Skip to content

Commit 85c8892

Browse files
committed
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.
1 parent 87ecb95 commit 85c8892

1 file changed

Lines changed: 60 additions & 66 deletions

File tree

.github/workflows/build.yml

Lines changed: 60 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -549,16 +549,22 @@ jobs:
549549
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip
550550
551551
ubuntu-latest-rocm:
552-
runs-on: ubuntu-latest
553-
container: rocm/dev-ubuntu-24.04:7.2
552+
runs-on: ubuntu-24.04
554553

555554
env:
556-
ROCM_VERSION: "7.2"
557555
UBUNTU_VERSION: "24.04"
558-
GPU_TARGETS: "gfx1151;gfx1150;gfx1100;gfx1101;gfx1102;gfx1200;gfx1201"
556+
557+
strategy:
558+
matrix:
559+
include:
560+
- ROCM_VERSION: "7.2.1"
561+
gpu_targets: "gfx908;gfx90a;gfx942;gfx1030;gfx1031;gfx1032;gfx1100;gfx1101;gfx1102;gfx1151;gfx1150;gfx1200;gfx1201"
562+
build: 'x64'
563+
- ROCM_VERSION: "7.12.0"
564+
gpu_targets: "gfx906;gfx908;gfx90a;gfx942;gfx950;gfx1100;gfx1101;gfx1102;gfx1150;gfx1151;gfx1200;gfx1201"
565+
build: x64
559566

560567
steps:
561-
- run: apt-get update && apt-get install -y git
562568
- name: Clone
563569
id: checkout
564570
uses: actions/checkout@v6
@@ -575,6 +581,38 @@ jobs:
575581
with:
576582
version: 10.15.1
577583

584+
- name: ccache
585+
uses: ggml-org/ccache-action@v1.2.16
586+
with:
587+
key: ubuntu-rocm-cmake-${{ matrix.ROCM_VERSION }}-${{ matrix.build }}
588+
evict-old-files: 1d
589+
590+
- name: Dependencies
591+
id: depends
592+
run: |
593+
sudo apt install -y build-essential cmake wget zip ninja-build
594+
595+
- name: Setup Legacy ROCm
596+
if: matrix.ROCM_VERSION == '7.2.1'
597+
id: legacy_env
598+
run: |
599+
sudo mkdir --parents --mode=0755 /etc/apt/keyrings
600+
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | \
601+
gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null
602+
603+
sudo tee /etc/apt/sources.list.d/rocm.list << EOF
604+
deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/${{ matrix.ROCM_VERSION }} noble main
605+
EOF
606+
607+
sudo tee /etc/apt/preferences.d/rocm-pin-600 << EOF
608+
Package: *
609+
Pin: release o=repo.radeon.com
610+
Pin-Priority: 600
611+
EOF
612+
613+
sudo apt update
614+
sudo apt-get install -y libssl-dev rocm-hip-sdk
615+
578616
- name: Free disk space
579617
run: |
580618
# Remove preinstalled SDKs and caches not needed for this job
@@ -588,64 +626,30 @@ jobs:
588626
sudo rm -rf /var/lib/apt/lists/* || true
589627
sudo apt clean
590628
591-
- name: Dependencies
592-
id: depends
629+
- name: Setup TheRock
630+
if: matrix.ROCM_VERSION != '7.2.1'
631+
id: therock_env
593632
run: |
594-
sudo apt-get update
595-
sudo apt install -y \
596-
cmake \
597-
hip-dev \
598-
hipblas-dev \
599-
ninja-build \
600-
rocm-dev \
601-
zip
602-
# Clean apt caches to recover disk space
603-
sudo apt clean
604-
sudo rm -rf /var/lib/apt/lists/* || true
605-
606-
- name: Setup ROCm Environment
607-
run: |
608-
# Add ROCm to PATH for current session
609-
echo "/opt/rocm/bin" >> $GITHUB_PATH
610-
611-
# Build regex pattern from ${{ env.GPU_TARGETS }} (match target as substring)
612-
TARGET_REGEX="($(printf '%s' "${{ env.GPU_TARGETS }}" | sed 's/;/|/g'))"
613-
614-
# Remove library files for architectures we're not building for to save disk space
615-
echo "Cleaning up unneeded architecture files..."
616-
cd /opt/rocm/lib/rocblas/library
617-
# Keep only our target architectures
618-
for file in *; do
619-
if printf '%s' "$file" | grep -q 'gfx'; then
620-
if ! printf '%s' "$file" | grep -Eq "$TARGET_REGEX"; then
621-
echo "Removing $file" &&
622-
sudo rm -f "$file";
623-
fi
624-
fi
625-
done
626-
627-
cd /opt/rocm/lib/hipblaslt/library
628-
for file in *; do
629-
if printf '%s' "$file" | grep -q 'gfx'; then
630-
if ! printf '%s' "$file" | grep -Eq "$TARGET_REGEX"; then
631-
echo "Removing $file" &&
632-
sudo rm -f "$file";
633-
fi
634-
fi
635-
done
633+
wget https://repo.amd.com/rocm/tarball/therock-dist-linux-gfx1151-${{ matrix.ROCM_VERSION }}.tar.gz
634+
mkdir install
635+
tar -xf *.tar.gz -C install
636+
export ROCM_PATH=$(pwd)/install
637+
echo ROCM_PATH=$ROCM_PATH >> $GITHUB_ENV
638+
echo PATH=$PATH:$ROCM_PATH/bin >> $GITHUB_ENV
639+
echo LD_LIBRARY_PATH=$ROCM_PATH/lib:$ROCM_PATH/llvm/lib:$ROCM_PATH/lib/rocprofiler-systems >> $GITHUB_ENV
636640
637641
- name: Build
638642
id: cmake_build
639643
run: |
640644
mkdir build
641645
cd build
642646
cmake .. -G Ninja \
643-
-DCMAKE_CXX_COMPILER=amdclang++ \
644-
-DCMAKE_C_COMPILER=amdclang \
647+
-DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" \
648+
-DCMAKE_HIP_FLAGS="-mllvm --amdgpu-unroll-threshold-local=600" \
645649
-DCMAKE_BUILD_TYPE=Release \
646650
-DSD_HIPBLAS=ON \
647-
-DGPU_TARGETS="${{ env.GPU_TARGETS }}" \
648-
-DAMDGPU_TARGETS="${{ env.GPU_TARGETS }}" \
651+
-DHIP_PLATFORM=amd \
652+
-DGPU_TARGETS="${{ matrix.gpu_targets }}" \
649653
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
650654
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
651655
-DSD_BUILD_SHARED_LIBS=ON
@@ -664,16 +668,6 @@ jobs:
664668
cp ggml/LICENSE ./build/bin/ggml.txt
665669
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
666670
667-
# Move ROCm runtime libraries (to avoid double space consumption)
668-
sudo mv /opt/rocm/lib/librocsparse.so* ./build/bin/
669-
sudo mv /opt/rocm/lib/libhsa-runtime64.so* ./build/bin/
670-
sudo mv /opt/rocm/lib/libamdhip64.so* ./build/bin/
671-
sudo mv /opt/rocm/lib/libhipblas.so* ./build/bin/
672-
sudo mv /opt/rocm/lib/libhipblaslt.so* ./build/bin/
673-
sudo mv /opt/rocm/lib/librocblas.so* ./build/bin/
674-
sudo mv /opt/rocm/lib/rocblas/ ./build/bin/
675-
sudo mv /opt/rocm/lib/hipblaslt/ ./build/bin/
676-
677671
- name: Fetch system info
678672
id: system-info
679673
run: |
@@ -688,15 +682,15 @@ jobs:
688682
run: |
689683
cp ggml/LICENSE ./build/bin/ggml.txt
690684
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
691-
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
685+
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
692686
693687
- name: Upload artifacts
694688
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
695689
uses: actions/upload-artifact@v4
696690
with:
697-
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
691+
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
698692
path: |
699-
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
693+
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
700694
701695
release:
702696
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}

0 commit comments

Comments
 (0)