Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Torch Hub download fails due to Torchvision dependency? #5813

Open
jmwolf82 opened this issue Apr 13, 2022 · 7 comments
Open

Torch Hub download fails due to Torchvision dependency? #5813

jmwolf82 opened this issue Apr 13, 2022 · 7 comments

Comments

@jmwolf82
Copy link

jmwolf82 commented Apr 13, 2022

🐛 Describe the bug

Running the following code returns the error seen below. It seems like there is some type of dependency or call to torchvision. Torchvision, however, doesn't list the new efficientnet models.

Screenshot 2022-04-13 004546

import torch
from torch import hub
#import torchvision.models as models

resnet18_model = torch.hub.load('pytorch/vision:main',
                         'resnet18',
                         pretrained = True)

Screenshot 2022-04-13 004413

It seems like there is something missing. I have cleared my .cache folder, and even updated the efficientnet.py code on my local machine to match the latest. Still receiving this Import Error. I am running the following versions:

Screenshot 2022-04-13 004800

Even if I do a simple:

torch.hub.list('pytorch/vision')

I receive the following error:

Screenshot 2022-04-13 004900

Versions

Screenshot 2022-04-13 005622

@pmeier
Copy link
Collaborator

pmeier commented Apr 13, 2022

I cannot reproduce. The only difference in my env is that I'm not on Windows.

My guess to what is happening: torch.hub commands add the downloaded repository to the Python path and afterwards import the package. Somehow this goes wrong and actually the version installed in your environment is loaded. The error then happens, because the hubconf.py from main contains entries

vision/hubconf.py

Lines 15 to 19 in 467b841

efficientnet_b7,
efficientnet_v2_s,
efficientnet_v2_m,
efficientnet_v2_l,
)

that are not present in 0.12.0

vision/hubconf.py

Lines 15 to 16 in 9b5a3fe

efficientnet_b7,
)

Let's wait for @NicolasHug who knows torch.hub better than I do.

@jmwolf82
Copy link
Author

@pmeier what OS are you using?

@pmeier
Copy link
Collaborator

pmeier commented Apr 13, 2022

Linux

@NicolasHug
Copy link
Member

NicolasHug commented Apr 14, 2022

@jmwolf82 Could you try loading from 0.12.0 instead?

resnet18_model = torch.hub.load('pytorch/vision:v0.12.0',
                         'resnet18',
                         pretrained = True)

Note that since torchvision is already installed on your machine, you don't really need to use torchhub, you could just import resnet18 from torchvision.models directly.

@jmwolf82
Copy link
Author

@NicolasHug that worked when I specifically referenced the branch in the command, I was able to use torch hub. It is interesting that I do not have the same issue on my Linux VM. Thanks for your help.

Screenshot 2022-04-14 080838

@pmeier
Copy link
Collaborator

pmeier commented Apr 14, 2022

It is interesting that I do not have the same issue on my Linux VM.

So torch.hub is indeed broken on Windows? We should look into that.

@NicolasHug
Copy link
Member

NicolasHug commented Apr 18, 2022

I would suspect this is due to a different environment rather than a platform issue. But yeah I'm getting some other torchhub errors myself, something bad is going on. I can't do much about it right now because the torchhub repo's CI is failing for random reasons.

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

No branches or pull requests

3 participants