@@ -485,6 +485,153 @@ jobs:
485485 path : |
486486 sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip
487487
488+ ubuntu-latest-rocm :
489+ runs-on : ubuntu-latest
490+ container : rocm/dev-ubuntu-24.04:7.2
491+
492+ env :
493+ ROCM_VERSION : " 7.2"
494+ UBUNTU_VERSION : " 24.04"
495+ GPU_TARGETS : " gfx1151;gfx1150;gfx1100;gfx1101;gfx1102;gfx1200;gfx1201"
496+
497+ steps :
498+ - run : apt-get update && apt-get install -y git
499+ - name : Clone
500+ id : checkout
501+ uses : actions/checkout@v6
502+ with :
503+ submodules : recursive
504+
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
517+
518+ - name : Dependencies
519+ id : depends
520+ 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
534+ run : |
535+ # Add ROCm to PATH for current session
536+ echo "/opt/rocm/bin" >> $GITHUB_PATH
537+
538+ # Build case pattern from GPU_TARGETS
539+ PATTERN=$(printf '%s' "$GPU_TARGETS" | sed 's/;/\*|\*/g')
540+ PATTERN="*${PATTERN}*"
541+
542+ # Remove library files for architectures we're not building for to save disk space
543+ echo "Cleaning up unneeded architecture files..."
544+ cd /opt/rocm/lib/rocblas/library
545+ # Keep only our target architectures
546+ for file in *; do
547+ case "$file" in
548+ $PATTERN)
549+ ;;
550+ *)
551+ sudo rm -f "$file" ;;
552+ esac;
553+ done
554+
555+ cd /opt/rocm/lib/hipblaslt/library
556+ for file in *; do
557+ case "$file" in
558+ $PATTERN)
559+ ;;
560+ *)
561+ sudo rm -f "$file" ;;
562+ esac;
563+ done
564+
565+ - name : Build
566+ id : cmake_build
567+ run : |
568+ mkdir build
569+ cd build
570+ cmake .. -G Ninja \
571+ -DCMAKE_CXX_COMPILER=amdclang++ \
572+ -DCMAKE_C_COMPILER=amdclang \
573+ -DCMAKE_BUILD_TYPE=Release \
574+ -DSD_HIPBLAS=ON \
575+ -DGPU_TARGETS="${{ env.GPU_TARGETS }}" \
576+ -DAMDGPU_TARGETS="${{ env.GPU_TARGETS }}" \
577+ -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
578+ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
579+ -DSD_BUILD_SHARED_LIBS=ON
580+ cmake --build . --config Release
581+
582+ - name : Get commit hash
583+ id : commit
584+ if : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
585+ uses : pr-mpt/actions-commit-hash@v2
586+
587+ - name : Prepare artifacts
588+ id : prepare_artifacts
589+ if : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
590+ run : |
591+ # Copy licenses
592+ cp ggml/LICENSE ./build/bin/ggml.txt
593+ cp LICENSE ./build/bin/stable-diffusion.cpp.txt
594+
595+ # Create directories for ROCm libraries
596+ mkdir -p ./build/bin/rocblas/library
597+ mkdir -p ./build/bin/hipblaslt/library
598+
599+ # Copy ROCm runtime libraries (use || true to continue if files don't exist)
600+ cp /opt/rocm/lib/librocsparse.so* ./build/bin/ || true
601+ cp /opt/rocm/lib/libhsa-runtime64.so* ./build/bin/ || true
602+ cp /opt/rocm/lib/libamdhip64.so* ./build/bin/ || true
603+ cp /opt/rocm/lib/libhipblas.so* ./build/bin/ || true
604+ cp /opt/rocm/lib/libhipblaslt.so* ./build/bin/ || true
605+ cp /opt/rocm/lib/librocblas.so* ./build/bin/ || true
606+
607+ # Copy library files (already filtered to target architectures)
608+ cp /opt/rocm/lib/rocblas/library/* ./build/bin/rocblas/library/ || true
609+ cp /opt/rocm/lib/hipblaslt/library/* ./build/bin/hipblaslt/library/ || true
610+
611+ - name : Fetch system info
612+ id : system-info
613+ run : |
614+ echo "CPU_ARCH=`uname -m`" >> "$GITHUB_OUTPUT"
615+ echo "OS_NAME=`lsb_release -s -i`" >> "$GITHUB_OUTPUT"
616+ echo "OS_VERSION=`lsb_release -s -r`" >> "$GITHUB_OUTPUT"
617+ echo "OS_TYPE=`uname -s`" >> "$GITHUB_OUTPUT"
618+
619+ - name : Pack artifacts
620+ id : pack_artifacts
621+ if : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
622+ run : |
623+ cp ggml/LICENSE ./build/bin/ggml.txt
624+ cp LICENSE ./build/bin/stable-diffusion.cpp.txt
625+ zip -j 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/*
626+
627+ - name : Upload artifacts
628+ if : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
629+ uses : actions/upload-artifact@v4
630+ with :
631+ 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
632+ path : |
633+ 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
634+
488635 release :
489636 if : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
490637
@@ -493,6 +640,7 @@ jobs:
493640 needs :
494641 - ubuntu-latest-cmake
495642 - ubuntu-latest-cmake-vulkan
643+ - ubuntu-latest-rocm
496644 - build-and-push-docker-images
497645 - macOS-latest-cmake
498646 - windows-latest-cmake
0 commit comments