Spaces:
Running on Zero
Running on Zero
Fix Spaces runtime: Import spaces before torch to prevent CUDA init error
Browse files
app.py
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import json
|
| 2 |
import os
|
| 3 |
import traceback
|
|
@@ -17,18 +30,6 @@ from space_backend import (
|
|
| 17 |
run_predict_only,
|
| 18 |
)
|
| 19 |
|
| 20 |
-
try:
|
| 21 |
-
import spaces
|
| 22 |
-
except ImportError:
|
| 23 |
-
class _SpacesFallback:
|
| 24 |
-
@staticmethod
|
| 25 |
-
def GPU(fn=None, **_kwargs):
|
| 26 |
-
if fn is None:
|
| 27 |
-
def decorator(inner):
|
| 28 |
-
return inner
|
| 29 |
-
return decorator
|
| 30 |
-
return fn
|
| 31 |
-
spaces = _SpacesFallback()
|
| 32 |
|
| 33 |
AUTO_PRELOAD_BADAS = os.environ.get("COSMOS_PRELOAD_BADAS", "1") == "1"
|
| 34 |
AUTO_PRELOAD_REASON = os.environ.get("COSMOS_PRELOAD_REASON", "1") == "1"
|
|
|
|
| 1 |
+
try:
|
| 2 |
+
import spaces
|
| 3 |
+
except ImportError:
|
| 4 |
+
class _SpacesFallback:
|
| 5 |
+
@staticmethod
|
| 6 |
+
def GPU(fn=None, **_kwargs):
|
| 7 |
+
if fn is None:
|
| 8 |
+
def decorator(inner):
|
| 9 |
+
return inner
|
| 10 |
+
return decorator
|
| 11 |
+
return fn
|
| 12 |
+
spaces = _SpacesFallback()
|
| 13 |
+
|
| 14 |
import json
|
| 15 |
import os
|
| 16 |
import traceback
|
|
|
|
| 30 |
run_predict_only,
|
| 31 |
)
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
AUTO_PRELOAD_BADAS = os.environ.get("COSMOS_PRELOAD_BADAS", "1") == "1"
|
| 35 |
AUTO_PRELOAD_REASON = os.environ.get("COSMOS_PRELOAD_REASON", "1") == "1"
|