# RuntimeError: MPS backend is not available. Please install PyTorch with MPS support or use CPU/CUDA.

- **ID:** `pytorch/mps-backend-unavailable`
- **Domain:** pytorch
- **Category:** config_error
- **Error Code:** `MPS_NOT_AVAILABLE`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

PyTorch was built without MPS (Metal Performance Shaders) support, or the system lacks a compatible Apple GPU/macOS version.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| torch>=1.12 | active | — | — |
| macOS>=12.3 | active | — | — |
| MPS>=1.0 | active | — | — |

## Workarounds

1. **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())** (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())
   ```
2. **Fall back to CPU: device = torch.device('cuda' if torch.cuda.is_available() else ('mps' if torch.backends.mps.is_available() else 'cpu'))** (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'))
   ```

## Dead Ends

- **conda install pytorch -c pytorch** — Installing PyTorch from conda default channel often ships CPU-only build; user must explicitly select MPS variant. (70% fail)
- **export PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0** — Setting environment variable PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 does not enable MPS; it only controls memory threshold. (90% fail)
