I am working on a classification problem and using Google Colab for the implementation. I am using transfer learning and specifically using ResNet at the moment. I have 5955 images in the train set. When I am running my code, I face the following error:
RuntimeError: CUDA out of memory. Tried to allocate 1.53 GiB (GPU 0; 14.76 GiB total capacity; 12.24 GiB already allocated; 1.27 GiB free; 12.44 GiB reserved in total by PyTorch)
I have tried to clear out cache using
device = 'cuda' import torch, gc import os gc.collect() torch.cuda.empty_cache()
It does not seem to work either. I have a batch size of 512 for train loader, 256 for valid and test loader.