{"record":{"id":"49ae619a824b86dd","repo":"OpenBMB/VoxCPM","slug":"requested-device-device-but-cuda-is-not-avail","errorCode":null,"errorMessage":"Requested device '{device}', but CUDA is not available. Use device='auto' for automatic fallback.","messagePattern":"Requested device '(.+?)', but CUDA is not available\\. Use device='auto' for automatic fallback\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/voxcpm/model/utils.py","lineNumber":226,"sourceCode":"    return \"cpu\"\n\n\ndef resolve_runtime_device(device: Optional[str], configured_device: str = \"cuda\") -> str:\n    \"\"\"\n    Resolve the actual runtime device.\n\n    Semantics:\n    - ``device`` is ``None`` or ``\"auto\"``: use automatic fallback selection\n    - otherwise: treat it as an explicit user choice and validate availability\n    \"\"\"\n    explicit = None if device is None else device.strip().lower()\n\n    if explicit is None or explicit == \"auto\":\n        return auto_select_device(configured_device)\n\n    if explicit.startswith(\"cuda\"):\n        if not torch.cuda.is_available():\n            raise ValueError(\n                f\"Requested device '{device}', but CUDA is not available. \" \"Use device='auto' for automatic fallback.\"\n            )\n        return explicit\n    if explicit == \"mps\":\n        if not _has_mps():\n            raise ValueError(\n                \"Requested device 'mps', but MPS is not available. \" \"Use device='auto' for automatic fallback.\"\n            )\n        return \"mps\"\n    if explicit == \"cpu\":\n        return \"cpu\"\n\n    raise ValueError(\n        f\"Unsupported device '{device}'. Supported values are 'auto', 'cpu', 'mps', \"\n        \"'cuda', or indexed CUDA devices like 'cuda:0'.\"\n    )\n","sourceCodeStart":208,"sourceCodeEnd":243,"githubUrl":"https://github.com/OpenBMB/VoxCPM/blob/f5a1c6a6b901bc732e20f0d59a369f6829ad717a/src/voxcpm/model/utils.py#L208-L243","documentation":"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).","triggerScenarios":"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.","commonSituations":"Developing on Mac/CI then deploying config with device='cuda'; driver/CUDA toolkit mismatch; GPU occupied/unavailable in containers without nvidia runtime.","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"],"exampleFix":"# before\nmodel = VoxCPM(..., device=\"cuda\")\n# after\nmodel = VoxCPM(..., device=\"auto\")","handlingStrategy":"fallback","validationCode":"import torch\nif device and device.startswith(\"cuda\") and not torch.cuda.is_available():\n    device = \"auto\"","typeGuard":"def cuda_ok() -> bool:\n    import torch; return torch.cuda.is_available()","tryCatchPattern":null,"preventionTips":["Default to device='auto' in configs","Smoke-test torch.cuda.is_available() at startup on GPU boxes"],"tags":["cuda","device-selection","environment"],"backgroundTag":"cuda-not-available","analyzedSha":"f5a1c6a6b901bc732e20f0d59a369f6829ad717a","analyzedAt":"2026-08-27T05:54:30.617Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}