Permission Error while loading pretrained Vgg19

Hi, so I am trying to load pretrained vgg19 in an interactive session within a GPU cluster. I get this permission error while trying the following:

Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision.models as models
>>> import torch
>>> vgg19 = models.vgg19(pretrained=True)
Downloading: "https://download.pytorch.org/models/vgg19-dcbb9e9d.pth" to /.torch/models/vgg19-dcbb9e9d.pth
100%|#########################################################################################################################################| 574673361/574673361 [00:03<00:00, 162997989.65it/s]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/torchvision/models/vgg.py", line 141, in vgg19
    model.load_state_dict(model_zoo.load_url(model_urls['vgg19']))
  File "/usr/local/lib/python2.7/dist-packages/torch/utils/model_zoo.py", line 56, in load_url
    _download_url_to_file(url, cached_file, hash_prefix)
  File "/usr/local/lib/python2.7/dist-packages/torch/utils/model_zoo.py", line 85, in _download_url_to_file
    shutil.move(f.name, dst)
  File "/usr/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/usr/lib/python2.7/shutil.py", line 130, in copy2
    copyfile(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/.torch/models/vgg19-dcbb9e9d.pth'

How can I possibly avoid this issue?

seems like it’s trying to store ito /.torch rahter than ~/.torch, ie prefixed with the value of $HOME. Is it something like, for some reason $HOME isnt defined?

I see what’s going on. According to http://pytorch.org/docs/master/model_zoo.html?highlight=torch_home at torch.utils.model_zoo “The default value of model_dir is $TORCH_HOME/models where $TORCH_HOME defaults to ~/.torch. The default directory can be overriden with the $TORCH_MODEL_ZOO environment variable.”

Now if I want to load pretrained model directly from torch.utils.model_zoo, then I can use model_dir argument like loaded_state_dict = model_zoo.load_url(model_urls['vgg19'],'/code/cs231n/model') but in this case I am trying to do so through torchvision.models. In this case, how I might override the $TORCH_MODEL_ZOO environment variable? I mean where do i need to do so ?

Thanks!