Spaces:
Running on Zero
Running on Zero
Download core/gpu.py from MustafaHussein/te-assistant: direct link, hf CLI and curl.
- Browser
- Download file 521 Bytes
-
https://huggingface.co/spaces/MustafaHussein/te-assistant/resolve/main/core/gpu.py
- Command line
-
hf download hf://spaces/MustafaHussein/te-assistant/core/gpu.py
-
curl -L -o gpu.py https://huggingface.co/spaces/MustafaHussein/te-assistant/resolve/main/core/gpu.py
521 Bytes
| """ZeroGPU shim. On a ZeroGPU Space `gpu` is `spaces.GPU`; anywhere else it is a no-op, | |
| so the same code runs locally and on-prem. Import this module BEFORE torch.""" | |
| try: | |
| import spaces # type: ignore | |
| gpu = spaces.GPU | |
| ON_ZERO_GPU = True | |
| except Exception: # not on HF, or `spaces` not installed | |
| ON_ZERO_GPU = False | |
| def gpu(*args, **kwargs): | |
| if len(args) == 1 and callable(args[0]) and not kwargs: | |
| return args[0] | |
| def deco(fn): | |
| return fn | |
| return deco | |