Loading pretrained resnet on Google Colab fails with Http 403: Forbidden

Hi All

I am very new to deep learning and pytorch. i am trying to lead the resnet34 model and it fails with 403 forbidden error. I am using Google Colab as the environment for notebooks.

resnet = torchvision.models.resnet34(pretrained=True)

Downloading: "https://download.pytorch.org/models/resnet34-333f7ec4.pth" to /root/.cache/torch/checkpoints/resnet34-333f7ec4.pth
HTTPError                                 Traceback (most recent call last)
<ipython-input-16-9b84e690c25c> in <module>()
      1 get_ipython().system('rm -rf /root/.cache/torch')
----> 2 resnet = torchvision.models.resnet34(pretrained=True)

9 frames
/usr/local/lib/python3.6/dist-packages/torchvision/models/resnet.py in resnet34(pretrained, progress, **kwargs)
    247     """
    248     return _resnet('resnet34', BasicBlock, [3, 4, 6, 3], pretrained, progress,
--> 249                    **kwargs)

/usr/local/lib/python3.6/dist-packages/torchvision/models/resnet.py in _resnet(arch, block, layers, pretrained, progress, **kwargs)
    221     if pretrained:
    222         state_dict = load_state_dict_from_url(model_urls[arch],
--> 223                                               progress=progress)
    224         model.load_state_dict(state_dict)
    225     return model

/usr/local/lib/python3.6/dist-packages/torch/hub.py in load_state_dict_from_url(url, model_dir, map_location, progress, check_hash)
    490         sys.stderr.write('Downloading: "{}" to {}\n'.format(url, cached_file))
    491         hash_prefix = HASH_REGEX.search(filename).group(1) if check_hash else None
--> 492         download_url_to_file(url, cached_file, hash_prefix, progress=progress)
    494     # Note: extractall() defaults to overwrite file if exists. No need to clean up beforehand.

/usr/local/lib/python3.6/dist-packages/torch/hub.py in download_url_to_file(url, dst, hash_prefix, progress)
    389     # We use a different API for python2 since urllib(2) doesn't recognize the CA
    390     # certificates in older Python
--> 391     u = urlopen(url)
    392     meta = u.info()
    393     if hasattr(meta, 'getheaders'):

/usr/lib/python3.6/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    221     else:
    222         opener = _opener
--> 223     return opener.open(url, data, timeout)
    225 def install_opener(opener):

/usr/lib/python3.6/urllib/request.py in open(self, fullurl, data, timeout)
    530         for processor in self.process_response.get(protocol, []):
    531             meth = getattr(processor, meth_name)
--> 532             response = meth(req, response)
    534         return response

/usr/lib/python3.6/urllib/request.py in http_response(self, request, response)
    640         if not (200 <= code < 300):
    641             response = self.parent.error(
--> 642                 'http', request, response, code, msg, hdrs)
    644         return response

/usr/lib/python3.6/urllib/request.py in error(self, proto, *args)
    568         if http_err:
    569             args = (dict, 'default', 'http_error_default') + orig_args
--> 570             return self._call_chain(*args)
    572 # XXX probably also want an abstract factory that knows when it makes

/usr/lib/python3.6/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
    502         for handler in handlers:
    503             func = getattr(handler, meth_name)
--> 504             result = func(*args)
    505             if result is not None:
    506                 return result

/usr/lib/python3.6/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
    648 class HTTPDefaultErrorHandler(BaseHandler):
    649     def http_error_default(self, req, fp, code, msg, hdrs):
--> 650         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    652 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 403: Forbidden

There were some DNS issues. It should be fixed now. Are you still having this problem?

Yes. Just tried and it failed again with same error.

Still having issues as well!

When will it be fixed?

Just to chime in. Still seeing this issue from my own laptop in Japan, Colab and Google Cloud Instances

This seems to be CloudFlare doing terrible things – for no reason whatsoever with it’s β€œprotection and caching layer”.

I’ve switched it off for now, and in ~4 hours or so, all requests should be direct again.

I’ll keep tabs on this thread to hear back if things are fixed.

Sorry about this whole mess.

1 Like

Oh I though my network is down… β€œhappy” to see lots of people have the same issue… :sneezing_face:, hope we can download model again soon…

Thanks @smth! Things seem to be back to normal for me :slight_smile:

Hey I had the same problem yesterday, however today did I get a new error while downloading a pretrained model from pytorch in google colab
(URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)>)

Do anybody know how to fix it or when there will be a fix available?

Thanks for letting us know.
It’s most likely related to this issue and we are looking into it.

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.

1 Like

Still facing the same issue!

Can we have some permanent solution for this?

Could you recheck it please, as it’s working now on my system:

>>> model = models.resnet34(pretrained=True)
Downloading: "https://download.pytorch.org/models/resnet34-333f7ec4.pth" to /root/.cache/torch/checkpoints/resnet34-333f7ec4.pth
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 83.3M/83.3M [00:03<00:00, 27.7MB/s]

Yes it worked. Still not sure but at that point of time i tried multiple times but it was not working and keep on failing. Thank you ptrblck.

Good to hear it’s working now. Please let us know, if you see such issues again. :slight_smile:

Unfortunately, this seems to be an issue again. For me, this happens when I try to download MNIST:

train_dataset = datasets.MNIST(root='data', 

Tried on both macOS and Ubuntu. I am wondering if this is due to some redirect because visiting the lecun’s mnist website and then downloading it manually works.

1 Like

Thanks for notifying us. I can reproduce it and we’ll look into it.

PS: Do you see other datasets failing as well or just MNIST?
So far I can just reproduce it for MNIST.

Thanks for reporting @rasbt, we are tracking this issue in https://github.com/pytorch/vision/issues/1938

Still don’t know what the root cause is.

this is a general issue with the download site of MNIST, i.e. yann.lecun.com. It has implemented CloudFlare protection.
I’ll ask the hosts what is going on.