Torchvision 0.20.1 looks for jpeg9 on MacOS, while depending on libjpeg-turbo which only provides jpeg8 #8889
Open
Description
🐛 Describe the bug
Hi, I tried to create a new conda environment torch + torchvision + torchaudio + blas accelerate on a MacOS 14.
Post installation, when I try to import the torchvision library, I get a warning about missing libjpeg9.
I have added more details below. Just wanted to bring this to your attention for triage and if there is an issue to be fixed. Cheers!
(Replaced full path with CONDA_PREFIX and added newlines to make it clearer)
mamba create -n env -c pytorch 'pytorch=2.5.1' torchvision torchaudio 'libblas=*=*accelerate'
mamba run -n env python
Python 3.12.8 | packaged by conda-forge | (main, Dec 5 2024, 14:19:53) [Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision
{CONDA_PREFIX}/lib/python3.12/site-packages/torchvision/io/image.py:14: UserWarning: Failed to load image Python extension: 'dlopen({CONDA_PREFIX}/lib/python3.12/site-packages/torchvision/image.so, 0x0006): Library not loaded: @rpath/libjpeg.9.dylib
Referenced from: <367D4265-B20F-34BD-94EB-4F3EE47C385B>{CONDA_PREFIX}/lib/python3.12/site-packages/torchvision/image.so
Reason: tried:
'{CONDA_PREFIX}/lib/python3.12/site-packages/torchvision/../../../libjpeg.9.dylib' (no such file),
'{CONDA_PREFIX}/lib/python3.12/site-packages/torchvision/../../../libjpeg.9.dylib' (no such file),
'{CONDA_PREFIX}/lib/python3.12/lib-dynload/../../libjpeg.9.dylib' (no such file),
'{CONDA_PREFIX}/bin/../lib/libjpeg.9.dylib' (no such file)'
If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?
warn(
>>>
I tried to find the jpeg libraries in the conda environment with find command
find ${CONDA_PREFIX} -name 'libjpeg*.dylib'
{CONDA_PREFIX}/lib/libjpeg.8.3.2.dylib
{CONDA_PREFIX}/lib/libjpeg.8.dylib
{CONDA_PREFIX}/lib/libjpeg.dylib
When I run otool
, I see that it is linked against jpeg9, while installing libjpeg-turbo as a dependency, which only provides jpeg8.
$ otool -L $CONDA_PREFIX/lib/python3.1/site-packages/torchvision/image.so
{CONDA_PREFIX}/lib/python3.1/site-packages/torchvision/image.so:
@rpath/libpng16.16.dylib (compatibility version 56.0.0, current version 56.0.0)
@rpath/libjpeg.9.dylib (compatibility version 15.0.0, current version 15.0.0)
@rpath/libwebp.7.dylib (compatibility version 9.0.0, current version 9.8.0)
@rpath/libc10.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libtorch.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libtorch_cpu.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libtorch_python.dylib (compatibility version 0.0.0, current version 0.0.0)
@rpath/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.100.2)
conda packages
blas 2.128 accelerate conda-forge
blas-devel 3.9.0 28_h55bc449_accelerate conda-forge
brotli-python 1.1.0 py312hde4cb15_2 conda-forge
bzip2 1.0.8 h99b78c6_7 conda-forge
ca-certificates 2024.12.14 hf0a4a13_0 conda-forge
certifi 2024.12.14 pyhd8ed1ab_0 conda-forge
cffi 1.17.1 py312h0fad829_0 conda-forge
charset-normalizer 3.4.1 pyhd8ed1ab_0 conda-forge
cpython 3.12.8 py312hd8ed1ab_1 conda-forge
filelock 3.17.0 pyhd8ed1ab_0 conda-forge
freetype 2.12.1 hadb7bae_2 conda-forge
giflib 5.2.2 h93a5062_0 conda-forge
gmp 6.3.0 h7bae524_2 conda-forge
gmpy2 2.1.5 py312h524cf62_3 conda-forge
h2 4.1.0 pyhd8ed1ab_1 conda-forge
hpack 4.1.0 pyhd8ed1ab_0 conda-forge
hyperframe 6.1.0 pyhd8ed1ab_0 conda-forge
idna 3.10 pyhd8ed1ab_1 conda-forge
jinja2 3.1.5 pyhd8ed1ab_0 conda-forge
lcms2 2.16 ha0e7c42_0 conda-forge
lerc 4.0.0 h9a09cb3_0 conda-forge
libblas 3.9.0 28_h504e6c8_accelerate conda-forge
libcblas 3.9.0 28_h8d39bcd_accelerate conda-forge
libcxx 19.1.7 ha82da77_0 conda-forge
libdeflate 1.23 hec38601_0 conda-forge
libexpat 2.6.4 h286801f_0 conda-forge
libffi 3.4.2 h3422bc3_5 conda-forge
libgfortran 5.0.0 13_2_0_hd922786_3 conda-forge
libgfortran5 13.2.0 hf226fd6_3 conda-forge
libjpeg-turbo 3.0.0 hb547adb_1 conda-forge
liblapack 3.9.0 28_h3c9cff3_accelerate conda-forge
liblapacke 3.9.0 28_h09be921_accelerate conda-forge
liblzma 5.6.3 h39f12f2_1 conda-forge
libpng 1.6.46 h3783ad8_0 conda-forge
libsqlite 3.48.0 h3f77e49_1 conda-forge
libtiff 4.7.0 h551f018_3 conda-forge
libwebp 1.5.0 h1618228_0 conda-forge
libwebp-base 1.5.0 h2471fea_0 conda-forge
libxcb 1.17.0 hdb1d25a_0 conda-forge
libzlib 1.3.1 h8359307_2 conda-forge
llvm-openmp 15.0.7 h7cfbb63_0 conda-forge
markupsafe 3.0.2 py312h998013c_1 conda-forge
mpc 1.3.1 h8f1351a_1 conda-forge
mpfr 4.2.1 hb693164_3 conda-forge
mpmath 1.3.0 pyhd8ed1ab_1 conda-forge
ncurses 6.5 h5e97a16_3 conda-forge
networkx 3.4.2 pyh267e887_2 conda-forge
numpy 2.2.2 py312h7c1f314_0 conda-forge
openjpeg 2.5.3 h8a3d83b_0 conda-forge
openssl 3.4.0 h81ee809_1 conda-forge
pillow 11.1.0 py312h50aef2c_0 conda-forge
pip 25.0 pyh8b19718_0 conda-forge
pthread-stubs 0.4 hd74edd7_1002 conda-forge
pycparser 2.22 pyh29332c3_1 conda-forge
pysocks 1.7.1 pyha55dd90_7 conda-forge
python 3.12.8 hc22306f_1_cpython conda-forge
python_abi 3.12 5_cp312 conda-forge
pytorch 2.5.1 py3.12_0 pytorch
pyyaml 6.0.2 py312h998013c_2 conda-forge
readline 8.2 h92ec313_1 conda-forge
requests 2.32.3 pyhd8ed1ab_1 conda-forge
setuptools 75.8.0 pyhff2d567_0 conda-forge
sympy 1.13.3 pyh2585a3b_105 conda-forge
tk 8.6.13 h5083fa2_1 conda-forge
torchaudio 2.5.1 py312_cpu pytorch
torchvision 0.20.1 py312_cpu pytorch
typing_extensions 4.12.2 pyha770c72_1 conda-forge
tzdata 2025a h78e105d_0 conda-forge
urllib3 2.3.0 pyhd8ed1ab_0 conda-forge
wheel 0.45.1 pyhd8ed1ab_1 conda-forge
xorg-libxau 1.0.12 h5505292_0 conda-forge
xorg-libxdmcp 1.1.5 hd74edd7_0 conda-forge
yaml 0.2.5 h3422bc3_2 conda-forge
zstandard 0.23.0 py312h15fbf35_1 conda-forge
zstd 1.5.6 hb46c0d2_0 conda-forge
Versions
Collecting environment information...
PyTorch version: 2.5.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A
OS: macOS 14.7.2 (arm64)
GCC version: Could not collect
Clang version: 16.0.0 (clang-1600.0.26.6)
CMake version: Could not collect
Libc version: N/A
Python version: 3.12.8 | packaged by conda-forge | (main, Dec 5 2024, 14:19:53) [Clang 18.1.8 ] (64-bit runtime)
Python platform: macOS-14.7.2-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
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
Is XNNPACK available: True
CPU:
Apple M3 Max
Versions of relevant libraries:
[pip3] numpy==2.2.2
[pip3] torch==2.5.1
[pip3] torchaudio==2.5.1
[pip3] torchvision==0.20.1
[conda] numpy 2.2.2 py312h7c1f314_0 conda-forge
[conda] pytorch 2.5.1 py3.12_0 pytorch
[conda] torchaudio 2.5.1 py312_cpu pytorch
[conda] torchvision 0.20.1 py312_cpu pytorch
Metadata
Assignees
Labels
No labels