I was trying the coding implementation of a research paper Attention Aware Polarity Sensitive Embedding for Affective Image Retrieval. I found this code on github:
Coding Implementation
 print("check point ---2")
    print(len(self.base._modules))
    for name, module in self.base._modules.items():
      print(name)
      print(x.size())
      if name == 'avgpool':
        break

      if name == 'layer3':
        l2 = x
      x = module(x)
      l4 = x
    print("check point ---x") 

The terminal on Google Colab quits after printing this:
Output with cuda
It never reaches “checkpoint —x”, and the program just ends.
I tried to remove the  .cuda()  from the  __init()__  :
output without cuda
I observed that it was able to loop over one more iteration, so I believe that the RAM on Google Colab is filling up as the model is very large. I want to know if there is a workaround for this piece of code.If I can find l2 and l4 some other way?