Skip to content

Commit 5b21378

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) and preview (7.11) 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 636d3cb commit 5b21378

File tree

1 file changed

+54
-72
lines changed

1 file changed

+54
-72
lines changed

.github/workflows/build.yml

Lines changed: 54 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,20 @@ jobs:
486486
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip
487487
488488
ubuntu-latest-rocm:
489-
runs-on: ubuntu-latest
490-
container: rocm/dev-ubuntu-24.04:7.2
489+
runs-on: ubuntu-24.04
491490

492491
env:
493-
ROCM_VERSION: "7.2"
494492
UBUNTU_VERSION: "24.04"
495-
GPU_TARGETS: "gfx1151;gfx1150;gfx1100;gfx1101;gfx1102;gfx1200;gfx1201"
493+
494+
strategy:
495+
matrix:
496+
include:
497+
- ROCM_VERSION: "7.2"
498+
gpu_targets: "gfx908;gfx90a;gfx942;gfx1030;gfx1031;gfx1032;gfx1100;gfx1101;gfx1102;gfx1151;gfx1150;gfx1200;gfx1201"
499+
build: 'x64'
500+
- ROCM_VERSION: "7.11.0"
501+
gpu_targets: "gfx906;gfx908;gfx90a;gfx942;gfx950;gfx1100;gfx1101;gfx1102;gfx1150;gfx1151;gfx1152;gfx1200;gfx1201"
502+
build: x64
496503

497504
steps:
498505
- run: apt-get update && apt-get install -y git
@@ -502,64 +509,49 @@ jobs:
502509
with:
503510
submodules: recursive
504511

505-
- name: Free disk space
506-
run: |
507-
# Remove preinstalled SDKs and caches not needed for this job
508-
sudo rm -rf /usr/share/dotnet || true
509-
sudo rm -rf /usr/local/lib/android || true
510-
sudo rm -rf /opt/ghc || true
511-
sudo rm -rf /usr/local/.ghcup || true
512-
sudo rm -rf /opt/hostedtoolcache || true
513-
514-
# Remove old package lists and caches
515-
sudo rm -rf /var/lib/apt/lists/* || true
516-
sudo apt clean
512+
- name: ccache
513+
uses: ggml-org/ccache-action@v1.2.16
514+
with:
515+
key: ubuntu-rocm-cmake-${{ matrix.ROCM_VERSION }}-${{ matrix.build }}
516+
evict-old-files: 1d
517517

518518
- name: Dependencies
519519
id: depends
520520
run: |
521-
sudo apt-get update
522-
sudo apt install -y \
523-
cmake \
524-
hip-dev \
525-
hipblas-dev \
526-
ninja-build \
527-
rocm-dev \
528-
zip
529-
# Clean apt caches to recover disk space
530-
sudo apt clean
531-
sudo rm -rf /var/lib/apt/lists/* || true
532-
533-
- name: Setup ROCm Environment
521+
sudo apt install -y build-essential cmake wget zip ninja-build
522+
523+
- name: Setup Legacy ROCm
524+
if: matrix.ROCM_VERSION == '7.2'
525+
id: legacy_env
526+
run: |
527+
sudo mkdir --parents --mode=0755 /etc/apt/keyrings
528+
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | \
529+
gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null
530+
531+
sudo tee /etc/apt/sources.list.d/rocm.list << EOF
532+
deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/${{ matrix.ROCM_VERSION }} noble main
533+
EOF
534+
535+
sudo tee /etc/apt/preferences.d/rocm-pin-600 << EOF
536+
Package: *
537+
Pin: release o=repo.radeon.com
538+
Pin-Priority: 600
539+
EOF
540+
541+
sudo apt update
542+
sudo apt-get install -y libssl-dev rocm-hip-sdk
543+
544+
- name: Setup TheRock
545+
if: matrix.ROCM_VERSION != '7.2'
546+
id: therock_env
534547
run: |
535-
# Add ROCm to PATH for current session
536-
echo "/opt/rocm/bin" >> $GITHUB_PATH
537-
538-
# Build regex pattern from ${{ env.GPU_TARGETS }} (match target as substring)
539-
TARGET_REGEX="($(printf '%s' "${{ env.GPU_TARGETS }}" | sed 's/;/|/g'))"
540-
541-
# Remove library files for architectures we're not building for to save disk space
542-
echo "Cleaning up unneeded architecture files..."
543-
cd /opt/rocm/lib/rocblas/library
544-
# Keep only our target architectures
545-
for file in *; do
546-
if printf '%s' "$file" | grep -q 'gfx'; then
547-
if ! printf '%s' "$file" | grep -Eq "$TARGET_REGEX"; then
548-
echo "Removing $file" &&
549-
sudo rm -f "$file";
550-
fi
551-
fi
552-
done
553-
554-
cd /opt/rocm/lib/hipblaslt/library
555-
for file in *; do
556-
if printf '%s' "$file" | grep -q 'gfx'; then
557-
if ! printf '%s' "$file" | grep -Eq "$TARGET_REGEX"; then
558-
echo "Removing $file" &&
559-
sudo rm -f "$file";
560-
fi
561-
fi
562-
done
548+
wget https://repo.amd.com/rocm/tarball/therock-dist-linux-gfx1151-${{ matrix.ROCM_VERSION }}.tar.gz
549+
mkdir install
550+
tar -xf *.tar.gz -C install
551+
export ROCM_PATH=$(pwd)/install
552+
echo ROCM_PATH=$ROCM_PATH >> $GITHUB_ENV
553+
echo PATH=$PATH:$ROCM_PATH/bin >> $GITHUB_ENV
554+
echo LD_LIBRARY_PATH=$ROCM_PATH/lib:$ROCM_PATH/llvm/lib:$ROCM_PATH/lib/rocprofiler-systems >> $GITHUB_ENV
563555
564556
- name: Build
565557
id: cmake_build
@@ -571,8 +563,8 @@ jobs:
571563
-DCMAKE_C_COMPILER=amdclang \
572564
-DCMAKE_BUILD_TYPE=Release \
573565
-DSD_HIPBLAS=ON \
574-
-DGPU_TARGETS="${{ env.GPU_TARGETS }}" \
575-
-DAMDGPU_TARGETS="${{ env.GPU_TARGETS }}" \
566+
-DCMAKE_HIP_FLAGS="-mllvm --amdgpu-unroll-threshold-local=600" \
567+
-DGPU_TARGETS="${{ matrix.gpu_targets }}" \
576568
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
577569
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
578570
-DSD_BUILD_SHARED_LIBS=ON
@@ -591,16 +583,6 @@ jobs:
591583
cp ggml/LICENSE ./build/bin/ggml.txt
592584
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
593585
594-
# Move ROCm runtime libraries (to avoid double space consumption)
595-
sudo mv /opt/rocm/lib/librocsparse.so* ./build/bin/
596-
sudo mv /opt/rocm/lib/libhsa-runtime64.so* ./build/bin/
597-
sudo mv /opt/rocm/lib/libamdhip64.so* ./build/bin/
598-
sudo mv /opt/rocm/lib/libhipblas.so* ./build/bin/
599-
sudo mv /opt/rocm/lib/libhipblaslt.so* ./build/bin/
600-
sudo mv /opt/rocm/lib/librocblas.so* ./build/bin/
601-
sudo mv /opt/rocm/lib/rocblas/ ./build/bin/
602-
sudo mv /opt/rocm/lib/hipblaslt/ ./build/bin/
603-
604586
- name: Fetch system info
605587
id: system-info
606588
run: |
@@ -615,15 +597,15 @@ jobs:
615597
run: |
616598
cp ggml/LICENSE ./build/bin/ggml.txt
617599
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
618-
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
600+
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
619601
620602
- name: Upload artifacts
621603
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
622604
uses: actions/upload-artifact@v4
623605
with:
624-
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
606+
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
625607
path: |
626-
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
608+
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
627609
628610
release:
629611
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}

0 commit comments

Comments
 (0)