question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error after fresh install: Cannot import '_download_url_to_file' from 'torch.utils.model_zoo'

See original GitHub issue

🐛 Bug

To Reproduce

Steps to reproduce the behavior:

  1. Install as per instructions (Ubuntu DSVM)
  2. Attempt to start training

Error

The error is: ImportError: cannot import name '_download_url_to_file' from 'torch.utils.model_zoo'

Additional context

If I am seeing things clearly, torch.utils.model_zoo no longer contains _download_url_to_file.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
Jinksicommented, Apr 16, 2019

@my-hello-world as a temp fix, you make these changes to maskrcnn_benchmark/utils/model_zoo.py

1reaction
metusnpcommented, Apr 20, 2019

Hello, I am still getting the error in docker image. I update file as proposed temporary fix above but same error shows up. It seems somewhat cached code is run. How can i force it to use normal code instead of cached (well, if that is the case) thanks in advance


Error lines in docker container:
root@a213ed43e084:/home/retinamask/maskrcnn-benchmark/demo# python3 
Python 3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 19:16:44) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from predictor import COCODemo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/retinamask/maskrcnn-benchmark/demo/predictor.py", line 7, in <module>
    from maskrcnn_benchmark.utils.checkpoint import DetectronCheckpointer
  File "/maskrcnn-benchmark/maskrcnn_benchmark/utils/checkpoint.py", line 10, in <module>
    from maskrcnn_benchmark.utils.model_zoo import cache_url
  File "/maskrcnn-benchmark/maskrcnn_benchmark/utils/model_zoo.py", line 5, in <module>
    from torch.utils.model_zoo import _download_url_to_file
ImportError: cannot import name '_download_url_to_file'

And the head content of model_zoo.py is as follows ( I commented out torch.utils related lines):

 root@a213ed43e084:/home/retinamask/maskrcnn-benchmark/demo# head -n 20 ../maskrcnn_benchmark/utils/model_zoo.py 
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import os
import sys

try:
    from torch.hub import _download_url_to_file
    from torch.hub import urlparse
    from torch.hub import HASH_REGEX

    
   # from torch.utils.model_zoo import _download_url_to_file
  #  from torch.utils.model_zoo import urlparse
  #  from torch.utils.model_zoo import HASH_REGEX
except:
    from torch.hub import _download_url_to_file
    from torch.hub import urlparse
    from torch.hub import HASH_REGEX

from maskrcnn_benchmark.utils.comm import is_main_process
from maskrcnn_benchmark.utils.comm import synchronize

Read more comments on GitHub >

github_iconTop Results From Across the Web

torch.hub — PyTorch 1.13 documentation
torch.hub. Pytorch Hub is a pre-trained model repository designed to facilitate research reproducibility. Publishing models. Pytorch Hub supports publishing ...
Read more >
Cannot import torch module - python - Stack Overflow
Open command prompt or terminal and type: pip3 install pytorch. If it says pip isn't installed then type: python -m pip install -U...
Read more >
torch.utils.model_zoo — PyTorch master documentation
Source code for torch.utils.model_zoo. from __future__ import absolute_import, division, print_function, unicode_literals import torch import hashlib import ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found