question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot install any version of torchvision newer than 0.2.2 with opencv for python 3.9 and pytorch 1.9.0

See original GitHub issue

🐛 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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:12
  • Comments:24 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
farleylaicommented, Jul 22, 2021

The latest torchvision=0.10 requires ffmpeg>=4.2 such that only opencv>=4.2 is eligible and available from conda-forge. However, opencv>=4.2 requires jpge>=9d in conflict with jpeg<=9b required by torchvision=0.10. Why torchvision=0.2.2 is picked is because of loose requirements of python3, 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 from 9c to 9d regarding jpeg_mem_dest(...). For example, platform dependent size_t replaces unsigned long in an internal structure type my_mem_dest_ptr. Both pillow and opencv eventually opt for pinning jpeg>=9d since some versions (8.0.1 and 4.3 respectively) and adapt to this potential breaking change. It would be odd if torchvision 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 to jpeg>=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:

  • Different conda channels may specify different dependencies for a particular pkg version even on the same platform
  • Worse, some up to update dependencies are only available in some non-default channels, implying channel dependencies

Since most dependencies would require conda-forge to provide the necessary packages, a careful consideration to include conda-forge seems quite essential.

Workaround

If torchvision may not support jpeg>=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 as opencv-python or opencv-python-headless.

4reactions
NicolasHugcommented, Jun 17, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Install pytorch 1.9.0 with unexpected problem
I follow the official guide to install pytorch 1.9.0 + cuda11.3 ... after installment finished, it seems cpu version is installed,not GPU.
Read more >
Can't install pytorch with pip on Windows - Stack Overflow
The most likely reason for Your issue is a 32-bit installation of python, while the torch libraries rely on having a 64-bit version....
Read more >
EasyBuild v4.6.2 documentation (release 20221021.0)
The latest version of EasyBuild provides support for building and installing 2,798 different software packages, including 37 different (compiler) toolchains ...
Read more >
PyTorch for Jetson - NVIDIA Developer Forums
Download one of the PyTorch binaries from below for your version of JetPack, and see the installation instructions to run on your Jetson....
Read more >
no module named 'typing_extensions' pytorch - You.com
There must be an import from typing-extensions module in blog\views.py ... You might have more than one python versions installed on your system...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found