Build HipBLAS ROCm 7.1 #39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build HipBLAS ROCm 7.1 | |
| on: | |
| workflow_dispatch: # allows manual triggering | |
| inputs: | |
| create_release: | |
| description: "Create rocm release" | |
| required: false | |
| type: boolean | |
| default: false | |
| gpu_targets: | |
| description: "GPU Targets (comma separated)" | |
| required: false | |
| type: string | |
| default: "gfx1201,gfx1200,gfx1100,gfx1101,gfx1151" | |
| push: | |
| branches: | |
| - master | |
| - ci | |
| paths: | |
| [ | |
| ".github/workflows/build-hipblas-rocm71.yml", | |
| "**/CMakeLists.txt", | |
| "**/*.h", | |
| "**/*.hpp", | |
| "**/*.c", | |
| "**/*.cpp", | |
| "**/*.cu", | |
| ] | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| paths: | |
| [ | |
| ".github/workflows/build-hipblas-rocm71.yml", | |
| "**/CMakeLists.txt", | |
| "**/*.h", | |
| "**/*.hpp", | |
| "**/*.c", | |
| "**/*.cpp", | |
| "**/*.cu", | |
| ] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| get-default-branch: | |
| runs-on: self-hosted | |
| outputs: | |
| branch: ${{ steps.branch.outputs.branch }} | |
| steps: | |
| - name: Get default branch | |
| id: branch | |
| run: echo "branch=${{ github.event.repository.default_branch || 'master' }}" >> $GITHUB_OUTPUT | |
| rocm71-hipblas-build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| gpu_target: [gfx1201, gfx1200, gfx1100, gfx1101, gfx1151] | |
| runs-on: self-hosted | |
| needs: get-default-branch | |
| env: | |
| BRANCH_NAME: ${{ needs.get-default-branch.outputs.branch }} | |
| ROCM_VERSION: "7.1.0" | |
| # Individual GPU target for this build | |
| GPU_TARGET: ${{ matrix.gpu_target }} | |
| SD_DEFINES: -DSD_HIPBLAS=ON -DSD_BUILD_SHARED_LIBS=ON -DGGML_NATIVE=OFF | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup ROCm (Ubuntu) | |
| run: | | |
| # Remove existing ROCm packages to avoid conflicts | |
| sudo apt remove --purge -y rocm-* hip-* hipcc rocm-cmake rocm-utils || true | |
| sudo apt autoremove -y | |
| # Install ROCm 7.1 | |
| sudo apt update | |
| sudo apt install -y wget gnupg | |
| # Add ROCm GPG key to proper location | |
| sudo mkdir -p /etc/apt/keyrings | |
| wget -qO - https://repo.radeon.com/rocm/rocm.gpg.key | sudo gpg --batch --yes --dearmor -o /etc/apt/keyrings/rocm.gpg | |
| # Add both ROCm repositories | |
| 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/7.1 noble main | |
| deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/graphics/7.1/ubuntu noble main | |
| EOF | |
| # Set repository priority | |
| 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 install -y \ | |
| rocm-dev \ | |
| clang \ | |
| hip-dev \ | |
| hipblas-dev \ | |
| rocblas-dev \ | |
| cmake \ | |
| ninja-build \ | |
| build-essential \ | |
| logrotate | |
| - name: Cache build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.ccache | |
| build | |
| key: ${{ runner.os }}-rocm71-${{ matrix.gpu_target }}-${{ hashFiles('**/CMakeLists.txt', '**/*.cpp', '**/*.h') }} | |
| restore-keys: | | |
| ${{ runner.os }}-rocm71-${{ matrix.gpu_target }}- | |
| - name: Build with CMake | |
| run: | | |
| # Setup ccache | |
| sudo apt install -y ccache | |
| export PATH="/usr/lib/ccache:$PATH" | |
| mkdir -p build | |
| cd build | |
| echo "Building for GPU target: ${{ matrix.gpu_target }}" | |
| # Configure with ROCm 7.1 and specific GPU target (following official build guide) | |
| cmake .. \ | |
| -G "Ninja" \ | |
| -DCMAKE_C_COMPILER=clang \ | |
| -DCMAKE_CXX_COMPILER=clang++ \ | |
| -DSD_HIPBLAS=ON \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DGPU_TARGETS="${{ env.GPU_TARGET }}" \ | |
| -DAMDGPU_TARGETS="${{ env.GPU_TARGET }}" \ | |
| -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \ | |
| -DCMAKE_POSITION_INDEPENDENT_CODE=ON | |
| # Build with all available cores | |
| cmake --build . --config Release | |
| - name: Test HipBLAS build | |
| run: | | |
| cd build | |
| # Test if hipblas libraries are linked correctly | |
| ldd bin/* 2>/dev/null | grep -i hip || echo "No direct HIP dependencies found" | |
| ldd bin/* 2>/dev/null | grep -i rocm || echo "No ROCm dependencies found" | |
| echo "Built binaries for GPU target ${{ matrix.gpu_target }}:" | |
| ls -la bin/ | |
| - name: Get commit hash | |
| id: commit | |
| if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' || github.event.inputs.create_release == 'true' }} | |
| run: | | |
| echo "short=$(git rev-parse --short=7 HEAD)" >> $GITHUB_OUTPUT | |
| - name: Package artifacts | |
| if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' || github.event.inputs.create_release == 'true' }} | |
| run: | | |
| cd build | |
| # Create package directory | |
| mkdir -p package/lib package/bin package/include | |
| # Copy binaries | |
| cp -r bin/* package/bin/ || echo "No binaries to copy" | |
| # Copy ROCm libraries if needed | |
| if [ -d "/opt/rocm/lib" ]; then | |
| cp /opt/rocm/lib/libhipblas.so* package/lib/ 2>/dev/null || echo "hipblas lib not found" | |
| cp /opt/rocm/lib/librocblas.so* package/lib/ 2>/dev/null || echo "rocblas lib not found" | |
| cp /opt/rocm/lib/libhipblaslt.so* package/lib/ 2>/dev/null || echo "hipblaslt lib not found" | |
| fi | |
| # Create archive with GPU target in filename | |
| tar -czf ../sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-linux-rocm71-${{ matrix.gpu_target }}-x64.tar.gz -C package . | |
| - 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-linux-rocm71-${{ matrix.gpu_target }}-x64 | |
| path: | | |
| sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-linux-rocm71-${{ matrix.gpu_target }}-x64.tar.gz | |
| retention-days: 7 | |
| - name: Create Release | |
| if: ${{ github.event.inputs.create_release == 'true' && github.ref == 'refs/heads/master' }} | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: rocm71-${{ matrix.gpu_target }}-${{ steps.commit.outputs.short }} | |
| name: ROCm 7.1 HipBLAS Build ${{ matrix.gpu_target }} ${{ steps.commit.outputs.short }} | |
| body: | | |
| ## ROCm 7.1 HipBLAS Build for ${{ matrix.gpu_target }} | |
| **GPU Target:** `${{ matrix.gpu_target }}` | |
| **Commit:** ${{ steps.commit.outputs.short }} | |
| Built with: | |
| - ROCm 7.1.0 | |
| - HipBLAS support | |
| - Optimized for GPU architecture: ${{ matrix.gpu_target }} | |
| ### Downloads | |
| - Linux: `sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-linux-rocm71-${{ matrix.gpu_target }}-x64.tar.gz` | |
| files: | | |
| sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-linux-rocm71-${{ matrix.gpu_target }}-x64.tar.gz | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |