Skip to content

old version is installed for arm64 based conda #5374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kadereub opened this issue Feb 4, 2022 · 5 comments
Open

old version is installed for arm64 based conda #5374

kadereub opened this issue Feb 4, 2022 · 5 comments

Comments

@kadereub
Copy link

kadereub commented Feb 4, 2022

🐛 Describe the bug

I installed miniforge for apple silicon with the following specs:

          conda version : 4.11.0
    conda-build version : not installed
         python version : 3.9.7.final.0
               platform : osx-arm64

I then created a conda environment and then install pytorch and torchvision,

conda create --name pytorch_env python=3.9
conda activate pytorch_env
conda install -c pytorch pytorch torchvision

When trying to run this main.py script I get the following error:

from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION 
ImportError: cannot import name 'PILLOW_VERSION' from 'PIL

Looking at the torchvision package version it installed a very old version in-spite of the new pillow and pytorch versions installed

pillow                    9.0.0            py39hcb29f89_0    conda-forge
python                    3.9.10          h38ef502_2_cpython    conda-forge
pytorch                   1.10.1          cpu_py39hbfdb42d_0    conda-forge
torchvision               0.2.2                      py_3    pytorch

After installing the right version as advised on the readme it all worked fine!

conda install torchvision==0.11.2 -c pytorch

But seems the requirements / package dependencies are not aligned as an old version 0.2.2 was installed with new pytorch and pillow versions.

I also did not have this problem when I installed the Intel based miniforge

(more details here)

Versions

conda setup:

          conda version : 4.11.0
    conda-build version : not installed
         python version : 3.9.7.final.0
               platform : osx-arm64

pytorch and python:

pillow                    9.0.0            py39hcb29f89_0    conda-forge
python                    3.9.10          h38ef502_2_cpython    conda-forge
pytorch                   1.10.1          cpu_py39hbfdb42d_0    conda-forge
torchvision               0.2.2                      py_3    pytorch
@JH-LEE-KR
Copy link

conda install torchvision==0.11.2 -c pytorch

When I tried to install torchvision through the command above,
I also had the same issue with the old version (0.2.2) being installed.

I don’t know why the old version is installed, but I was able to solve it simply through the conda package update.

conda activate torch38arm
conda update --all

After update the all conda package through the above commands, I was able to get the correct version of torchvision.

pillow                    9.0.1            py38he7148d4_0    conda-forge
python                    3.8.12          hd949e87_3_cpython    conda-forge
pytorch                   1.10.2          cpu_py38h7444d52_0    conda-forge
torchvision               0.11.2          cpu_py38h700cb6d_2    conda-forge

Additionally, it was confirmed that it works well in python through the command below from terminal.

$ python -c "import torchvision; print(torchvision.__version__)"

@pmeier
Copy link
Collaborator

pmeier commented Feb 7, 2022

The reason it installs this really old version, is that 0.2.2 was the last pure Python version and thus works on every architecture. Since the installation works fine for torch it seems there is something off on our side. cc @malfet

@ayushnoori
Copy link

ayushnoori commented Feb 5, 2023

Hi there, I believe I encountered this same issue while attempting to install torchvision for arm64 on a MacBook Pro with Apple M1 Max chip. My Python version was originally 3.11.0. When attempting to load torchvision, I received the same error:

ImportError: cannot import name 'PILLOW_VERSION' from 'PIL'

After downgrading to Python 3.10.9, I reinstalled torchvision via:

conda install torchvision==0.14.0 -c pytorch

The following output indicated that torchvision-0.2.2 was originally installed.

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    torchvision-0.14.0         |cpu_py310h7df52bc_1         5.9 MB  conda-forge
    ------------------------------------------------------------
                                           Total:         5.9 MB

The following packages will be UPDATED:

  torchvision        pytorch/noarch::torchvision-0.2.2-py_3 --> conda-forge/osx-arm64::torchvision-0.14.0-cpu_py310h7df52bc_1 

Now, when I try to import torchvision, I receive the following warning, where {USER_NAME} is my user name and {ENV} is the name of my Conda environment:

Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.10/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: dlopen(/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.10/site-packages/torchvision/image.so, 0x0006): Library not loaded: @rpath/libjpeg.8.dylib
  Referenced from: <09887E54-388B-3C40-B0D7-3895E5F60FF1> /Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.10/site-packages/torchvision/image.so
  Reason: tried: '/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.10/site-packages/torchvision/../../../libjpeg.8.dylib' (no such file), '/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.10/site-packages/torchvision/../../../libjpeg.8.dylib' (no such file), '/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.10/lib-dynload/../../libjpeg.8.dylib' (no such file), '/Users/{USER_NAME}/miniforge3/envs/{ENV}/bin/../lib/libjpeg.8.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS@rpath/libjpeg.8.dylib' (no such file), '/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.10/site-packages/torchvision/../../../libjpeg.8.dylib' (no such file), '/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.10/site-packages/torchvision/../../../libjpeg.8.dylib' (no such file), '/Users/{USER_NAME}/miniforge3/envs/{ENV}/lib/python3.10/lib-dynload/../../libjpeg.8.dylib' (no such file), '/Users/{USER_NAME}/miniforge3/envs/{ENV}/bin/../lib/libjpeg.8.dylib' (no such file), '/usr/local/lib/libjpeg.8.dylib' (no such file), '/usr/lib/libjpeg.8.dylib' (no such file, not in dyld cache)
  warn(f"Failed to load image Python extension: {e}")

See relevant discussion on the forums here. Would be grateful for any assistance here. Thanks!

Edit: Looks like this latter message is an unrelated issue with 0.14.0, see #7151. Am still curious about the original import error, though.

@pmeier
Copy link
Collaborator

pmeier commented Feb 6, 2023

@ayushnoori

We currently don't have any binaries for Python 3.11. See #7049. Meaning, if you require that, conda will pull torchvision==0.2.2, because that is the only one marked as compatible. However, this release is over 5 years old and not compatible with current Pillow versions. I guess the dependency was unpinned and thus the setup pulled in a reasonable new Pillow version, which ultimately leads to the error you saw.

This is why the behavior goes away if you depend on Python 3.10. Now conda actually pulls in a recent torchvision build, which is also compatible to recent Pillow versions.

@ayushnoori
Copy link

Ah, makes sense. Thanks, @pmeier!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants