I downloaded the pretrained weights for resnet152 using Python 3.5 and test the below code with both Python 2.7 and Python 3.5. When i ran the code below in Python 2.7, it cause out-of-memory error (it requires more than 12GB).
resnet = torchvision.models.resnet152(pretrained=True)
for param in resnet.parameters():
param.requires_grad = False # It seems not work in Python 2.7
images = torch.randn(128, 3, 224, 224)
resnet = resnet.cuda()
images = images.cuda()
outputs = resnet(Variable(images)) # requires 2.3GB in Python 3.5
Do you have any idea why this is happening?