Skip to content

Strip Tensile library data #8

Strip Tensile library data

Strip Tensile library data #8

name: ROCm Test
on:
workflow_dispatch: # allows manual triggering
inputs:
create_release:
description: "Create new release"
required: true
type: boolean
push:
branches:
- master
- ci
paths:
[
".github/workflows/**",
"**/CMakeLists.txt",
"**/Makefile",
"**/*.h",
"**/*.hpp",
"**/*.c",
"**/*.cpp",
"**/*.cu",
]
pull_request:
types: [opened, synchronize, reopened]
paths:
[
"**/CMakeLists.txt",
"**/Makefile",
"**/*.h",
"**/*.hpp",
"**/*.c",
"**/*.cpp",
"**/*.cu",
]
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true
jobs:
ubuntu-latest-rocm:
runs-on: ubuntu-latest
env:
ROCM_VERSION: "7.2"
GPU_TARGETS: "gfx1151;gfx1150;gfx1100;gfx1101;gfx1102;gfx1200;gfx1201"
steps:
- name: Clone
id: checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Free disk space
run: |
echo "Disk usage before cleanup:"
df -h /
# Remove preinstalled SDKs and caches not needed for this job
sudo rm -rf /usr/share/dotnet || true
sudo rm -rf /usr/local/lib/android || true
sudo rm -rf /opt/ghc || true
sudo rm -rf /usr/local/.ghcup || true
sudo rm -rf /opt/hostedtoolcache || true
# Remove old package lists and caches
sudo rm -rf /var/lib/apt/lists/* || true
sudo apt-get clean
echo "Disk usage after cleanup:"
df -h /
- name: Setup ROCm Repository
run: |
# Always setup ROCm repository (needed even when cache hits)
sudo apt-get update
sudo apt-get install -y wget gnupg2
# Add ROCm repository using modern GPG key handling
wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/rocm-archive-keyring.gpg
echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${{ env.ROCM_VERSION }}/ noble main" | sudo tee /etc/apt/sources.list.d/rocm.list
# Set ROCm repository to highest priority to avoid conflicts with Ubuntu packages
echo "Package: *" | sudo tee /etc/apt/preferences.d/rocm-pin
echo "Pin: origin repo.radeon.com" | sudo tee -a /etc/apt/preferences.d/rocm-pin
echo "Pin-Priority: 1001" | sudo tee -a /etc/apt/preferences.d/rocm-pin
sudo apt-get update
- name: Install ROCm
run: |
# Check if ROCm packages are available
echo "Checking ROCm package availability..."
apt-cache show rocm-dev hip-dev hipblas-dev || {
echo "ROCm packages not found, listing available packages:"
apt-cache search rocm | head -10
apt-cache search hip | head -10
}
# Check repository priorities
echo "Checking repository priorities..."
apt-cache policy hipcc rocm-cmake rocm-utils
# Install ROCm packages (APT preferences will ensure ROCm repo versions are used)
echo "Installing ROCm packages..."
sudo apt-get install -y \
rocm-dev \
hip-dev \
hipblas-dev \
ninja-build
# Clean apt caches to recover disk space
sudo apt-get 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
# 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 [[ ! "$file" =~ (gfx1151|gfx1150|gfx1100|gfx1101|gfx1102|gfx1200|gfx1201) ]]; then
rm -f "$file"
fi
done
cd /opt/rocm/lib/hipblaslt/library
for file in *; do
if [[ ! "$file" =~ (gfx1151|gfx1150|gfx1100|gfx1101|gfx1102|gfx1200|gfx1201) ]]; then
rm -f "$file"
fi
done
echo "Disk usage after ROCm cleanup:"
df -h /
- name: Build
id: cmake_build
run: |
mkdir build
cd build
cmake .. -G Ninja \
-DCMAKE_CXX_COMPILER=amdclang++ \
-DCMAKE_C_COMPILER=amdclang \
-DCMAKE_BUILD_TYPE=Release \
-DSD_HIPBLAS=ON \
-DGPU_TARGETS="${{ env.GPU_TARGETS }}" \
-DAMDGPU_TARGETS="${{ env.GPU_TARGETS }}" \
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DSD_BUILD_SHARED_LIBS=ON
cmake --build . --config Release
- name: Get commit hash
id: commit
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
uses: pr-mpt/actions-commit-hash@v2
- name: Prepare artifacts
id: prepare_artifacts
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
run: |
# Copy licenses
cp ggml/LICENSE ./build/bin/ggml.txt
cp LICENSE ./build/bin/stable-diffusion.cpp.txt
# Create directories for ROCm libraries
mkdir -p ./build/bin/rocblas/library
mkdir -p ./build/bin/hipblaslt/library
# Copy ROCm runtime libraries (use || true to continue if files don't exist)
cp /opt/rocm/lib/librocsparse.so* ./build/bin/ || true
cp /opt/rocm/lib/libhsa-runtime64.so* ./build/bin/ || true
cp /opt/rocm/lib/libamdhip64.so* ./build/bin/ || true
cp /opt/rocm/lib/libhipblas.so* ./build/bin/ || true
cp /opt/rocm/lib/libhipblaslt.so* ./build/bin/ || true
cp /opt/rocm/lib/librocblas.so* ./build/bin/ || true
# Copy library files (already filtered to target architectures)
cp /opt/rocm/lib/rocblas/library/* ./build/bin/rocblas/library/ || true
cp /opt/rocm/lib/hipblaslt/library/* ./build/bin/hipblaslt/library/ || true
- 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-rocm-x64
path: build/bin