Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,40 @@
|
|
1 |
import spaces
|
2 |
import os
|
3 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
@spaces.GPU(duration=180)
|
5 |
def install_setup():
|
6 |
os.system("pip install git+https://github.com/facebookresearch/detectron2.git")
|
7 |
os.system("git clone https://github.com/Visual-AI/Mr.DETR.git MrDETR && cd MrDETR && rm -f requirements.txt && cd ..")
|
8 |
# os.system("cp multi_scale_deform_attn.py MrDETR/detrex/layers/ && cd MrDETR && pip install . & cd ..")
|
9 |
# os.system("cd MrDETR && export CUDA_HOME=$(dirname $(dirname $(which nvcc))) && pip install . & cd ..")
|
10 |
-
os.environ["CUDA_HOME"] = os.environ.get("CUDA_PATH")
|
11 |
os.system("cd MrDETR && pip install . & cd ..")
|
12 |
import sys
|
13 |
sys.path.append("MrDETR/")
|
|
|
1 |
import spaces
|
2 |
import os
|
3 |
import gradio as gr
|
4 |
+
import shutil
|
5 |
+
|
6 |
+
def find_cuda():
|
7 |
+
# Check if CUDA_HOME or CUDA_PATH environment variables are set
|
8 |
+
cuda_home = os.environ.get('CUDA_HOME') or os.environ.get('CUDA_PATH')
|
9 |
+
|
10 |
+
if cuda_home and os.path.exists(cuda_home):
|
11 |
+
return cuda_home
|
12 |
+
|
13 |
+
# Search for the nvcc executable in the system's PATH
|
14 |
+
nvcc_path = shutil.which('nvcc')
|
15 |
+
|
16 |
+
if nvcc_path:
|
17 |
+
# Remove the 'bin/nvcc' part to get the CUDA installation path
|
18 |
+
cuda_path = os.path.dirname(os.path.dirname(nvcc_path))
|
19 |
+
return cuda_path
|
20 |
+
|
21 |
+
return None
|
22 |
+
|
23 |
+
os.environ["CUDA_HOME"] = find_cuda()
|
24 |
+
|
25 |
+
if cuda_path:
|
26 |
+
print(f"CUDA installation found at: {cuda_path}")
|
27 |
+
else:
|
28 |
+
print("CUDA installation not found")
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
@spaces.GPU(duration=180)
|
33 |
def install_setup():
|
34 |
os.system("pip install git+https://github.com/facebookresearch/detectron2.git")
|
35 |
os.system("git clone https://github.com/Visual-AI/Mr.DETR.git MrDETR && cd MrDETR && rm -f requirements.txt && cd ..")
|
36 |
# os.system("cp multi_scale_deform_attn.py MrDETR/detrex/layers/ && cd MrDETR && pip install . & cd ..")
|
37 |
# os.system("cd MrDETR && export CUDA_HOME=$(dirname $(dirname $(which nvcc))) && pip install . & cd ..")
|
|
|
38 |
os.system("cd MrDETR && pip install . & cd ..")
|
39 |
import sys
|
40 |
sys.path.append("MrDETR/")
|