Setup help: "torchvision 0.11.1 requires torch==1.10.0, but you'll have torch 1.7.0 which is incompatible."

I have just setup a Jupyter Notebook with Paperspace Gradient.
However, when trying to run the first cell of the Appendix in ‘app_jupyter.ipynb’ from fastbook/clean folder in a Paperspace instance, I have the following error, and I don’t really understand what’s happening. I also can’t run any subsequent cells that rely on the fast.ai library. Could someone please help?

[31mERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.

We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.

torchvision 0.11.1 requires torch==1.10.0, but you’ll have torch 1.7.0 which is incompatible.[0m

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-2b820b2b946f> in <module>
      1 #hide
      2 get_ipython().system('pip install -Uqq fastbook')
----> 3 import fastbook
      4 fastbook.setup_book()

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastbook/__init__.py in <module>
      1 __version__ = "0.0.18"
      2 import matplotlib as mpl, pkgutil, requests, time
----> 3 from fastai.vision.all import *
      4 from fastdownload import download_url
      5 from pandas.api.types import CategoricalDtype

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/vision/all.py in <module>
----> 1 from . import models
      2 from ..basics import *
      3 from ..callback.all import *
      4 from .augment import *
      5 from .core import *

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/vision/models/__init__.py in <module>
----> 1 from . import xresnet
      2 from . import unet
      3 from .tvm import *

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/vision/models/xresnet.py in <module>
     11 # Cell
     12 from ...torch_basics import *
---> 13 from torchvision.models.utils import load_state_dict_from_url
     14 
     15 # Cell

/opt/conda/envs/fastai/lib/python3.8/site-packages/torchvision/__init__.py in <module>
      4 from .extension import _HAS_OPS
      5 
----> 6 from torchvision import models
      7 from torchvision import datasets
      8 from torchvision import ops

/opt/conda/envs/fastai/lib/python3.8/site-packages/torchvision/models/__init__.py in <module>
      6 from .densenet import *
      7 from .googlenet import *
----> 8 from .mobilenet import *
      9 from .mnasnet import *
     10 from .shufflenetv2 import *

/opt/conda/envs/fastai/lib/python3.8/site-packages/torchvision/models/mobilenet.py in <module>
----> 1 from .mobilenetv2 import MobileNetV2, mobilenet_v2, __all__ as mv2_all
      2 from .mobilenetv3 import MobileNetV3, mobilenet_v3_large, mobilenet_v3_small, __all__ as mv3_all
      3 
      4 __all__ = mv2_all + mv3_all

/opt/conda/envs/fastai/lib/python3.8/site-packages/torchvision/models/mobilenetv2.py in <module>
      6 from torch import Tensor
      7 from .._internally_replaced_utils import load_state_dict_from_url
----> 8 from ..ops.misc import ConvNormActivation
      9 from ._utils import _make_divisible
     10 from typing import Callable, Any, Optional, List

/opt/conda/envs/fastai/lib/python3.8/site-packages/torchvision/ops/__init__.py in <module>
     10 from .feature_pyramid_network import FeaturePyramidNetwork
     11 from .focal_loss import sigmoid_focal_loss
---> 12 from .stochastic_depth import stochastic_depth, StochasticDepth
     13 
     14 from ._register_onnx_ops import _register_custom_op

/opt/conda/envs/fastai/lib/python3.8/site-packages/torchvision/ops/stochastic_depth.py in <module>
      1 import torch
----> 2 import torch.fx
      3 from torch import nn, Tensor
      4 
      5 

ModuleNotFoundError: No module named 'torch.fx'

my guess is paperspace has an incompatible version of torch. you can try this

!pip install -q --upgrade --no-cache-dir torch torchvision torchaudio

before you pip install the fastbook

Thanks for your reply!

I have tried this in the cell:

#hide
!pip install -q --upgrade --no-cache-dir torch torchvision torchaudio
!pip install -Uqq fastbook
import fastbook
fastbook.setup_book()

But I now have this error:

ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.

We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.

torchvision 0.11.1 requires torch==1.10.0, but you’ll have torch 1.9.1 which is incompatible.
torchaudio 0.10.0 requires torch==1.10.0, but you’ll have torch 1.9.1 which is incompatible.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-7b7a7b4dba0e> in <module>
      2 get_ipython().system('pip install -q --upgrade --no-cache-dir torch torchvision torchaudio')
      3 get_ipython().system('pip install -Uqq fastbook')
----> 4 import fastbook
      5 fastbook.setup_book()

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastbook/__init__.py in <module>
      1 __version__ = "0.0.18"
      2 import matplotlib as mpl, pkgutil, requests, time
----> 3 from fastai.vision.all import *
      4 from fastdownload import download_url
      5 from pandas.api.types import CategoricalDtype

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/vision/all.py in <module>
----> 1 from . import models
      2 from ..basics import *
      3 from ..callback.all import *
      4 from .augment import *
      5 from .core import *

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/vision/models/__init__.py in <module>
----> 1 from . import xresnet
      2 from . import unet
      3 from .tvm import *

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/vision/models/xresnet.py in <module>
     11 # Cell
     12 from ...torch_basics import *
---> 13 from torchvision.models.utils import load_state_dict_from_url
     14 
     15 # Cell

ModuleNotFoundError: No module named 'torchvision.models.utils'

I was able to resolve this by running in the terminal:

python -m pip install --upgrade pip

then:

pip install -Uqq fastbook --use-feature=2020-resolver

Found here:
https://stackoverflow.com/questions/63277123/what-is-use-feature-2020-resolver-error-message-with-jupyter-installation-on#

2 Likes

glad you figured it out.

Hey Matthew, I had the same error but after trying both yours and his solution I am left with the following AttributeError.

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-18-2b820b2b946f> in <module>
      1 #hide
      2 get_ipython().system('pip install -Uqq fastbook')
----> 3 import fastbook
      4 fastbook.setup_book()

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastbook/__init__.py in <module>
      1 __version__ = "0.0.18"
      2 import matplotlib as mpl, pkgutil, requests, time
----> 3 from fastai.vision.all import *
      4 from fastdownload import download_url
      5 from pandas.api.types import CategoricalDtype

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/vision/all.py in <module>
----> 1 from . import models
      2 from ..basics import *
      3 from ..callback.all import *
      4 from .augment import *
      5 from .core import *

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/vision/models/__init__.py in <module>
      1 from . import xresnet
      2 from . import unet
----> 3 from .tvm import *

/opt/conda/envs/fastai/lib/python3.8/site-packages/fastai/vision/models/tvm.py in <module>
----> 1 from torchvision.models import ResNet,resnet18,resnet34,resnet50,resnet101,resnet152
      2 from torchvision.models import SqueezeNet,squeezenet1_0,squeezenet1_1
      3 from torchvision.models import densenet121,densenet169,densenet201,densenet161
      4 from torchvision.models import vgg11_bn,vgg13_bn,vgg16_bn,vgg19_bn,alexnet

/opt/conda/envs/fastai/lib/python3.8/site-packages/torchvision/__init__.py in <module>
      4 from .extension import _HAS_OPS
      5 
----> 6 from torchvision import models
      7 from torchvision import datasets
      8 from torchvision import ops

/opt/conda/envs/fastai/lib/python3.8/site-packages/torchvision/models/__init__.py in <module>
      6 from .densenet import *
      7 from .googlenet import *
----> 8 from .mobilenet import *
      9 from .mnasnet import *
     10 from .shufflenetv2 import *

/opt/conda/envs/fastai/lib/python3.8/site-packages/torchvision/models/mobilenet.py in <module>
----> 1 from .mobilenetv2 import MobileNetV2, mobilenet_v2, __all__ as mv2_all
      2 from .mobilenetv3 import MobileNetV3, mobilenet_v3_large, mobilenet_v3_small, __all__ as mv3_all
      3 
      4 __all__ = mv2_all + mv3_all

/opt/conda/envs/fastai/lib/python3.8/site-packages/torchvision/models/mobilenetv2.py in <module>
      6 from torch import Tensor
      7 from .._internally_replaced_utils import load_state_dict_from_url
----> 8 from ..ops.misc import ConvNormActivation
      9 from ._utils import _make_divisible
     10 from typing import Callable, Any, Optional, List

/opt/conda/envs/fastai/lib/python3.8/site-packages/torchvision/ops/__init__.py in <module>
     10 from .feature_pyramid_network import FeaturePyramidNetwork
     11 from .focal_loss import sigmoid_focal_loss
---> 12 from .stochastic_depth import stochastic_depth, StochasticDepth
     13 
     14 from ._register_onnx_ops import _register_custom_op

/opt/conda/envs/fastai/lib/python3.8/site-packages/torchvision/ops/stochastic_depth.py in <module>
      1 import torch
----> 2 import torch.fx
      3 from torch import nn, Tensor
      4 
      5 

/opt/conda/envs/fastai/lib/python3.8/site-packages/torch/fx/__init__.py in <module>
     81 '''
     82 
---> 83 from .graph_module import GraphModule
     84 from ._symbolic_trace import symbolic_trace, Tracer, wrap, PH, ProxyableClassMeta
     85 from .graph import Graph

/opt/conda/envs/fastai/lib/python3.8/site-packages/torch/fx/graph_module.py in <module>
      6 import linecache
      7 from typing import Type, Dict, List, Any, Union, Optional, Set
----> 8 from .graph import Graph, _is_from_torch, _custom_builtins, PythonCode
      9 from ._compatibility import compatibility
     10 from torch.package import Importer, sys_importer

/opt/conda/envs/fastai/lib/python3.8/site-packages/torch/fx/graph.py in <module>
----> 1 from .node import Node, Argument, Target, map_arg, _type_repr, _get_qualified_name
      2 import torch.utils._pytree as pytree
      3 from . import _pytree as fx_pytree
      4 from ._compatibility import compatibility
      5 

/opt/conda/envs/fastai/lib/python3.8/site-packages/torch/fx/node.py in <module>
     26 
     27 _side_effectful_functions: Set[Callable] = {
---> 28     torch._assert, torch.ops.profiler._record_function_enter,
     29     torch.ops.profiler._record_function_exit}
     30 

AttributeError: module 'torch' has no attribute '_assert'

Any idea how I could overcome this error?

are you using paperspace? if you have a colab version with the error you can share, feel free.

also check the torch version. i think it’d be something like this, right after your pip install

import torch
print(torch.__version__)

Yeah I’m using paperspace. I also have colab and the error doesn’t seem to be present. I’d prefer to use paperspace though since I paid $8 for a premium gpu and access to the terminal, plus I enjoy the true Jupyter Notebook.

I just checked the torch version, it’s 1.7.0. Perhaps I must update it?

I just upgraded the package using:

pip install torch --upgrade

It successfully upgraded torch to 1.10. However afterwards, I put a code cell to check the version and it still says 1.7.0. Why is this so? Am I updating it in the wrong place? I’m updating it directly in the Jupyter Notebook, as oppose to in the terminal.

Nevermind, restarted the kernal and followed the steps given in this thread once again. Note for everyone experiencing the same problem. When @harajuku-minas said:

I was able to resolve this by running in the terminal:

python -m pip install --upgrade pip

then:

pip install -Uqq fastbook --use-feature=2020-resolver

Make sure that:

pip install -Uqq fastbook --use-feature=2020-resolver

is ran in the Jupyter Notebook and not in the terminal.

1 Like