PyTorch PermissionError: [Errno 13] Permission denied: '/.torch'
I'm running a PyTorch based ML program for image classification using Resnet50 model for transfer learning. I am getting below error regarding permission.

Traceback (most recent call last):
File &quot;imgc_pytorch.py&quot;, line 67, in 
  model = models.resnet50(pretrained=True)
File &quot;/opt/conda/lib/python3.6/site-packages/torchvision/models/resnet.py&quot;, line 187, in resnet50
  model.load_state_dict(model_zoo.load_url(model_urls['resnet50']))
File &quot;/opt/conda/lib/python3.6/site-packages/torch/utils/model_zoo.py&quot;,
line 59, in load_url
  os.makedirs(model_dir)
File &quot;/opt/conda/lib/python3.6/os.py&quot;, line 210, in makedirs
  makedirs(head, mode, exist_ok)
File &quot;/opt/conda/lib/python3.6/os.py&quot;, line 220, in makedirs
  mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.torch'

Looked up on this forum and it was suggested to add 'sudo' before the file name, but getting error &quot;/bin/sh: 1: sudo: not found&quot;

you can change model_zoo.load_url(model_urls['resnet50']) to model_zoo.load_url(model_urls['resnet50'], model_dir='~/.torch/') like this
