{"record":{"id":"621f625976ad5711","repo":"OpenBMB/VoxCPM","slug":"requested-device-mps-but-mps-is-not-available","errorCode":null,"errorMessage":"Requested device 'mps', but MPS is not available. Use device='auto' for automatic fallback.","messagePattern":"Requested device 'mps', but MPS is not available\\. Use device='auto' for automatic fallback\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/voxcpm/model/utils.py","lineNumber":232,"sourceCode":"\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":214,"sourceCodeEnd":243,"githubUrl":"https://github.com/OpenBMB/VoxCPM/blob/f5a1c6a6b901bc732e20f0d59a369f6829ad717a/src/voxcpm/model/utils.py#L214-L243","documentation":"Explicitly requesting device='mps' fails with ValueError when torch.backends.mps is unavailable, mirroring the CUDA check. 'auto' would fall back instead.","triggerScenarios":"Passing device='mps' on Linux/Windows, on macOS without Apple Silicon or too-old macOS/torch, or in environments where MPS is disabled.","commonSituations":"Config written for Apple Silicon reused on a Linux server; older torch builds predating MPS support.","solutions":["Use device='auto' so the model falls back to CPU/CUDA as available","On macOS, upgrade to a torch version with MPS support and a supported macOS version","Pass device='cpu' or 'cuda' explicitly on non-Apple machines"],"exampleFix":"# before\nmodel = VoxCPM(..., device=\"mps\")  # on Linux\n# after\nmodel = VoxCPM(..., device=\"auto\")","handlingStrategy":"fallback","validationCode":"import torch\ndef mps_ok() -> bool:\n    return hasattr(torch.backends, \"mps\") and torch.backends.mps.is_available()\nif device == \"mps\" and not mps_ok():\n    device = \"auto\"","typeGuard":"def mps_ok() -> bool:\n    import torch; return getattr(torch.backends, \"mps\", None) is not None and torch.backends.mps.is_available()","tryCatchPattern":null,"preventionTips":["Never hardcode 'mps' in shared configs","Use 'auto' unless you specifically must force a device"],"tags":["mps","device-selection","macos"],"backgroundTag":"device-not-available","analyzedSha":"f5a1c6a6b901bc732e20f0d59a369f6829ad717a","analyzedAt":"2026-08-27T05:54:30.617Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}