Torch.hub.load() gives "HTTPError: rate limit exceeded"

D_L: <p>Working through the deep insight example <a>herehttps://github.com/alok-ai-lab/DeepInsight/blob/master/examples/pytorch_squeezenet.ipynb</a>.</p>
<p>However, when trying to load this I get “HTTPError: rate limit exceeded”</p>
<p>I did some searching and couldn’t find a solution. There were some mentions of something similar being due to your location <a href="https://github.com/pytorch/vision/issues/1876" rel="noopener nofollow ugc">here</a>.</p>
<p>Any thoughts?</p>

D_L: <p>FYI - work around is downloading to disk from git and:</p>
<p>torch.hub.load(PATH , ‘squeezenet1_1’, source = ‘local’, pretrained=False, verbose=False)</p>

cloudhan: <p>You can comment this line out to workaround this issue temporarily.</p><aside class="onebox githubblob">
  <header class="source">

      <a href="https://github.com/pytorch/pytorch/blob/80f40b172f4d1491713d6608f2196e59eb04b1b5/torch/hub.py#L162" target="_blank" rel="noopener nofollow ugc">github.com</a>
  </header>

  <article class="onebox-body">
    <h4><a href="https://github.com/pytorch/pytorch/blob/80f40b172f4d1491713d6608f2196e59eb04b1b5/torch/hub.py#L162" target="_blank" rel="noopener nofollow ugc">pytorch/pytorch/blob/80f40b172f4d1491713d6608f2196e59eb04b1b5/torch/hub.py#L162</a></h4>



  <pre class="onebox">    <code class="lang-py">
      <ol class="start lines" start="152" style="counter-reset: li-counter 151 ;">
          <li># To check if cached repo exists, we need to normalize folder names.</li>
          <li>repo_dir = os.path.join(hub_dir, '_'.join([repo_owner, repo_name, normalized_br]))</li>
          <li>
          </li>
<li>use_cache = (not force_reload) and os.path.exists(repo_dir)</li>
          <li>
          </li>
<li>if use_cache:</li>
          <li>    if verbose:</li>
          <li>        sys.stderr.write('Using cache found in {}\n'.format(repo_dir))</li>
          <li>else:</li>
          <li>    # Validate the tag/branch is from the original repo instead of a forked repo</li>
          <li class="selected">    _validate_not_a_forked_repo(repo_owner, repo_name, branch)</li>
          <li>
          </li>
<li>    cached_file = os.path.join(hub_dir, normalized_br + '.zip')</li>
          <li>    _remove_if_exists(cached_file)</li>
          <li>
          </li>
<li>    url = _git_archive_link(repo_owner, repo_name, branch)</li>
          <li>    sys.stderr.write('Downloading: \"{}\" to {}\n'.format(url, cached_file))</li>
          <li>    download_url_to_file(url, cached_file, progress=False)</li>
          <li>
          </li>
<li>    with zipfile.ZipFile(cached_file) as cached_zipfile:</li>
          <li>        extraced_repo_name = cached_zipfile.infolist()[0].filename</li>
      </ol>
    </code>
  </pre>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>


Verner: <p>Hi D_L,</p>
<p>Did you get a solution to this problem?</p>

D_L: <p>I worked around using the solution I posted above. Thanks for following up!</p>

Verner: <p>Hi again,</p>
<p>Thanks for answering. Did you download the code and use it stored on your local machine? That’s it?<br>
Thanks a lot.</p>

Verner: <p>Hi D_L,<br>
Thanks for answer.<br>
I managed to run the model by copying the code from github to Collab. I did this after reading your answer.<br>
It is not a definitive solution, but it serves to continue my research.<br>
Thanks a lot.</p>

durgeshrathod777: <aside class="onebox stackexchange" data-onebox-src="https://stackoverflow.com/questions/68901236/urllib-error-httperror-http-error-403-rate-limit-exceeded-when-loading-resnet1">
  <header class="source">

      <a href="https://stackoverflow.com/questions/68901236/urllib-error-httperror-http-error-403-rate-limit-exceeded-when-loading-resnet1" target="_blank" rel="noopener nofollow ugc">stackoverflow.com</a>
  </header>

  <article class="onebox-body">
      <a href="https://stackoverflow.com/users/2414957/mona-jalal" target="_blank" rel="noopener nofollow ugc">
    <img alt="Mona Jalal" src="https://i.sstatic.net/0MuAW.jpg?s=256" class="thumbnail onebox-avatar" width="" height="">
  </a>

<h4>
  <a href="https://stackoverflow.com/questions/68901236/urllib-error-httperror-http-error-403-rate-limit-exceeded-when-loading-resnet1" target="_blank" rel="noopener nofollow ugc">urllib.error.HTTPError: HTTP Error 403: rate limit exceeded when loading resnet18 from pytorch hub</a>
</h4>

<div class="tags">
  <strong>python, pytorch, torch, http-error</strong>
</div>

<div class="date">
  asked by
  
  <a href="https://stackoverflow.com/users/2414957/mona-jalal" target="_blank" rel="noopener nofollow ugc">
    Mona Jalal
  </a>
  on <a href="https://stackoverflow.com/questions/68901236/urllib-error-httperror-http-error-403-rate-limit-exceeded-when-loading-resnet1" target="_blank" rel="noopener nofollow ugc">02:54AM - 24 Aug 21 UTC</a>
</div>

  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
<p>
Pytorch released a bugfix for 1.9 (i.e. 1.9.1) so updating to 1.9.1 should rectify this issue for good</p>