Spaces:
Running
on
Zero
Running
on
Zero
刘虹雨
commited on
Commit
·
5c92efe
1
Parent(s):
f01c993
update code
Browse files
app.py
CHANGED
@@ -56,6 +56,43 @@ import shutil
|
|
56 |
|
57 |
# Suppress warnings (especially for PyTorch)
|
58 |
warnings.filterwarnings("ignore")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
# Configure logging settings
|
61 |
logging.basicConfig(
|
|
|
56 |
|
57 |
# Suppress warnings (especially for PyTorch)
|
58 |
warnings.filterwarnings("ignore")
|
59 |
+
import os
|
60 |
+
import subprocess
|
61 |
+
import sys
|
62 |
+
|
63 |
+
def auto_set_cuda_home():
|
64 |
+
"""
|
65 |
+
Automatically detect and set CUDA_HOME environment variable.
|
66 |
+
"""
|
67 |
+
if "CUDA_HOME" not in os.environ:
|
68 |
+
potential_paths = [
|
69 |
+
"/usr/local/cuda",
|
70 |
+
]
|
71 |
+
# Also scan for /usr/local/cuda-*
|
72 |
+
try:
|
73 |
+
ls_out = subprocess.check_output("ls /usr/local | grep cuda", shell=True).decode().splitlines()
|
74 |
+
for line in ls_out:
|
75 |
+
full_path = os.path.join("/usr/local", line.strip())
|
76 |
+
if os.path.isdir(full_path):
|
77 |
+
potential_paths.append(full_path)
|
78 |
+
except Exception:
|
79 |
+
pass
|
80 |
+
|
81 |
+
for path in potential_paths:
|
82 |
+
nvcc_path = os.path.join(path, "bin", "nvcc")
|
83 |
+
if os.path.exists(nvcc_path):
|
84 |
+
print(f"[INFO] Detected CUDA at: {path}")
|
85 |
+
os.environ["CUDA_HOME"] = path
|
86 |
+
os.environ["PATH"] = f'{os.path.join(path, "bin")}:' + os.environ.get("PATH", "")
|
87 |
+
os.environ["LD_LIBRARY_PATH"] = f'{os.path.join(path, "lib64")}:' + os.environ.get("LD_LIBRARY_PATH", "")
|
88 |
+
return
|
89 |
+
|
90 |
+
print("[WARNING] CUDA not found. Some plugins may fail to compile.")
|
91 |
+
else:
|
92 |
+
print(f"[INFO] CUDA_HOME is already set to: {os.environ['CUDA_HOME']}")
|
93 |
+
|
94 |
+
# 🔧 Set CUDA_HOME before anything else
|
95 |
+
auto_set_cuda_home()
|
96 |
|
97 |
# Configure logging settings
|
98 |
logging.basicConfig(
|