Spaces:
Sleeping
Sleeping
Download space_runtime.py from Yu-star/RLMF-m6APred-Web: direct link, hf CLI and curl.
- Browser
- Download file 702 Bytes
-
https://huggingface.co/spaces/Yu-star/RLMF-m6APred-Web/resolve/main/space_runtime.py
- Command line
-
hf download hf://spaces/Yu-star/RLMF-m6APred-Web/space_runtime.py
-
curl -L -o space_runtime.py https://huggingface.co/spaces/Yu-star/RLMF-m6APred-Web/resolve/main/space_runtime.py
702 Bytes
| """Prepare the shared backbone before ZeroGPU starts an inference worker.""" | |
| from __future__ import annotations | |
| import os | |
| ON_SPACE = bool(os.environ.get("SPACE_ID")) | |
| if ON_SPACE: | |
| import spaces # Set up CUDA emulation before importing torch or the model. | |
| from rlmf import get_predictor | |
| def _predict(dataset: str, sequence: str): | |
| return get_predictor().predict(dataset, sequence) | |
| if ON_SPACE: | |
| # Only the forward pass and fold checkpoint application need the GPU slot. | |
| # Initialize in the parent process, before any decorated function runs. | |
| get_predictor(device="cuda").prepare() | |
| predict_sequence = spaces.GPU(duration=20)(_predict) | |
| else: | |
| predict_sequence = _predict | |