I’m running my model on Google Colab and I’m faced with CUDA out of memory error. I have batch_size = 20 and all the images are resized to (224,224) . I am using vgg13 model with pre-trained weights with a custom classifier:
classifier = nn.Sequential(OrderedDict([                           ('fc1', nn.Linear(25088, 25088)),                           ('relu', nn.ReLU()),                           ('dropout', nn.Dropout(0.5)),                           ('fc2', nn.Linear(25088, 2048)),                           ('relu', nn.ReLU()),                           ('dropout', nn.Dropout(0.5)),                           ('fc3', nn.Linear(2048, 1024)),                           ('relu', nn.ReLU()),                           ('dropout', nn.Dropout(0.5)),                           ('fc4', nn.Linear(1024, 10))                                                                              ]))
I tried deleting images and labels of each iteration but no use. What else can I do to bring down memory usage and/or why is Cuda having an out of memory error?(I just trained a densenet 121 with no problems on same data)
Notebook:

  
      github.com
  
  
    arohanajit/disease-detector/blob/master/melanoma/torchvgg.ipynb 1
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "Untitled5.ipynb",
      "provenance": [],
      "private_outputs": true,
      "authorship_tag": "ABX9TyOtIOg4+01eUxdQ/izPGWPK",
      "include_colab_link": true
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",


  This file has been truncated. show original