diff --git a/packaging/pre_build_script.sh b/packaging/pre_build_script.sh index 7167d813399..f1337233103 100644 --- a/packaging/pre_build_script.sh +++ b/packaging/pre_build_script.sh @@ -38,5 +38,21 @@ else pip install "auditwheel<6.3.0" fi +# Build the image extension without rocJPEG on ROCm. setup.py enables rocJPEG +# whenever $ROCM_HOME/include/rocjpeg/rocjpeg.h exists, which links +# torchvision/image_stable.so against librocjpeg.so.1. That library is neither +# bundled into the torchvision wheel (the repair step omits it) nor shipped in +# the torch wheel, so the extension fails to dlopen at import and every +# torchvision.io image op silently disappears -- CPU jpeg/png/webp included. +# Written to BUILD_ENV_FILE because this script runs as a subprocess; the build +# steps source that file. +if [[ "${CU_VERSION:-}" == rocm* ]]; then + echo "Disabling rocJPEG support for ${CU_VERSION}" + export TORCHVISION_USE_ROCJPEG=0 + if [[ -n "${BUILD_ENV_FILE:-}" ]]; then + echo "export TORCHVISION_USE_ROCJPEG=0" >> "${BUILD_ENV_FILE}" + fi +fi + pip install numpy pyyaml future ninja pip install --upgrade setuptools==72.1.0