vision: Torchvision 0.6.0 doesn't work on Ubuntu 16.04.3 with Python 3.5.2
🐛 Bug
To Reproduce
Steps to reproduce the behavior:
Create a virtual environment
python -m venv venv
Activate the virtual environment
pip install torchvision
Run the following line:
import torchvision
Python 3.5.2 (default, Apr 16 2020, 17:47:17)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torchvision/__init__.py", line 3, in <module>
from torchvision import models
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torchvision/models/__init__.py", line 12, in <module>
from . import detection
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torchvision/models/detection/__init__.py", line 1, in <module>
from .faster_rcnn import *
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torchvision/models/detection/faster_rcnn.py", line 14, in <module>
from .roi_heads import RoIHeads
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torchvision/models/detection/roi_heads.py", line 210, in <module>
@torch.jit.script
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torch/jit/__init__.py", line 1290, in script
fn = torch._C._jit_script_compile(qualified_name, ast, _rcb, get_default_args(obj))
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torch/jit/_recursive.py", line 568, in try_compile_fn
return torch.jit.script(fn, _rcb=rcb)
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torch/jit/__init__.py", line 1290, in script
fn = torch._C._jit_script_compile(qualified_name, ast, _rcb, get_default_args(obj))
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torch/jit/__init__.py", line 2030, in _get_overloads
compiled_fns.append(_compile_function_with_overload(overload_fn, qual_name, obj))
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torch/jit/__init__.py", line 2010, in _compile_function_with_overload
overload_signature = torch.jit.annotations.get_signature(overload_fn, None, None, inspect.ismethod(overload_fn))
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torch/jit/annotations.py", line 79, in get_signature
signature = parse_type_line(type_line, rcb, loc)
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torch/jit/annotations.py", line 165, in parse_type_line
arg_types = [ann_to_type(ann, loc) for ann in arg_ann]
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torch/jit/annotations.py", line 165, in <listcomp>
arg_types = [ann_to_type(ann, loc) for ann in arg_ann]
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torch/jit/annotations.py", line 303, in ann_to_type
the_type = try_ann_to_type(ann, loc)
File "/var/www/rabbit.goodtrees.com/env/lib/python3.5/site-packages/torch/jit/annotations.py", line 296, in try_ann_to_type
the_type = torch._C._resolve_type_from_object(ann, loc, fake_rcb)
TypeError: _resolve_type_from_object(): incompatible function arguments. The following argument types are supported:
1. (arg0: object, arg1: torch._C._jit_tree_views.SourceRange, arg2: Callable[[str], function]) -> torch._C.Type
Invoked with: typing.Union[int, NoneType], None, <function try_ann_to_type.<locals>.fake_rcb at 0x7f566909fd90>
>>>
Expected behavior
Expected it to import successfully
Environment
Please copy and paste the output from our environment collection script (or fill out the checklist below manually).
You can get the script and run it with:
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
Collecting environment information… PyTorch version: 1.5.0 Is debug build: No CUDA used to build PyTorch: 10.2
OS: Ubuntu 16.04.3 LTS GCC version: (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609 CMake version: Could not collect
Python version: 3.5 Is CUDA available: No CUDA runtime version: No CUDA GPU models and configuration: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA
Versions of relevant libraries: [pip3] numpy==1.18.3 [pip3] torch==1.5.0 [pip3] torchvision==0.6.0 [conda] Could not collect
Additional context
I tried it with pip install torchvision==0.5
and it worked.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 20 (7 by maintainers)
Commits related to this issue
- Problem with Python 3.5 and PyTorch 1.5 (impacts Ubuntu base for image). See https://github.com/pytorch/vision/issues/2132 — committed to gnperdue/singularity_imgs by gnperdue 4 years ago
Downgrading to 1.4 works
python3 -m pip install torch==1.4.0+cu92 torchvision==0.5.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html
FYI this issue should have been fixed in torchvision 0.7.0
I was facing the same issue so i downgraded the torch version to 0.5 and it worked.