RunTime Error : cuda out of memory

created at 10-01-2021 views: 13

error

RuntimeError: CUDA error: out of memory

Divided into two situations

Case 1

CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 7.93 GiB total capacity; 6.68 GiB already allocated; 18.06 MiB free; 41.28 MiB cached)

reason

The process of running the network model fills up the memory and causes an interruption

solution

Reduce the Batch-size of the input 
Or reduce the size of the picture

Case 2

Only error message out of memory
The landlord googled the answer, it was found that the network pre-training model did not match the Pytorch version

solution

Do not directly extract the entire network, only the model parameters, this method requires you to have the parameter file of the model.

only the model parameters

created at:10-01-2021
edited at: 10-01-2021: