MPS_NOT_AVAILABLE
pytorch
config_error
ai_generated
true
运行时错误:MPS后端不可用。请安装支持MPS的PyTorch或使用CPU/CUDA。
RuntimeError: MPS backend is not available. Please install PyTorch with MPS support or use CPU/CUDA.
ID: pytorch/mps-backend-unavailable
85%修复率
90%置信度
1证据数
2023-04-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| torch>=1.12 | active | — | — | — |
| macOS>=12.3 | active | — | — | — |
| MPS>=1.0 | active | — | — | — |
根因分析
PyTorch编译时未启用MPS(Metal Performance Shaders)支持,或系统缺少兼容的Apple GPU/macOS版本。
English
PyTorch was built without MPS (Metal Performance Shaders) support, or the system lacks a compatible Apple GPU/macOS version.
官方文档
https://pytorch.org/docs/stable/mps.html解决方案
-
安装支持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'))
无效尝试
常见但无效的做法:
-
conda install pytorch -c pytorch
70% 失败
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% 失败
Setting environment variable PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 does not enable MPS; it only controls memory threshold.