Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,39 @@ import subprocess
|
|
2 |
import re
|
3 |
from typing import List, Tuple, Optional
|
4 |
|
|
|
5 |
# Define the command to be executed
|
6 |
command = ["python", "setup.py", "build_ext", "--inplace"]
|
7 |
|
8 |
# Execute the command
|
9 |
result = subprocess.run(command, capture_output=True, text=True)
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
# Print the output and error (if any)
|
12 |
print("Output:\n", result.stdout)
|
13 |
print("Errors:\n", result.stderr)
|
@@ -413,11 +440,6 @@ def reset_propagation(first_frame_path, predictor, stored_inference_state):
|
|
413 |
# print(f"RESET State: {stored_inference_state} ")
|
414 |
return first_frame_path, gr.State([]), gr.State([]), gr.update(value=None, visible=False), stored_inference_state, None, ["frame_0.jpg"], first_frame_path, "frame_0.jpg", gr.update(visible=False)
|
415 |
|
416 |
-
css="""
|
417 |
-
div#component-18, div#component-25, div#component-35, div#component-41{
|
418 |
-
align-items: stretch!important;
|
419 |
-
}
|
420 |
-
"""
|
421 |
|
422 |
with gr.Blocks(css=css) as demo:
|
423 |
first_frame_path = gr.State()
|
|
|
2 |
import re
|
3 |
from typing import List, Tuple, Optional
|
4 |
|
5 |
+
|
6 |
# Define the command to be executed
|
7 |
command = ["python", "setup.py", "build_ext", "--inplace"]
|
8 |
|
9 |
# Execute the command
|
10 |
result = subprocess.run(command, capture_output=True, text=True)
|
11 |
|
12 |
+
|
13 |
+
def install_cuda_toolkit():
|
14 |
+
# CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run"
|
15 |
+
CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run"
|
16 |
+
CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
|
17 |
+
subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
|
18 |
+
subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
|
19 |
+
subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
|
20 |
+
|
21 |
+
os.environ["CUDA_HOME"] = "/usr/local/cuda"
|
22 |
+
os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
|
23 |
+
os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
|
24 |
+
os.environ["CUDA_HOME"],
|
25 |
+
"" if "LD_LIBRARY_PATH" not in os.environ else os.environ["LD_LIBRARY_PATH"],
|
26 |
+
)
|
27 |
+
# Fix: arch_list[-1] += '+PTX'; IndexError: list index out of range
|
28 |
+
os.environ["TORCH_CUDA_ARCH_LIST"] = "8.0;8.6"
|
29 |
+
|
30 |
+
install_cuda_toolkit()
|
31 |
+
|
32 |
+
css="""
|
33 |
+
div#component-18, div#component-25, div#component-35, div#component-41{
|
34 |
+
align-items: stretch!important;
|
35 |
+
}
|
36 |
+
"""
|
37 |
+
|
38 |
# Print the output and error (if any)
|
39 |
print("Output:\n", result.stdout)
|
40 |
print("Errors:\n", result.stderr)
|
|
|
440 |
# print(f"RESET State: {stored_inference_state} ")
|
441 |
return first_frame_path, gr.State([]), gr.State([]), gr.update(value=None, visible=False), stored_inference_state, None, ["frame_0.jpg"], first_frame_path, "frame_0.jpg", gr.update(visible=False)
|
442 |
|
|
|
|
|
|
|
|
|
|
|
443 |
|
444 |
with gr.Blocks(css=css) as demo:
|
445 |
first_frame_path = gr.State()
|