Disable rocJPEG for ROCm wheel builds - #9586
Merged
Merged
Conversation
The ROCm 7.14 build of torchvision produces a wheel whose image extension
cannot be imported at all:
AttributeError: '_OpNamespace' 'image' object has no attribute '_jpeg_version'
setup.py enables rocJPEG whenever $ROCM_HOME/include/rocjpeg/rocjpeg.h is
present, which links torchvision/image_stable.so against librocjpeg.so.1. The
wheel repair step then omits librocjpeg ("Omitting librocjpeg.so.1"), as it
does for libtorch/libc10/libamdhip64 -- but unlike those, librocjpeg is not in
the torch wheel either: pytorch's repair_wheel.py has no rocjpeg in
ROCM_SO_FILES, and on the ROCm 7.14 TheRock layout it bundles no ROCm libs at
all (they live in the separate _rocm_sdk_* wheels, which torchvision has no
RPATH to). So image_stable.so fails to dlopen and every torchvision.io image op
disappears -- CPU jpeg/png/webp included, not just the GPU path.
ROCm 7.2 is unaffected only by accident: rocm/dev-almalinux-8 does not ship the
rocjpeg header, so that build already prints "Building torchvision without
ROCJPEG support". Setting the flag for all ROCm builds makes that intentional
and keeps 7.2 and 7.14 consistent.
The export is written to BUILD_ENV_FILE because the pre-script runs as a
subprocess (${CONDA_RUN} bash ${SCRIPT}); the build steps source that file.
If GPU JPEG on ROCm is wanted later, the fix is to make librocjpeg.so.1
resolvable -- bundle it into torchvision.libs or add an RPATH to the ROCm SDK
wheels -- rather than to re-enable the flag as-is.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/vision/9586
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
NicolasHug
approved these changes
Aug 6, 2026
NicolasHug
left a comment
Member
There was a problem hiding this comment.
SGTM, I am going to remove the entire ROCJPEG code from TorchVision soon anyway. As discussed on slack, I'm migrating it to TorchCodec in meta-pytorch/torchcodec#1554 (would love some help with the CI there!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The ROCm 7.14 torchvision build produces a wheel whose image extension cannot be
imported at all. Smoke test
(test-infra run):
torch.ops.imageis empty becausetorchvision/image_stable.sofails todlopen, and torchvision swallows the load error.Cause
setup.py:449enables rocJPEG whenever the header is present:so
image_stable.solinks-lrocjpeg. The repair step then drops it:Omitting the torch libs is fine — they resolve through torchvision's RPATH into
torch/lib.librocjpegis different: it is not in the torch wheel either.pytorch's
repair_wheel.pyhas no rocjpeg inROCM_SO_FILES, and on the ROCm7.14 TheRock layout it bundles no ROCm libs at all — they live in the separate
_rocm_sdk_*wheels, which torchvision has no RPATH to.So the extension is unloadable, and all
torchvision.ioimage ops vanish —CPU jpeg/png/webp included, not just the GPU path.
Why 7.2 is green today
By accident, not by design. Both builds print
USE_ROCJPEG = True; thedifference is only whether the header exists in the builder image:
Nothing sets
TORCHVISION_USE_ROCJPEGanywhere in this repo or in test-infratoday. This PR makes the existing 7.2 behaviour explicit and applies it to 7.14
too, so the two stay consistent as ROCm 7.1/7.2 → 7.2/7.14 lands
(pytorch/test-infra#8451).
Note on the mechanism
The export is appended to
BUILD_ENV_FILErather than just exported: thepre-script is invoked as a subprocess (
${CONDA_RUN} bash ${SCRIPT}) in its ownworkflow step, so a plain
exportwould not reach the build. Both"Build the wheel" steps in
build_wheels_linux.ymldosource "${BUILD_ENV_FILE}",which is how
FORCE_CUDAand friends already propagate. The guard on${BUILD_ENV_FILE:-}keeps the script usable when run by hand.Test plan
Gate exercised directly:
CU_VERSIONrocm7.2export TORCHVISION_USE_ROCJPEG=0rocm7.14export TORCHVISION_USE_ROCJPEG=0cu126/cpu/xpubash -nandshellcheck -S warningclean.BUILD_ENV_FILEunset the block is a no-op and does not error underset -u.TORCHVISION_USE_ROCJPEG=0makesUSE_ROCJPEGFalse, so the whole rocJPEGblock in
setup.pyis skipped: no-lrocjpeg, noROCJPEG_FOUND, and theimage extension goes back to the CPU-only link line that ROCm 7.2 ships today.
Follow-up
If GPU JPEG on ROCm is wanted, the fix is to make
librocjpeg.so.1resolvable —bundle it into
torchvision.libs/, or add an RPATH fromtorchvision/to theROCm SDK wheels mirroring
repair_wheel.py::rocm_rpaths()— rather thanre-enabling the flag as-is.
cc @jeffdaily @jithunnair-amd