vision: Cannot install any version of torchvision newer than 0.2.2 with opencv for python 3.9 and pytorch 1.9.0
๐ Bug
Issue #3207 has cropped up again for pytorch 1.9.0 Cannot install any version of torchvision newer than 0.2.2 with opencv for python 3.9
To Reproduce
Contents of ~/.condarc
:
channels:
- defaults
- anaconda
- pytorch
- conda-forge
channel_priority: disabled
On the command line:
conda create -n temp python=3.9
conda activate temp
conda install torchvision opencv pytorch=1.9.0
This installs torchvision version 0.2.2.
Replacing the last line with
conda install torchvision=0.10.0 opencv pytorch=1.9.0
produces the error
UnsatisfiableError: The following specifications were found to be incompatible with each other:
Output in format: Requested package -> Available versions
Package bzip2 conflicts for:
opencv -> pypy3.6[version='>=7.3.3'] -> bzip2[version='1.0.*|>=1.0.6,<2.0a0|>=1.0.8,<2.0a0|>=1.0.6,<1.1.0a0']
torchvision==0.10.0=py39_cu111 -> ffmpeg[version='>=4.2'] -> bzip2[version='>=1.0.8,<2.0a0']
Package jpeg conflicts for:
torchvision==0.10.0=py39_cu111 -> jpeg[version='<=9b']
torchvision==0.10.0=py39_cu111 -> pillow[version='>=5.3.0'] -> jpeg[version='>=9b,<10a|>=9d,<10a|>=9c,<10a']
Package libpng conflicts for:
torchvision==0.10.0=py39_cu111 -> libpng
torchvision==0.10.0=py39_cu111 -> ffmpeg[version='>=4.2'] -> libpng[version='>=1.6.37,<1.7.0a0']
Package python_abi conflicts for:
torchvision==0.10.0=py39_cu111 -> python_abi=3.9[build=*_cp39]
torchvision==0.10.0=py39_cu111 -> pillow[version='>=5.3.0'] -> python_abi[version='3.6|3.6.*|3.7|3.7.*|3.8.*',build='*_cp38|*_pypy36_pp73|*_pypy37_pp73|*_cp36m|*_cp37m']
Package python conflicts for:
torchvision==0.10.0=py39_cu111 -> python[version='>=3.9,<3.10.0a0']
opencv -> py-opencv==4.5.2=py39hef51801_0 -> python[version='3.7.*|3.9.*|>=3.9,<3.10.0a0|>=3.8,<3.9.0a0|3.8.*']
opencv -> python[version='2.7.*|3.5.*|3.6.*|>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.5,<3.6.0a0|3.4.*']
torchvision==0.10.0=py39_cu111 -> pillow[version='>=5.3.0'] -> python[version='3.9.*|>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.8,<3.9.0a0|>=3.5,<3.6.0a0']
python=3.9
Package _libgcc_mutex conflicts for:
opencv -> libgcc-ng[version='>=7.3.0'] -> _libgcc_mutex[version='*|0.1|0.1',build='main|conda_forge']
python=3.9 -> libgcc-ng[version='>=7.5.0'] -> _libgcc_mutex[version='*|0.1|0.1',build='main|conda_forge']
Package tzdata conflicts for:
torchvision==0.10.0=py39_cu111 -> python[version='>=3.9,<3.10.0a0'] -> tzdata
python=3.9 -> tzdataThe following specifications were found to be incompatible with your system:
- feature:/linux-64::__glibc==2.33=0
- torchvision==0.10.0=py39_cu111 -> cudatoolkit[version='>=11.1,<11.2'] -> __glibc[version='>=2.17,<3.0.a0']
Your installed version is: 2.33
Expected behavior
Torchvision version 0.10.0 should be selected for installation. If version is explicitly specified, packages should get installed without error.
Environment
OS: Ubuntu 20.10 (x86_64) GCC version: (Ubuntu 10.2.0-13ubuntu1) 10.2.0 Clang version: 11.0.0-2 CMake version: version 3.16.3 Python version: 3.9 (64-bit runtime) GPU models and configuration: GPU 0: GeForce 930MX Nvidia driver version: 460.80
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 13
- Comments: 25 (7 by maintainers)
The latest
torchvision=0.10
requiresffmpeg>=4.2
such that onlyopencv>=4.2
is eligible and available fromconda-forge
. However,opencv>=4.2
requiresjpge>=9d
in conflict withjpeg<=9b
required bytorchvision=0.10
. Whytorchvision=0.2.2
is picked is because of loose requirements ofpython3
,pytorch
,jpeg
versions.This issue is not done yet for the side effect of pinning the jpeg version:
Looking into
libjpeg
, there are indeed API changes from9c
to9d
regardingjpeg_mem_dest(...)
. For example, platform dependentsize_t
replacesunsigned long
in an internal structure typemy_mem_dest_ptr
. Bothpillow
andopencv
eventually opt for pinningjpeg>=9d
since some versions (8.0.1 and 4.3 respectively) and adapt to this potential breaking change. It would be odd iftorchvision
choose NOT to align with those recent dependent packages.Besides, there are other potentially critical concerns about pinning
jpeg<=9b
:Therefore, the solution is likely for
torchvision
to adapt tojpeg>=9d
. Then the question is what prevents to do so.On the other hand, there are other complexities and implications due to the dependencies possibly inconsistent across platforms and channels:
Since most dependencies would require
conda-forge
to provide the necessary packages, a careful consideration to includeconda-forge
seems quite essential.Workaround
If
torchvision
may not supportjpeg>=9d
soon, the other way around is to use the non-official opencv build that is statically linked to its dependencies (libjpeg
,ffmpeg
, and etc.) and available asopencv-python
oropencv-python-headless
.For information, you can get unblocked by doing
if you are working with conda.
we will be fixing the issue soon.
Thanks for the report, weโre working on it.
It doesnโt seem to be related to opencv though, or at least it also happens without opencv on conda: https://github.com/pytorch/vision/issues/4071#issuecomment-862238275