Loading pre trained model (vgg16) - RuntimeError: storage has wrong size: expected 0 got 512

Hi,
When i load the model via my pc it works, but when i run it via the GPU cluster it fails.
this is the code:

class _netVGGFeatures(nn.Module):
    def __init__(self):
        super(_netVGGFeatures, self).__init__()
        self.vggnet = models.vgg16(pretrained=True).cuda() #FAIL HERE

this is the error i get:

    self.vggnet = models.vgg16(pretrained=True).cuda() #Load the pre trained VGG16 model from pytorch on GPU
  File "/cs/usr/daniel023/.local/lib/python3.6/site-packages/torchvision/models/vgg.py", line 152, in vgg16
    model.load_state_dict(model_zoo.load_url(model_urls['vgg16']))
  File "/cs/usr/daniel023/.local/lib/python3.6/site-packages/torch/utils/model_zoo.py", line 67, in load_url
    return torch.load(cached_file, map_location=map_location)
  File "/cs/usr/daniel023/.local/lib/python3.6/site-packages/torch/serialization.py", line 368, in load
    return _load(f, map_location, pickle_module)
  File "/cs/usr/daniel023/.local/lib/python3.6/site-packages/torch/serialization.py", line 549, in _load
    deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: storage has wrong size: expected 0 got 512

Thanks for any help :slight_smile:

Can you verify if the torchvision version is same in your PC and GPU server?
You can also verify if torchvision is loading the same version of vgg model. The pretrained models usually be downloaded to ~/.torch/models.