PyTorch Can’t Allocate More Memory

Photo by Fredy Jacob on Unsplash

We all love PyTorch for many obvious reasons (i.e. ease of implementing our ideas). But, sometimes you run into an error:

CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 15.90 GiB total capacity; 15.17 GiB already allocated; 15.88 MiB free; 15.18 GiB reserved in total by PyTorch)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store