pytorch / hub

Submission to https://pytorch.org/hub/
1.4k stars 244 forks source link

PyTorch Hub models and dependencies should be versioned #63

Open nlothian opened 5 years ago

nlothian commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

Thanks.

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

ailzhang commented 5 years ago

@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 commented 5 years ago

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(..)