1+ name : ROCm Test
2+
3+ on :
4+ workflow_dispatch : # allows manual triggering
5+ inputs :
6+ create_release :
7+ description : " Create new release"
8+ required : true
9+ type : boolean
10+ push :
11+ branches :
12+ - master
13+ - ci
14+ paths :
15+ [
16+ " .github/workflows/**" ,
17+ " **/CMakeLists.txt" ,
18+ " **/Makefile" ,
19+ " **/*.h" ,
20+ " **/*.hpp" ,
21+ " **/*.c" ,
22+ " **/*.cpp" ,
23+ " **/*.cu" ,
24+ ]
25+ pull_request :
26+ types : [opened, synchronize, reopened]
27+ paths :
28+ [
29+ " **/CMakeLists.txt" ,
30+ " **/Makefile" ,
31+ " **/*.h" ,
32+ " **/*.hpp" ,
33+ " **/*.c" ,
34+ " **/*.cpp" ,
35+ " **/*.cu" ,
36+ ]
37+
38+ env :
39+ BRANCH_NAME : ${{ github.head_ref || github.ref_name }}
40+
41+ concurrency :
42+ group : ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
43+ cancel-in-progress : true
44+
45+ jobs :
46+ ubuntu-latest-rocm :
47+ runs-on : ubuntu-latest
48+
49+ env :
50+ ROCM_VERSION : " 7.2"
51+ GPU_TARGETS : " gfx1151;gfx1150;gfx1100;gfx1101;gfx1102;gfx1200;gfx1201"
52+
53+ steps :
54+ - name : Clone
55+ id : checkout
56+ uses : actions/checkout@v3
57+ with :
58+ submodules : recursive
59+
60+ - name : Cache ROCm Installation
61+ id : cache-rocm
62+ uses : actions/cache@v4
63+ with :
64+ path : /opt/rocm
65+ key : rocm-${{ env.ROCM_VERSION }}-${{ runner.os }}
66+
67+ - name : ccache
68+ uses : ggml-org/ccache-action@v1.2.16
69+ with :
70+ key : ubuntu-latest-rocm-${{ env.ROCM_VERSION }}-x64
71+ evict-old-files : 1d
72+
73+ - name : Setup ROCm Repository
74+ run : |
75+ # Always setup ROCm repository (needed even when cache hits)
76+ sudo apt-get update
77+ sudo apt-get install -y wget gnupg2
78+
79+ # Add ROCm repository using modern GPG key handling
80+ wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/rocm-archive-keyring.gpg
81+ echo "deb [arch=amd64] https://repo.radeon.com/rocm/apt/${{ env.ROCM_VERSION }}/ noble main" | sudo tee /etc/apt/sources.list.d/rocm.list
82+ sudo apt-get update
83+
84+ - name : Install ROCm
85+ if : steps.cache-rocm.outputs.cache-hit != 'true'
86+ run : |
87+ # Check if ROCm packages are available
88+ echo "Checking ROCm package availability..."
89+ apt-cache show rocm-dev hip-dev hipblas-dev || {
90+ echo "ROCm packages not found, listing available packages:"
91+ apt-cache search rocm | head -10
92+ apt-cache search hip | head -10
93+ }
94+
95+ # Install ROCm packages
96+ sudo apt-get install -y rocm-dev hip-dev hipblas-dev ninja-build
97+
98+ - name : Setup ROCm Environment
99+ run : |
100+ # Add ROCm to PATH for current session
101+ echo "/opt/rocm/bin" >> $GITHUB_PATH
102+
103+ - name : Verify ROCm Installation
104+ run : |
105+ # Verify ROCm installation
106+ if [ -f "/opt/rocm/bin/clang" ]; then
107+ echo "ROCm clang found at /opt/rocm/bin/clang"
108+ /opt/rocm/bin/clang --version
109+ else
110+ echo "ERROR: ROCm clang not found"
111+ ls -la /opt/rocm/bin/ || echo "ROCm bin directory not found"
112+ exit 1
113+ fi
114+
115+ # Test rocminfo if available
116+ if command -v rocminfo >/dev/null 2>&1; then
117+ echo "ROCm device info:"
118+ rocminfo | head -20 || echo "Warning: rocminfo failed, but continuing"
119+ else
120+ echo "rocminfo not available (expected in CI environment)"
121+ fi
122+
123+ - name : Build
124+ id : cmake_build
125+ run : |
126+ mkdir build
127+ cd build
128+ cmake .. -G Ninja \
129+ -DCMAKE_CXX_COMPILER=/opt/rocm/bin/clang++ \
130+ -DCMAKE_C_COMPILER=/opt/rocm/bin/clang \
131+ -DCMAKE_BUILD_TYPE=Release \
132+ -DGGML_HIPBLAS=ON \
133+ -DGGML_AVX2=ON \
134+ -DAMDGPU_TARGETS="${{ env.GPU_TARGETS }}" \
135+ -DSD_BUILD_SHARED_LIBS=ON
136+ cmake --build . --config Release
137+
138+ - name : Test ROCm Integration
139+ run : |
140+ cd build
141+ ./bin/sd --help || {
142+ echo "Binary execution failed. Checking dependencies..."
143+ ldd ./bin/sd || echo "ldd failed"
144+ ls -la ./bin/ || echo "bin directory listing failed"
145+ exit 1
146+ }
147+
148+ - name : Get commit hash
149+ id : commit
150+ if : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
151+ uses : pr-mpt/actions-commit-hash@v2
152+
153+ - name : Pack artifacts
154+ id : pack_artifacts
155+ if : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
156+ run : |
157+ # Copy licenses
158+ cp ggml/LICENSE ./build/bin/ggml.txt
159+ cp LICENSE ./build/bin/stable-diffusion.cpp.txt
160+
161+ # Create directories for ROCm libraries
162+ mkdir -p ./build/bin/rocblas/library
163+ mkdir -p ./build/bin/hipblaslt/library
164+
165+ # Copy ROCm runtime libraries (use || true to continue if files don't exist)
166+ cp /opt/rocm/lib/librocsparse.so* ./build/bin/ || true
167+ cp /opt/rocm/lib/libhsa-runtime64.so* ./build/bin/ || true
168+ cp /opt/rocm/lib/libamdhip64.so* ./build/bin/ || true
169+ cp /opt/rocm/lib/libhipblas.so* ./build/bin/ || true
170+ cp /opt/rocm/lib/libhipblaslt.so* ./build/bin/ || true
171+ cp /opt/rocm/lib/librocblas.so* ./build/bin/ || true
172+ cp /opt/rocm/lib/rocblas/library/* ./build/bin/rocblas/library/ || true
173+ cp /opt/rocm/lib/hipblaslt/library/* ./build/bin/hipblaslt/library/ || true
174+
175+ # Create archive
176+ tar -czf sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-linux-rocm-x64.tar.gz -C ./build/bin .
177+
178+ - name : Upload artifacts
179+ if : ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
180+ uses : actions/upload-artifact@v4
181+ with :
182+ name : sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-linux-rocm-x64.tar.gz
183+ path : |
184+ sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-linux-rocm-x64.tar.gz
0 commit comments