[Hardware][AMD][Perf][Bugfix] Update ROCr and clr in base image (#53712)

Signed-off-by: Matthew Wong <Matthew.Wong2@amd.com>

Matt committed Aug 26, 2026 at 00:38 UTC 796822d141382ab8ce82ef6101c6d802046f94e0
1 file changed +81
docker/Dockerfile.rocm_base
+81
@@ -15,6 +15,8 @@ ARG MORI_BRANCH="v1.1.0"
15 ARG MORI_REPO="https://github.com/ROCm/mori.git"
16 ARG ROCPROFILER_SDK_REPO="https://github.com/ROCm/rocm-systems.git"
17 ARG ROCPROFILER_SDK_COMMIT="2b22ab0195cc1461cd9abf3b969e9dd7c10af350"
18 +ARG ROCM_RUNTIME_REPO="https://github.com/mawong-amd/rocm-systems.git"
19 +ARG ROCM_RUNTIME_COMMIT="c7e40e16bca10311af72aee09cfa0cd1726f70a7"
20
21 # Sccache configuration (only used in release pipeline)
22 ARG USE_SCCACHE
@@ -24,11 +26,86 @@ ARG SCCACHE_BUCKET_NAME=vllm-build-sccache
26 ARG SCCACHE_REGION_NAME=us-west-2
27 ARG SCCACHE_S3_NO_CREDENTIALS=0
28
29 +
30 +###
31 +### ROCr + CLR build
32 +###
33 +# Pull in updates to ROCr + clr from ROCm 7.2.4 and beyond. Happens before base so they
34 +# are present in each downstream stage
35 +FROM ${BASE_IMAGE} AS build_rocm_runtime
36 +ARG ROCM_RUNTIME_REPO
37 +ARG ROCM_RUNTIME_COMMIT
38 +RUN apt-get update \
39 + && apt-get install -y --no-install-recommends git cmake ninja-build g++ pkg-config \
40 + python3-pip libelf-dev libdrm-dev libnuma-dev libdw-dev xxd \
41 + && rm -rf /var/lib/apt/lists/*
42 +RUN pip install --no-cache-dir CppHeaderParser
43 +RUN git init -q /src && cd /src \
44 + && git remote add origin ${ROCM_RUNTIME_REPO} \
45 + && git config core.sparseCheckout true \
46 + && git config remote.origin.promisor true \
47 + && git config remote.origin.partialclonefilter blob:none \
48 + && git sparse-checkout init --cone \
49 + && git sparse-checkout set projects/rocr-runtime projects/clr projects/hip shared cmake \
50 + && git fetch --filter=blob:none --depth 1 origin ${ROCM_RUNTIME_COMMIT} \
51 + && git checkout -q FETCH_HEAD
52 +# ROCr's trap_handler and blit_shaders call find_package(Clang/LLVM REQUIRED) only to get
53 +# IMPORTED executables. The ROCm dev image ships the binaries but no CMake package config, so
54 +# supply one pointing at them.
55 +RUN mkdir -p /opt/rocm-cmake-shim \
56 + && printf 'if(NOT TARGET clang)\n add_executable(clang IMPORTED GLOBAL)\n set_target_properties(clang PROPERTIES IMPORTED_LOCATION "/opt/rocm/llvm/bin/clang")\nendif()\nset(Clang_PACKAGE_VERSION "rocm-image-shim")\n' > /opt/rocm-cmake-shim/ClangConfig.cmake \
57 + && printf 'if(NOT TARGET llvm-objcopy)\n add_executable(llvm-objcopy IMPORTED GLOBAL)\n set_target_properties(llvm-objcopy PROPERTIES IMPORTED_LOCATION "/opt/rocm/llvm/bin/llvm-objcopy")\nendif()\nset(LLVM_FOUND TRUE)\nset(LLVM_PACKAGE_VERSION "rocm-image-shim")\n' > /opt/rocm-cmake-shim/LLVMConfig.cmake
58 +# ROCr first, and installed into /opt/rocm, because the clr build below needs its headers
59 +RUN cd /src/projects/rocr-runtime \
60 + && cmake -B build -G Ninja \
61 + -DCMAKE_BUILD_TYPE=Release \
62 + -DCMAKE_PREFIX_PATH=/opt/rocm \
63 + -DCMAKE_INSTALL_PREFIX=/opt/rocm \
64 + -DClang_DIR=/opt/rocm-cmake-shim \
65 + -DLLVM_DIR=/opt/rocm-cmake-shim \
66 + && cmake --build build --parallel 16 \
67 + && cmake --install build \
68 + && cmake --install build --prefix /rocr-install --strip
69 +RUN cd /src/projects/clr \
70 + && cmake -B build -G Ninja \
71 + -DCMAKE_BUILD_TYPE=Release \
72 + -DCLR_BUILD_HIP=ON \
73 + -DCLR_BUILD_OCL=OFF \
74 + -DHIP_COMMON_DIR=/src/projects/hip \
75 + -DROCM_PATH=/opt/rocm \
76 + -DCMAKE_PREFIX_PATH=/opt/rocm \
77 + -DCMAKE_INSTALL_PREFIX=/opt/rocm \
78 + -DLLVM_DIR=/opt/rocm-cmake-shim \
79 + -DHIP_LLVM_ROOT=/opt/rocm/llvm \
80 + && cmake --build build --parallel 16 \
81 + && cmake --install build --prefix /clr-install --strip
82 +RUN mkdir -p /staging/lib \
83 + && cp -P /rocr-install/lib/libhsa-runtime64.so* /staging/lib/ \
84 + && cp -P /clr-install/lib/libamdhip64.so* /staging/lib/ \
85 + && ls -l /staging/lib
86 +
87 +
88 FROM ${BASE_IMAGE} AS base
89
90 ENV PATH=/opt/rocm/llvm/bin:/opt/rocm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
91 ENV ROCM_PATH=/opt/rocm
92 ENV LD_LIBRARY_PATH=/opt/rocm/lib:/usr/local/lib:
93 +
94 +COPY --from=build_rocm_runtime /staging/ /opt/rocm/
95 +# Hard link the patched library onto every stock file name so that both the
96 +# SONAME lookup and the hard coded paths resolve to it.
97 +RUN set -eux; \
98 + cd /opt/rocm/lib; \
99 + ours_hsa="$(readlink -f libhsa-runtime64.so.1)"; \
100 + ours_hip="$(readlink -f libamdhip64.so.7)"; \
101 + for f in libhsa-runtime64.so.1.*; do \
102 + [ "$f" = "${ours_hsa##*/}" ] || ln -f "$ours_hsa" "$f"; \
103 + done; \
104 + for f in libamdhip64.so.7.*; do \
105 + [ "$f" = "${ours_hip##*/}" ] || ln -f "$ours_hip" "$f"; \
106 + done; \
107 + ldconfig
108 +
109 ARG PYTORCH_ROCM_ARCH=gfx90a;gfx942;gfx950;gfx1100;gfx1101;gfx1200;gfx1201;gfx1150;gfx1151
110 ENV PYTORCH_ROCM_ARCH=${PYTORCH_ROCM_ARCH}
111 ENV AITER_ROCM_ARCH=gfx942;gfx950
@@ -371,9 +448,13 @@ ARG MORI_BRANCH
448 ARG MORI_REPO
449 ARG ROCPROFILER_SDK_REPO
450 ARG ROCPROFILER_SDK_COMMIT
451 +ARG ROCM_RUNTIME_REPO
452 +ARG ROCM_RUNTIME_COMMIT
453 RUN echo "BASE_IMAGE: ${BASE_IMAGE}" > /app/versions.txt \
454 && echo "ROCPROFILER_SDK_REPO: ${ROCPROFILER_SDK_REPO}" >> /app/versions.txt \
455 && echo "ROCPROFILER_SDK_COMMIT: ${ROCPROFILER_SDK_COMMIT}" >> /app/versions.txt \
456 + && echo "ROCM_RUNTIME_REPO: ${ROCM_RUNTIME_REPO}" >> /app/versions.txt \
457 + && echo "ROCM_RUNTIME_COMMIT: ${ROCM_RUNTIME_COMMIT}" >> /app/versions.txt \
458 && echo "TRITON_BRANCH: ${TRITON_BRANCH}" >> /app/versions.txt \
459 && echo "TRITON_REPO: ${TRITON_REPO}" >> /app/versions.txt \
460 && echo "PYTORCH_BRANCH: ${PYTORCH_BRANCH}" >> /app/versions.txt \