Skip to content

Commit e853e3e

Browse files
rocm: fix rocjpeg install with rpm --nodeps fallback for missing mesa dep
Try the standard 'dnf install rocjpeg rocjpeg-devel' first. If it fails because mesa-amdgpu-va-drivers is not available as a standalone dnf package (compute-only CI runners only have --usecase=rocm, not --usecase=graphics), fall back to downloading the RPMs and installing with rpm --nodeps. The mesa VA-API driver is already present on the system via amdgpu-install even if not registered as an RPM package. Also simplify the already-installed check to look for rocjpeg.h in either /opt/rocm (system install) or /opt/conda (ROCm pip-wheel install). Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 88f7ead commit e853e3e

1 file changed

Lines changed: 20 additions & 25 deletions

File tree

packaging/install_rocjpeg.sh

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,27 @@
1313

1414
set -euo pipefail
1515

16-
# ROCm >= 7.14 distributes the full ROCm stack (including rocJPEG and mesa)
17-
# as pip wheels (_rocm_sdk_core / _rocm_sdk_devel site-packages). In that case
18-
# librocjpeg.so, rocjpeg.h, and the AMD VA-API backend driver (mesa) are all
19-
# bundled inside _rocm_sdk_core — no separate dnf install needed.
20-
21-
# Check if librocjpeg is already available via the ROCm >= 7.14 pip-wheel layout
22-
# (_rocm_sdk_core / _rocm_sdk_devel under site-packages). In that layout AMD
23-
# bundles mesa (the VA-API DRI driver) inside _rocm_sdk_core, so no separate
24-
# dnf install of mesa-amdgpu-va-drivers is needed — only the base libva soname.
25-
#
26-
# NOTE: we intentionally do NOT match /opt/rocm/lib/librocjpeg.so* here. If
27-
# librocjpeg was installed via the ROCm <= 7.2 system RPM path it may be
28-
# present at /opt/rocm but mesa-amdgpu-va-drivers may not be — they are
29-
# separate packages and must be installed together. Let the else branch handle
30-
# that case so it always installs the full VA-API stack.
16+
# Skip if rocjpeg is already installed (e.g. via the ROCm pip-wheel distribution).
3117
if python3 -c "
3218
import glob, sys
33-
# Only the pip-wheel layout bundles mesa alongside librocjpeg.
34-
hits = glob.glob('/opt/conda/**/librocjpeg.so*', recursive=True)
35-
sys.exit(0 if hits else 1)
19+
found = (glob.glob('/opt/rocm/include/rocjpeg/rocjpeg.h') or
20+
glob.glob('/opt/conda/**/rocjpeg.h', recursive=True))
21+
sys.exit(0 if found else 1)
3622
" 2>/dev/null; then
37-
echo "librocjpeg already present via ROCm pip-wheel install; skipping dnf install."
38-
# libva is bundled inside _rocm_sdk_core/lib/rocm_sysdeps/lib/ and
39-
# librocjpeg's own RPATH resolves it from there — no system install needed.
40-
else
41-
# ROCm <=7.2 system RPM path.
42-
# rocjpeg-devel's RPM dependencies pull in libva and mesa VA drivers automatically.
43-
dnf install -y rocjpeg-devel
23+
echo "rocjpeg already installed; skipping dnf install."
24+
exit 0
25+
fi
26+
27+
# Install from the ROCm dnf repo.
28+
# mesa-amdgpu-va-drivers is declared as an RPM dependency of rocjpeg but may
29+
# not be available as a standalone dnf package (it is installed via
30+
# amdgpu-install as part of the GPU driver stack). Fall back to rpm --nodeps
31+
# if the regular dnf install fails for that reason.
32+
if ! dnf install -y rocjpeg rocjpeg-devel; then
33+
# Ensure the 'dnf download' subcommand is available.
34+
dnf install -y "dnf-command(download)" 2>/dev/null || dnf install -y dnf-plugins-core
35+
tmpdir=$(mktemp -d)
36+
dnf download --destdir "$tmpdir" rocjpeg rocjpeg-devel
37+
rpm -Uvh --nodeps "$tmpdir"/*.rpm
38+
rm -rf "$tmpdir"
4439
fi

0 commit comments

Comments
 (0)