Pretrained models cuda out of memory error

hi, i am working with vgg16 pretrained model. when train vgg16 model by freezing all layers there is no error. but when i freeze only few layers and tried to train i got cuda out of memory error. i also tried by removing last 7 layers of vgg16 and freeze the remaining layers i got cuda out of memory error . can anyone explain me why i got out memory in case freezing only certain layers …?
@ptrblck @tom

Not sure if this is relevent, but what batch size are you using? Have you tried reducing it?

batch size is 64 , may be it is due to less gpu memory i think i have 6gb nvidia GTX1060 graphic card. so i tried the same program in colab it worked.

Yes, i think that is the cause of your issue.