Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

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

Closed
Jinksi opened this issue Apr 15, 2019 · 7 comments

Comments

@Jinksi
Copy link

Jinksi commented Apr 15, 2019

馃悰 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.

@Jinksi
Copy link
Author

Jinksi commented Apr 15, 2019

PR already in:
#673

@my-hello-world
Copy link

how fix it? please

@Jinksi
Copy link
Author

Jinksi commented Apr 16, 2019

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

@my-hello-world
Copy link

thx! i got it 馃槂@Jinksi

@fmassa
Copy link
Contributor

fmassa commented Apr 20, 2019

Fixed via #698

@fmassa fmassa closed this as completed Apr 20, 2019
@metusnp
Copy link

metusnp commented 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

@smrfeld
Copy link

smrfeld commented Sep 6, 2022

This came up again, I am on version 1.13.0.dev20220905 - now _download_url_to_file is download_url_to_file and the correct import path is torch.hub, i.e. from torch.hub import download_url_to_file.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants