MPS_NOT_AVAILABLE
pytorch
config_error
ai_generated
true
RuntimeError: MPS backend is not available. Please install PyTorch with MPS support or use CPU/CUDA.
ID: pytorch/mps-backend-unavailable
85%Fix Rate
90%Confidence
1Evidence
2023-04-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| torch>=1.12 | active | — | — | — |
| macOS>=12.3 | active | — | — | — |
| MPS>=1.0 | active | — | — | — |
Root Cause
PyTorch was built without MPS (Metal Performance Shaders) support, or the system lacks a compatible Apple GPU/macOS version.
generic中文
PyTorch编译时未启用MPS(Metal Performance Shaders)支持,或系统缺少兼容的Apple GPU/macOS版本。
Official Documentation
https://pytorch.org/docs/stable/mps.htmlWorkarounds
-
90% success Install PyTorch with MPS support: pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/mps. Then verify with: import torch; print(torch.backends.mps.is_available())
Install PyTorch with MPS support: pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/mps. Then verify with: import torch; print(torch.backends.mps.is_available())
-
95% success Fall back to CPU: device = torch.device('cuda' if torch.cuda.is_available() else ('mps' if torch.backends.mps.is_available() else 'cpu'))
Fall back to CPU: device = torch.device('cuda' if torch.cuda.is_available() else ('mps' if torch.backends.mps.is_available() else 'cpu'))
中文步骤
安装支持MPS的PyTorch:pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/mps。然后验证:import torch; print(torch.backends.mps.is_available())
回退到CPU:device = torch.device('cuda' if torch.cuda.is_available() else ('mps' if torch.backends.mps.is_available() else 'cpu'))
Dead Ends
Common approaches that don't work:
-
conda install pytorch -c pytorch
70% fail
Installing PyTorch from conda default channel often ships CPU-only build; user must explicitly select MPS variant.
-
export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0
90% fail
Setting environment variable PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 does not enable MPS; it only controls memory threshold.