Spaces:
Running on Zero
Running on Zero
Detect CUDA home dynamically instead of hardcoded /cuda-image/... path
Browse filesThe hardcoded /cuda-image/usr/local/cuda-12.9 path does not exist on
the current ZeroGPU runtime container. Detect via shutil.which("nvcc")
first, then scan common /usr/local/cuda* paths as fallback.
app.py
CHANGED
|
@@ -128,8 +128,31 @@ def _install_runtime_packages():
|
|
| 128 |
)
|
| 129 |
# A10G = sm_86. Set arch list explicitly because NVML is unavailable at install
|
| 130 |
# time (no GPU allocated yet), so torch can't auto-detect it.
|
| 131 |
-
# CUDA
|
| 132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
_cuda_env = {
|
| 134 |
**os.environ,
|
| 135 |
"TORCH_CUDA_ARCH_LIST": "8.6",
|
|
|
|
| 128 |
)
|
| 129 |
# A10G = sm_86. Set arch list explicitly because NVML is unavailable at install
|
| 130 |
# time (no GPU allocated yet), so torch can't auto-detect it.
|
| 131 |
+
# Detect CUDA home dynamically — path varies between ZeroGPU container builds.
|
| 132 |
+
import shutil as _shutil
|
| 133 |
+
_nvcc = _shutil.which("nvcc")
|
| 134 |
+
if _nvcc:
|
| 135 |
+
_cuda_home = str(Path(_nvcc).parent.parent)
|
| 136 |
+
else:
|
| 137 |
+
# Scan common ZeroGPU / CUDA container paths
|
| 138 |
+
for _cand in [
|
| 139 |
+
"/usr/local/cuda",
|
| 140 |
+
"/usr/local/cuda-12.9",
|
| 141 |
+
"/usr/local/cuda-12.8",
|
| 142 |
+
"/usr/local/cuda-12.4",
|
| 143 |
+
"/usr/local/cuda-12.1",
|
| 144 |
+
"/cuda-image/usr/local/cuda-12.9",
|
| 145 |
+
"/cuda-image/usr/local/cuda",
|
| 146 |
+
]:
|
| 147 |
+
if Path(_cand, "bin", "nvcc").exists():
|
| 148 |
+
_cuda_home = _cand
|
| 149 |
+
break
|
| 150 |
+
else:
|
| 151 |
+
raise RuntimeError(
|
| 152 |
+
"nvcc not found — no CUDA toolkit in PATH or standard locations. "
|
| 153 |
+
"Cannot build nvdiffrast/detectron2/diso."
|
| 154 |
+
)
|
| 155 |
+
print(f"[startup] CUDA home: {_cuda_home}")
|
| 156 |
_cuda_env = {
|
| 157 |
**os.environ,
|
| 158 |
"TORCH_CUDA_ARCH_LIST": "8.6",
|