pytorch
config_error
ai_generated
true
RuntimeError: torch.cuda.amp.autocast only works with CUDA
ID: pytorch/amp-autocast-error
85%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2 | active | — | — | — |
Root Cause
AMP autocast used without CUDA or with wrong device.
genericWorkarounds
-
92% success Use torch.amp.autocast(device_type="cuda") for GPU, "cpu" for CPU
-
88% success Check torch.cuda.is_available() before enabling AMP
Dead Ends
Common approaches that don't work:
-
Disable AMP entirely
68% fail
Slower training
-
Force CUDA context on CPU
90% fail
Crash