Spaces:
Sleeping
Sleeping
Update config.py
Browse files
config.py
CHANGED
|
@@ -29,27 +29,6 @@ try:
|
|
| 29 |
except ImportError:
|
| 30 |
HAS_SPACES = False
|
| 31 |
|
| 32 |
-
def gpu_decorator(func=None, duration=None):
|
| 33 |
-
"""
|
| 34 |
-
Safely apply @spaces.GPU if in an active ZeroGPU environment,
|
| 35 |
-
otherwise return the original function as a no-op fallback.
|
| 36 |
-
"""
|
| 37 |
-
if HAS_SPACES:
|
| 38 |
-
try:
|
| 39 |
-
if func is None:
|
| 40 |
-
return spaces.GPU(duration=duration) if duration else spaces.GPU
|
| 41 |
-
if callable(func):
|
| 42 |
-
return spaces.GPU(func)
|
| 43 |
-
return spaces.GPU
|
| 44 |
-
except (NotImplementedError, Exception):
|
| 45 |
-
pass
|
| 46 |
-
|
| 47 |
-
if func is None:
|
| 48 |
-
return lambda f: f
|
| 49 |
-
if callable(func):
|
| 50 |
-
return func
|
| 51 |
-
return lambda f: f
|
| 52 |
-
|
| 53 |
def get_device() -> str:
|
| 54 |
"""Dynamically return 'cuda' if CUDA/ZeroGPU is active, otherwise 'cpu'."""
|
| 55 |
return "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 29 |
except ImportError:
|
| 30 |
HAS_SPACES = False
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
def get_device() -> str:
|
| 33 |
"""Dynamically return 'cuda' if CUDA/ZeroGPU is active, otherwise 'cpu'."""
|
| 34 |
return "cuda" if torch.cuda.is_available() else "cpu"
|