Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
74b2816
1
Parent(s):
629cf22
force torch to rec cuda
Browse files- app.py +18 -1
- requirements.txt +3 -2
app.py
CHANGED
@@ -22,6 +22,21 @@ import logging
|
|
22 |
from typing import List, Set, Tuple
|
23 |
import asyncio
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
def verify_gpu():
|
26 |
print("🔍 GPU Detection:")
|
27 |
print(f" - torch.cuda.is_available(): {torch.cuda.is_available()}")
|
@@ -29,8 +44,10 @@ def verify_gpu():
|
|
29 |
print(f" - CUDA Device: {torch.cuda.get_device_name(0)}")
|
30 |
print(f" - CUDA Version: {torch.version.cuda}")
|
31 |
print(f" - spaces.GPU_ENABLED: {hasattr(spaces, 'GPU_ENABLED') and spaces.GPU_ENABLED}")
|
|
|
|
|
32 |
|
33 |
-
#
|
34 |
verify_gpu()
|
35 |
|
36 |
|
|
|
22 |
from typing import List, Set, Tuple
|
23 |
import asyncio
|
24 |
|
25 |
+
os.environ["ZEROGPU_ENABLED"] = "1"
|
26 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
|
27 |
+
|
28 |
+
|
29 |
+
# Force torch to recognize CUDA if ZeroGPU is available
|
30 |
+
if hasattr(spaces, "GPU_ENABLED"):
|
31 |
+
print(f"🔍 Initial spaces.GPU_ENABLED: {spaces.GPU_ENABLED}")
|
32 |
+
# Try to activate spaces GPU support
|
33 |
+
try:
|
34 |
+
spaces.GPU_ENABLED = True
|
35 |
+
print(f"🔍 Set spaces.GPU_ENABLED to True")
|
36 |
+
except:
|
37 |
+
print(f"🔍 Could not set spaces.GPU_ENABLED")
|
38 |
+
|
39 |
+
# Verify GPU detection after configuration
|
40 |
def verify_gpu():
|
41 |
print("🔍 GPU Detection:")
|
42 |
print(f" - torch.cuda.is_available(): {torch.cuda.is_available()}")
|
|
|
44 |
print(f" - CUDA Device: {torch.cuda.get_device_name(0)}")
|
45 |
print(f" - CUDA Version: {torch.version.cuda}")
|
46 |
print(f" - spaces.GPU_ENABLED: {hasattr(spaces, 'GPU_ENABLED') and spaces.GPU_ENABLED}")
|
47 |
+
print(f" - CUDA_VISIBLE_DEVICES: {os.environ.get('CUDA_VISIBLE_DEVICES', 'not set')}")
|
48 |
+
print(f" - ZEROGPU_ENABLED: {os.environ.get('ZEROGPU_ENABLED', 'not set')}")
|
49 |
|
50 |
+
# Run verification at startup
|
51 |
verify_gpu()
|
52 |
|
53 |
|
requirements.txt
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
-
gradio==
|
|
|
2 |
pandas
|
3 |
transformers>=4.30.0
|
4 |
-
torch
|
5 |
tqdm
|
6 |
sentencepiece
|
7 |
pymystem3
|
|
|
1 |
+
gradio==4.44.0
|
2 |
+
spaces==0.19.4
|
3 |
pandas
|
4 |
transformers>=4.30.0
|
5 |
+
torch==2.1.2
|
6 |
tqdm
|
7 |
sentencepiece
|
8 |
pymystem3
|