pytorch config_error ai_generated true

RuntimeError: cannot pin memory: CUDA not available

ID: pytorch/pin-memory-error

Also available as: JSON · Markdown
85%Fix Rate
88%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
2 active

Root Cause

DataLoader pin_memory fails without CUDA.

generic

Workarounds

  1. 92% success Set pin_memory=True only when torch.cuda.is_available()
  2. 88% success Use pin_memory=False for CPU-only training

Dead Ends

Common approaches that don't work:

  1. Ignore error and continue without pinning 65% fail

    Slower data transfer when GPU available

  2. Force CUDA initialization 88% fail

    Fails without GPU hardware