Skip to content

MacOS 11_0 ARM wheel is missing image.so #5137

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

Closed
borchero opened this issue Dec 29, 2021 · 11 comments
Closed

MacOS 11_0 ARM wheel is missing image.so #5137

borchero opened this issue Dec 29, 2021 · 11 comments

Comments

@borchero
Copy link

🐛 Describe the bug

The MacOS 11_0 ARM wheel for release 0.11.2 does not provide the image.so shared library (this applies to both Python 3.8 and Python 3.9).

Thus, when importing torchvision on an Apple Silicon Mac running macOS Monterey, the following warning is raised:

UserWarning: Failed to load image Python extension:

Versions

PyTorch version: 1.10.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 12.1 (arm64)
GCC version: Could not collect
Clang version: 13.0.0 (clang-1300.0.29.30)
CMake version: Could not collect
Libc version: N/A

Python version: 3.9.9 (main, Dec 29 2021, 16:03:39)  [Clang 13.0.0 (clang-1300.0.29.30)] (64-bit runtime)
Python platform: macOS-12.1-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.21.5
[pip3] pytorch-lightning==1.5.7
[pip3] torch==1.10.1
[pip3] torchmetrics==0.6.2
[pip3] torchvision==0.11.2
[conda] Could not collect
@NicolasHug
Copy link
Member

Thanks for the report @borchero . Our of curiosity do you know if 0.11.1 was working properly on M1?

Perhaps this is something that @malfet can help with?

@zhiqwang
Copy link
Contributor

Seems that there is no torchvision 0.11.1 wheel released on macOS M1.

@brifordwylie
Copy link

Anyone know a workaround for this? I tried downgrading versions and didn't have any luck

@malfet
Copy link
Contributor

malfet commented Jan 27, 2022

Should be solved by 0.11.3 release, see https://pypi.org/project/torchvision/

@malfet malfet closed this as completed Jan 27, 2022
@alanyoungCN
Copy link

alanyoungCN commented Feb 12, 2022

The warning seems to be still there. When I use pip to install torch=1.10.2, torchvision=0.11.3, the import statement

import torchvision

throws out the similar warning:

/Users/alanyoung/Documents/Codes/Kaggle/ClassifyLeaves/venv/lib/python3.9/site-packages/torchvision/io/image.py:11: UserWarning: Failed to load image Python extension: dlopen(/Users/alanyoung/Documents/Codes/Kaggle/ClassifyLeaves/venv/lib/python3.9/site-packages/torchvision/image.so, 0x0006): Library not loaded: @rpath/libpng16.16.dylib
  Referenced from: /Users/alanyoung/Documents/Codes/Kaggle/ClassifyLeaves/venv/lib/python3.9/site-packages/torchvision/image.so
  Reason: tried: ......
  warn(f"Failed to load image Python extension: {e}")

I use MacBook Pro with M1 Max and there is not a image.so in torchvision directory.🤔
I notice that it has been talked in https://discuss.pytorch.org/t/failed-to-load-image-python-extension-could-not-find-module/140278/21 by Andrade.
@malfet Could you please check this?

@malfet
Copy link
Contributor

malfet commented Feb 14, 2022

@alanyoungCN thank you for reporting, but as you can see from the signature, issue is a bit different: image.so is present, but missing one of the dependent libraries. conda install libpng would undoubtedly solve this

@alanyoungCN
Copy link

@malfet Sorry for the title, I mention it in #5413 (comment). But I use pip to install torch and torchvision, I can't install libpng by pip.

Besides, when I install libpng in conda base env, the warning becomes Library not loaded: @rpath/libjpeg.9.dylib. It's very confusing.

cc plz🙏

@malfet
Copy link
Contributor

malfet commented Feb 14, 2022

@alanyoungCN you can conda install jpeg to probably solve this problem, but I agree, that those dependencies should be bundled into .whl file

@alanyoungCN
Copy link

@malfet
It works, thank you.

For now, the solution is installing the missing dylib by conda install libpng and conda install jpeg in conda base env, and it seems every python env will be okay.

But there is a little remaining question, how to install them in a pip-only environment?

@datumbox
Copy link
Contributor

@alanyoungCN It depends on the environment/operating system etc. You can install the libraries separately (for example using apt if you are on a debian system). Conda takes care of that.

@alanyoungCN
Copy link

@dimart
I do have installed it by brew install libpng, but it locates in /opt/homebrew/Cellar/libpng/ which is not in the @rpath lists(please see the full warning in #5413 (comment)), therefore leading the Library not loaded: @rpath/libpng16.16.dylib warning.

I wonder if you can bundle them all in .whl file, it may work.

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

7 participants