facebookresearch / fairseq

Facebook AI Research Sequence-to-Sequence Toolkit written in Python.
MIT License
30.31k stars 6.39k forks source link

HTTPError: HTTP Error 404: Not Found for torch.hub.load('pytorch/fairseq', 'transformer_lm.wmt20.en') #4047

Open AdaUchendu opened 2 years ago

AdaUchendu commented 2 years ago

πŸ› Bug

After downloading the appropriate packages, I run torch.hub.load('pytorch/fairseq', 'transformer_lm.wmt20.en') to download the model but I seem to always get the HTTP 404 Error. I have also successfully loaded this model in the past (early this year), however, without changing any of the code, I get the following error. Also, I use Google colab so I always download the lastest version of the repo.

To Reproduce

Steps to reproduce the behavior (always include the command you ran):

  1. Run cmd '....'
  2. See error

/usr/local/lib/python3.7/dist-packages/torch/hub.py in load(repo_or_dir, model, *args, *kwargs) 335 336 if source == 'github': --> 337 repo_or_dir = _get_cache_or_reload(repo_or_dir, force_reload, verbose) 338 339 model = _load_local(repo_or_dir, model, args, **kwargs)

/usr/local/lib/python3.7/dist-packages/torch/hub.py in _get_cache_or_reload(github, force_reload, verbose) 142 url = _git_archive_link(repo_owner, repo_name, branch) 143 sys.stderr.write('Downloading: \"{}\" to {}\n'.format(url, cached_file)) --> 144 download_url_to_file(url, cached_file, progress=False) 145 146 with zipfile.ZipFile(cached_file) as cached_zipfile:

/usr/local/lib/python3.7/dist-packages/torch/hub.py in download_url_to_file(url, dst, hash_prefix, progress) 392 # certificates in older Python 393 req = Request(url, headers={"User-Agent": "torch.hub"}) --> 394 u = urlopen(req) 395 meta = u.info() 396 if hasattr(meta, 'getheaders'):

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

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

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

/usr/lib/python3.7/urllib/request.py in error(self, proto, args) 561 http_err = 0 562 args = (dict, proto, meth_name) + args --> 563 result = self._call_chain(args) 564 if result: 565 return result

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

/usr/lib/python3.7/urllib/request.py in http_error_302(self, req, fp, code, msg, headers) 753 fp.close() 754 --> 755 return self.parent.open(new, timeout=req.timeout) 756 757 http_error_301 = http_error_303 = http_error_307 = http_error_302

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

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

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

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

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

HTTPError: HTTP Error 404: Not Found

Code sample

import torch en_lm = torch.hub.load('pytorch/fairseq', 'transformer_lm.wmt20.en')

Expected behavior

No Error

Environment

Additional context

liujiemnm commented 2 years ago

please quickly!!!

Anwarvic commented 2 years ago

I think this will fix your issue:

https://stackoverflow.com/questions/69349308/torch-hub-load-raises-httperror-http-error-404-not-found-when-loading-model/69349309#69349309