vision: Downloading pretrained models with torchvision gives HTTP Error 403

I’m getting a 403 error when I try to download pre-trained weights with torchvision 0.5.

torchvision.models.mobilenet_v2(pretrained=True) results in HTTPError: HTTP Error 403: Forbidden. I’ve tried multiple models on multiple machines on multiple networks, always get a 403 error.

I can download the model directly from the URL with wget. But for some reason downloading it through torchvision doesn’t work. I can progress since I can download the weights, but it’s unfortunate I have to load them in manually.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 18
  • Comments: 29 (8 by maintainers)

Most upvoted comments

And now it’s failing with URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)> (again multiple locations, Python 3.6.9)

https://github.com/pytorch/vision/blob/0156d58ec867590b1c78fe1bc834c7da9afdf46a/torchvision/models/resnet.py#L11-L21 A temporary workaround would be to update the model_urls prefixes from https://download.pytorch.org/models/ to https://s3.amazonaws.com/pytorch/models/

As a temporary workaround, you can use http:// instead of https:// to download the model. EDIT: should be fixed now. Can you confirm it works fine now?

Looks like it started working again.

I can confirm. This issue started happening this afternoon. I don’t think it has anything to do with the library but rather with where the models are hosted.

The SSL Certificate issue is fixed now. The Cert was expired for ~4 hours, and we root-caused the auto-renewal problem, it wont happen again.

It’s started failing again now:

Downloading: “https://download.pytorch.org/models/vgg19-dcbb9e9d.pth” to /root/.cache/torch/checkpoints/vgg19-dcbb9e9d.pth

SSLError Traceback (most recent call last) /usr/lib/python3.6/urllib/request.py in do_open(self, http_class, req, **http_conn_args) 1317 h.request(req.get_method(), req.selector, req.data, headers, -> 1318 encode_chunked=req.has_header(‘Transfer-encoding’)) 1319 except OSError as err: # timeout error

20 frames SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)

During handling of the above exception, another exception occurred:

URLError Traceback (most recent call last) /usr/lib/python3.6/urllib/request.py in do_open(self, http_class, req, **http_conn_args) 1318 encode_chunked=req.has_header(‘Transfer-encoding’)) 1319 except OSError as err: # timeout error -> 1320 raise URLError(err) 1321 r = h.getresponse() 1322 except:

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)>

Working again for me as well now.