Spaces:
Paused
Paused
Commit Β·
0c3df82
1
Parent(s): 82cc86d
fix: install nvidia-cudnn-cu12 alongside CUDA torch (removes --no-deps)
Browse files
app.py
CHANGED
|
@@ -19,19 +19,21 @@ print("=== PYTHON STARTED ===", flush=True)
|
|
| 19 |
|
| 20 |
# ββ Force CUDA torch before any `import torch` happens in this process βββββββββ
|
| 21 |
# requirements.txt installs CPU torch as a transitive dep of sentence-transformers.
|
| 22 |
-
# --force-reinstall overrides "already satisfied"
|
|
|
|
| 23 |
# This subprocess runs before gradio (and therefore before any torch import).
|
| 24 |
-
print("Installing CUDA torch
|
| 25 |
_cuda_r = subprocess.run(
|
| 26 |
[sys.executable, "-m", "pip", "install", "-q",
|
| 27 |
-
"--force-reinstall",
|
| 28 |
"--index-url", "https://download.pytorch.org/whl/cu121",
|
|
|
|
| 29 |
"torch"],
|
| 30 |
capture_output=True, text=True,
|
| 31 |
-
timeout=
|
| 32 |
)
|
| 33 |
if _cuda_r.returncode == 0:
|
| 34 |
-
print("CUDA torch installed OK.", flush=True)
|
| 35 |
else:
|
| 36 |
print("CUDA torch install FAILED:", _cuda_r.stderr[-400:], flush=True)
|
| 37 |
|
|
|
|
| 19 |
|
| 20 |
# ββ Force CUDA torch before any `import torch` happens in this process βββββββββ
|
| 21 |
# requirements.txt installs CPU torch as a transitive dep of sentence-transformers.
|
| 22 |
+
# --force-reinstall overrides "already satisfied" and also installs nvidia-cudnn-cu12
|
| 23 |
+
# and other CUDA runtime packages needed by the LSTM kernel (cuDNN).
|
| 24 |
# This subprocess runs before gradio (and therefore before any torch import).
|
| 25 |
+
print("Installing CUDA torch + cuDNN...", flush=True)
|
| 26 |
_cuda_r = subprocess.run(
|
| 27 |
[sys.executable, "-m", "pip", "install", "-q",
|
| 28 |
+
"--force-reinstall",
|
| 29 |
"--index-url", "https://download.pytorch.org/whl/cu121",
|
| 30 |
+
"--extra-index-url", "https://pypi.org/simple",
|
| 31 |
"torch"],
|
| 32 |
capture_output=True, text=True,
|
| 33 |
+
timeout=600,
|
| 34 |
)
|
| 35 |
if _cuda_r.returncode == 0:
|
| 36 |
+
print("CUDA torch + cuDNN installed OK.", flush=True)
|
| 37 |
else:
|
| 38 |
print("CUDA torch install FAILED:", _cuda_r.stderr[-400:], flush=True)
|
| 39 |
|