OpenBMB/VoxCPM · error · ValueError
Requested device '{device}', but CUDA is not available. Use
Error message
Requested device '{device}', but CUDA is not available. Use device='auto' for automatic fallback. What it means
resolve_runtime_device treats 'cuda'/'cuda:N' as an explicit requirement: if torch.cuda.is_available() is False it raises rather than silently falling back (use 'auto' for fallback).
Source
Thrown at src/voxcpm/model/utils.py:226
return "cpu"
def resolve_runtime_device(device: Optional[str], configured_device: str = "cuda") -> str:
"""
Resolve the actual runtime device.
Semantics:
- ``device`` is ``None`` or ``"auto"``: use automatic fallback selection
- otherwise: treat it as an explicit user choice and validate availability
"""
explicit = None if device is None else device.strip().lower()
if explicit is None or explicit == "auto":
return auto_select_device(configured_device)
if explicit.startswith("cuda"):
if not torch.cuda.is_available():
raise ValueError(
f"Requested device '{device}', but CUDA is not available. " "Use device='auto' for automatic fallback."
)
return explicit
if explicit == "mps":
if not _has_mps():
raise ValueError(
"Requested device 'mps', but MPS is not available. " "Use device='auto' for automatic fallback."
)
return "mps"
if explicit == "cpu":
return "cpu"
raise ValueError(
f"Unsupported device '{device}'. Supported values are 'auto', 'cpu', 'mps', "
"'cuda', or indexed CUDA devices like 'cuda:0'."
)
View on GitHub (pinned to f5a1c6a6b9)
Solutions
- Use device='auto' to let it pick the best available device
- Install/fix CUDA-enabled torch (pip install torch with cuda wheels) and drivers
- If CPU is intended, pass device='cpu' explicitly
Example fix
# before model = VoxCPM(..., device="cuda") # after model = VoxCPM(..., device="auto")
Defensive patterns
Strategy: fallback
Validate before calling
import torch
if device and device.startswith("cuda") and not torch.cuda.is_available():
device = "auto" Type guard
def cuda_ok() -> bool:
import torch; return torch.cuda.is_available() Prevention
- Default to device='auto' in configs
- Smoke-test torch.cuda.is_available() at startup on GPU boxes
When it happens
Trigger: Passing device='cuda' on a machine without CUDA GPU, without NVIDIA drivers, or in a CPU-only Docker/CI image; also broken CUDA installs where torch cannot initialize it.
Common situations: Developing on Mac/CI then deploying config with device='cuda'; driver/CUDA toolkit mismatch; GPU occupied/unavailable in containers without nvidia runtime.
Related errors
- Requested device 'mps', but MPS is not available. Use device
- Unsupported device '{device}'. Supported values are 'auto',
AI-assisted analysis of OpenBMB/VoxCPM@f5a1c6a6b9 (2026-08-27).
Data as JSON: /api/errors/49ae619a824b86dd.
Report an issue: GitHub.