# RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map the storages to the CPU.

- **ID:** `pytorch/model-save-load-device-mismatch`
- **Domain:** pytorch
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

Loading a model checkpoint that was saved on a GPU machine onto a CPU-only machine without specifying map_location, causing PyTorch to try to load CUDA tensors on a non-CUDA system.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.10 | active | — | — |
| 1.11 | active | — | — |
| 1.12 | active | — | — |
| 1.13 | active | — | — |
| 2.0 | active | — | — |
| 2.1 | active | — | — |
| 2.2 | active | — | — |
| 2.3 | active | — | — |

## Workarounds

1. **Use torch.load with map_location=torch.device('cpu') to load the checkpoint onto CPU, then move the model to the desired device afterward.** (95% success)
   ```
   Use torch.load with map_location=torch.device('cpu') to load the checkpoint onto CPU, then move the model to the desired device afterward.
   ```
2. **Alternatively, use map_location='cpu' directly as a string argument.** (90% success)
   ```
   Alternatively, use map_location='cpu' directly as a string argument.
   ```

## Dead Ends

- **** — This doesn't address the device mismatch; the model still expects CUDA. (80% fail)
- **** — This just changes the file path but doesn't fix the loading device. (90% fail)
