Error database

OSError: [WinError 1455] The paging file is too small for this operation to complete

Windows ran out of memory commit while loading PyTorch's large CUDA DLLs — often multiplied by DataLoader workers. Enlarge the Windows paging file and cut num_workers.

The message you saw
OSError: [WinError 1455] The paging file is too small for this operation to complete

By Updated

The error

Output
OSError: [WinError 1455] The paging file is too small for this operation to complete. Error loading "C:\Users\you\venv\Lib\site-packages\torch\lib\cudnn_adv_infer64_8.dll" or one of its dependencies.

The DLL named varies — any of torch's CUDA libraries can be the one that tips it over.

What it means

Windows accounts for memory as commit: every allocation must be backed by physical RAM plus the paging file (disk space Windows can swap to). PyTorch's CUDA DLLs are huge, and loading them reserves a large amount of commit — even though most of it is never touched. Your machine's RAM + paging file could not cover the reservation, so the load failed. It is not about your GPU, and often not even about real memory usage.

Why it happens

Three multipliers stack up:

  • The CUDA build of PyTorch reserves several GB of commit at import.
  • Every DataLoader worker is a separate process that imports torch again — num_workers=8 means nine copies of that reservation.
  • Many Windows machines have a small, fixed-size paging file, or one disabled to "save disk".

The combination fails on machines with plenty of RAM, which is what makes it confusing.

How to fix it

1. Enlarge the paging file. Settings → System → About → Advanced system settings → Performance Settings → Advanced → Virtual memory Change. Untick "Automatically manage", select the drive holding your Python environment, choose Custom size, and set something generous — for example initial 16000 MB, maximum 40000 MB (more if you run many workers). Restart Windows.

Letting Windows manage the size also works when the drive has free space; the failure mode is a fixed small size or a full drive.

2. Reduce the number of processes importing torch.

python
loader = DataLoader(ds, batch_size=32, num_workers=2)   # or 0 to test

Each worker you remove returns one full copy of the commit reservation. On Windows, high num_workers pays off less than on Linux anyway.

3. Close other commit-heavy programs. Browsers with many tabs hold gigabytes of commit. Check Task Manager's Performance tab — "Committed" shows the totals that matter for this error.

4. Free disk space on the paging drive. The paging file cannot grow on a full disk, which silently caps your commit limit.

How to prevent it

On any Windows machine used for deep learning, set the paging file generously once and forget it. Keep num_workers modest, and remember that every extra worker is a whole extra process on Windows — see the bootstrapping-phase error for the other thing that fact breaks.