From 85c88923b5d257743f1690d6582c9ccfe7526c73 Mon Sep 17 00:00:00 2001 From: "Mario Limonciello (AMD)" Date: Tue, 10 Feb 2026 15:46:17 -0600 Subject: [PATCH] Switch over ROCm builds to artifacts both for stable and preview releases AMD is in the process of moving over to a brand new build system (TheRock). They have a preview release stream for it, and it includes some significant performance uplifts. To let people experiment with both stacks generate artifacts both for the stable (7.2.1) and preview (7.12) stacks. In both cases - ROCm must be installed first to use this artifact. It's intentionally not bundled because so many ISAs are included and the size of the artifact balloons to an untenable size. --- .github/workflows/build.yml | 126 +++++++++++++++++------------------- 1 file changed, 60 insertions(+), 66 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c3dca338a..6c2591542 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -549,16 +549,22 @@ jobs: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip ubuntu-latest-rocm: - runs-on: ubuntu-latest - container: rocm/dev-ubuntu-24.04:7.2 + runs-on: ubuntu-24.04 env: - ROCM_VERSION: "7.2" UBUNTU_VERSION: "24.04" - GPU_TARGETS: "gfx1151;gfx1150;gfx1100;gfx1101;gfx1102;gfx1200;gfx1201" + + strategy: + matrix: + include: + - ROCM_VERSION: "7.2.1" + gpu_targets: "gfx908;gfx90a;gfx942;gfx1030;gfx1031;gfx1032;gfx1100;gfx1101;gfx1102;gfx1151;gfx1150;gfx1200;gfx1201" + build: 'x64' + - ROCM_VERSION: "7.12.0" + gpu_targets: "gfx906;gfx908;gfx90a;gfx942;gfx950;gfx1100;gfx1101;gfx1102;gfx1150;gfx1151;gfx1200;gfx1201" + build: x64 steps: - - run: apt-get update && apt-get install -y git - name: Clone id: checkout uses: actions/checkout@v6 @@ -575,6 +581,38 @@ jobs: with: version: 10.15.1 + - name: ccache + uses: ggml-org/ccache-action@v1.2.16 + with: + key: ubuntu-rocm-cmake-${{ matrix.ROCM_VERSION }}-${{ matrix.build }} + evict-old-files: 1d + + - name: Dependencies + id: depends + run: | + sudo apt install -y build-essential cmake wget zip ninja-build + + - name: Setup Legacy ROCm + if: matrix.ROCM_VERSION == '7.2.1' + id: legacy_env + run: | + sudo mkdir --parents --mode=0755 /etc/apt/keyrings + wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | \ + gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null + + sudo tee /etc/apt/sources.list.d/rocm.list << EOF + deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/${{ matrix.ROCM_VERSION }} noble main + EOF + + sudo tee /etc/apt/preferences.d/rocm-pin-600 << EOF + Package: * + Pin: release o=repo.radeon.com + Pin-Priority: 600 + EOF + + sudo apt update + sudo apt-get install -y libssl-dev rocm-hip-sdk + - name: Free disk space run: | # Remove preinstalled SDKs and caches not needed for this job @@ -588,51 +626,17 @@ jobs: sudo rm -rf /var/lib/apt/lists/* || true sudo apt clean - - name: Dependencies - id: depends + - name: Setup TheRock + if: matrix.ROCM_VERSION != '7.2.1' + id: therock_env run: | - sudo apt-get update - sudo apt install -y \ - cmake \ - hip-dev \ - hipblas-dev \ - ninja-build \ - rocm-dev \ - zip - # Clean apt caches to recover disk space - sudo apt clean - sudo rm -rf /var/lib/apt/lists/* || true - - - name: Setup ROCm Environment - run: | - # Add ROCm to PATH for current session - echo "/opt/rocm/bin" >> $GITHUB_PATH - - # Build regex pattern from ${{ env.GPU_TARGETS }} (match target as substring) - TARGET_REGEX="($(printf '%s' "${{ env.GPU_TARGETS }}" | sed 's/;/|/g'))" - - # Remove library files for architectures we're not building for to save disk space - echo "Cleaning up unneeded architecture files..." - cd /opt/rocm/lib/rocblas/library - # Keep only our target architectures - for file in *; do - if printf '%s' "$file" | grep -q 'gfx'; then - if ! printf '%s' "$file" | grep -Eq "$TARGET_REGEX"; then - echo "Removing $file" && - sudo rm -f "$file"; - fi - fi - done - - cd /opt/rocm/lib/hipblaslt/library - for file in *; do - if printf '%s' "$file" | grep -q 'gfx'; then - if ! printf '%s' "$file" | grep -Eq "$TARGET_REGEX"; then - echo "Removing $file" && - sudo rm -f "$file"; - fi - fi - done + wget https://repo.amd.com/rocm/tarball/therock-dist-linux-gfx1151-${{ matrix.ROCM_VERSION }}.tar.gz + mkdir install + tar -xf *.tar.gz -C install + export ROCM_PATH=$(pwd)/install + echo ROCM_PATH=$ROCM_PATH >> $GITHUB_ENV + echo PATH=$PATH:$ROCM_PATH/bin >> $GITHUB_ENV + echo LD_LIBRARY_PATH=$ROCM_PATH/lib:$ROCM_PATH/llvm/lib:$ROCM_PATH/lib/rocprofiler-systems >> $GITHUB_ENV - name: Build id: cmake_build @@ -640,12 +644,12 @@ jobs: mkdir build cd build cmake .. -G Ninja \ - -DCMAKE_CXX_COMPILER=amdclang++ \ - -DCMAKE_C_COMPILER=amdclang \ + -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \ + -DCMAKE_HIP_FLAGS="-mllvm --amdgpu-unroll-threshold-local=600" \ -DCMAKE_BUILD_TYPE=Release \ -DSD_HIPBLAS=ON \ - -DGPU_TARGETS="${{ env.GPU_TARGETS }}" \ - -DAMDGPU_TARGETS="${{ env.GPU_TARGETS }}" \ + -DHIP_PLATFORM=amd \ + -DGPU_TARGETS="${{ matrix.gpu_targets }}" \ -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ -DSD_BUILD_SHARED_LIBS=ON @@ -664,16 +668,6 @@ jobs: cp ggml/LICENSE ./build/bin/ggml.txt cp LICENSE ./build/bin/stable-diffusion.cpp.txt - # Move ROCm runtime libraries (to avoid double space consumption) - sudo mv /opt/rocm/lib/librocsparse.so* ./build/bin/ - sudo mv /opt/rocm/lib/libhsa-runtime64.so* ./build/bin/ - sudo mv /opt/rocm/lib/libamdhip64.so* ./build/bin/ - sudo mv /opt/rocm/lib/libhipblas.so* ./build/bin/ - sudo mv /opt/rocm/lib/libhipblaslt.so* ./build/bin/ - sudo mv /opt/rocm/lib/librocblas.so* ./build/bin/ - sudo mv /opt/rocm/lib/rocblas/ ./build/bin/ - sudo mv /opt/rocm/lib/hipblaslt/ ./build/bin/ - - name: Fetch system info id: system-info run: | @@ -688,15 +682,15 @@ jobs: run: | cp ggml/LICENSE ./build/bin/ggml.txt cp LICENSE ./build/bin/stable-diffusion.cpp.txt - zip -y -r sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm.zip ./build/bin + zip -y -r sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm-${{ matrix.ROCM_VERSION }}.zip ./build/bin - name: Upload artifacts if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }} uses: actions/upload-artifact@v4 with: - name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm.zip + name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm-${{ matrix.ROCM_VERSION }}.zip path: | - sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm.zip + sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-${{ steps.system-info.outputs.OS_TYPE }}-Ubuntu-${{ env.UBUNTU_VERSION }}-${{ steps.system-info.outputs.CPU_ARCH }}-rocm-${{ matrix.ROCM_VERSION }}.zip release: if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}