Spaces:
Paused
Paused
Commit ·
d3bb466
1
Parent(s): 5907c41
Make _get_device() ZeroGPU-aware so models target CUDA
Browse filesOn ZeroGPU Spaces torch.cuda.is_available() returns False at
module-load time because the GPU is only attached inside @spaces.GPU.
Check spaces.config.Config.zero_gpu as a fallback so all models are
placed on CUDA and work correctly once the GPU is attached.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
139 unmodified lines140141142143144145146147139 unmodified linesdef _get_device() -> str:"""Use CUDA if available, else CPU (e.g. for CI or CPU-only environments)."""return "cuda:0" if torch.cuda.is_available() else "cpu"def _session_dir_from_target(target_audio_path: str) -> Path:139 unmodified lines140141142143144145146147148149150151152153154155156157158159160139 unmodified linesdef _get_device() -> str:"""Use CUDA if available, else CPU (e.g. for CI or CPU-only environments).On ZeroGPU Spaces the real GPU is only attached inside @spaces.GPU, sotorch.cuda.is_available() returns False at module-load time. We stillwant models to target CUDA so they run on the GPU once it is attached."""if torch.cuda.is_available():return "cuda:0"try:from spaces.config import Configif Config.zero_gpu:return "cuda:0"except (ImportError, AttributeError):passreturn "cpu"def _session_dir_from_target(target_audio_path: str) -> Path:
webui.py+15-2