RuntimeError: CUDA out of memory. Tried to allocate

Viewed 11068

I am trying to run a pytorch code with jupyter notebook and I got this error

RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 2.00 GiB total capacity; 1.23 GiB already allocated; 18.83 MiB free; 1.25 GiB reserved in total by PyTorch)

I had already find answer. and most of all say just reduce the batch size. I have tried reduce the batch size from 20 to 10 to 2 and 1. Right now still can't run the code

My GPU is Quadro p620

1 Answers

You can free up the existing memory by

nvidia-smi

note the process and kill using

sudo kill -9 <pid>

PS: Please the process before killing it!. This solution worked for me when i tried to run large model and it was still kept on running after stopping it. DON'T KILL THE MODEL WHICH IS ONGOING TRAINING!

Related