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

PyTorch Hub models and dependencies should be versioned #63

Open
nlothian opened this issue Nov 4, 2019 · 4 comments
Open

PyTorch Hub models and dependencies should be versioned #63

nlothian opened this issue Nov 4, 2019 · 4 comments

Comments

@nlothian
Copy link

nlothian commented Nov 4, 2019

We are using the PyTorch deeplabv3_resnet101 model on AWS (on pytorch 1.1), and it suddenly stopped working.

It appears that a recent upgrade to torchvision/inception (!) broke this model:

Downloading: "https://github.com/pytorch/vision/archive/master.zip" to /home/ec2-user/.cache/torch/hub/master.zip

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-8-00653a6a902b> in <module>()
      4     'pytorch/vision',
      5     'deeplabv3_resnet101',
----> 6     pretrained=True)
      7 model_deeplab.eval()
      8 

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/hub.py in load(github, model, *args, **kwargs)
    334     sys.path.insert(0, repo_dir)
    335 
--> 336     hub_module = import_module(MODULE_HUBCONF, repo_dir + '/' + MODULE_HUBCONF)
    337 
    338     entry = _load_entry_from_hubconf(hub_module, model)

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/hub.py in import_module(name, path)
     68         spec = importlib.util.spec_from_file_location(name, path)
     69         module = importlib.util.module_from_spec(spec)
---> 70         spec.loader.exec_module(module)
     71         return module
     72     elif sys.version_info >= (3, 0):

~/anaconda3/envs/pytorch_p36/lib/python3.6/importlib/_bootstrap_external.py in exec_module(self, module)

~/anaconda3/envs/pytorch_p36/lib/python3.6/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

~/.cache/torch/hub/pytorch_vision_master/hubconf.py in <module>()
      3 
      4 from torchvision.models.alexnet import alexnet
----> 5 from torchvision.models.densenet import densenet121, densenet169, densenet201, densenet161
      6 from torchvision.models.inception import inception_v3
      7 from torchvision.models.resnet import resnet18, resnet34, resnet50, resnet101, resnet152,\

~/.cache/torch/hub/pytorch_vision_master/torchvision/__init__.py in <module>()
      1 import warnings
      2 
----> 3 from torchvision import models
      4 from torchvision import datasets
      5 from torchvision import ops

~/.cache/torch/hub/pytorch_vision_master/torchvision/models/__init__.py in <module>()
      3 from .vgg import *
      4 from .squeezenet import *
----> 5 from .inception import *
      6 from .densenet import *
      7 from .googlenet import *

~/.cache/torch/hub/pytorch_vision_master/torchvision/models/inception.py in <module>()
      6 import torch.nn as nn
      7 import torch.nn.functional as F
----> 8 from torch.jit.annotations import Optional
      9 from torch import Tensor
     10 from .utils import load_state_dict_from_url

ImportError: cannot import name 'Optional'

Is there a way to avoid this?

@ailzhang
Copy link
Contributor

ailzhang commented Nov 4, 2019

@nlothian Hub provides a way to pin to a specific release branch by hub.load('pytorch/vision:v0.4.0') so that it works with older version of Pytorch.

We're planning to add some version information on the website, our CI will be testing against latest stable releases(torch/torchvision).

@nlothian
Copy link
Author

nlothian commented Nov 4, 2019

Thanks.

Is there a way to know what version I should pin against? And is that dependency transitive somehow?

@ailzhang
Copy link
Contributor

ailzhang commented Nov 4, 2019

@nlothian It's not documented I think. Try 0.4.0 or 0.3.0? cc: @fmassa @soumith It might be worth documenting on pytorch/vision which version of pytorch it is compatible.

We definitely recommend upgrading to latest pytorch release if possible.

@nlothian
Copy link
Author

nlothian commented Nov 4, 2019

Unfortunately the latest Pytorch release doesn't stay static (you all keep on working on things!!), and we'd love not to have to keep debugging these types of version issues everytime our pipeline breaks.

We're fine to upgrade to latest now, but we don't like having to keep doing it whenever we bring up a new instance that does a hub.load(..)

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

No branches or pull requests

2 participants