Skip to content

Commit f43deaa

Browse files
committed
Fixed windows rocm build and changed all builds to be closer to the original sd.cpp builds
1 parent 9fd65e1 commit f43deaa

1 file changed

Lines changed: 173 additions & 34 deletions

File tree

.github/workflows/backends.yml

Lines changed: 173 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
mkdir build
102102
cd build
103103
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
104-
cmake .. -DSD_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES="61;75;86;89;100" -DSD_BUILD_SHARED_LIBS=ON
104+
cmake .. -DSD_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES="61;70;75;80;86;89;90;100;120" -DCMAKE_CUDA_FLAGS='-Xcudafe \"--diag_suppress=177\" -Xcudafe \"--diag_suppress=550\"'" -DSD_BUILD_SHARED_LIBS=ON
105105
cmake --build . --config Release
106106
107107
- name: Upload artifact
@@ -114,18 +114,53 @@ jobs:
114114
windows-hip:
115115
runs-on: windows-latest
116116

117-
steps:
118-
- name: Install
119-
id: depends
117+
env:
118+
HIPSDK_INSTALLER_VERSION: "25.Q3"
119+
GPU_TARGETS: "gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032"
120+
121+
steps:
122+
- name: Checkout
123+
id: checkout
124+
uses: actions/checkout@v4.2.2
125+
with:
126+
repository: 'leejet/stable-diffusion.cpp'
127+
ref: '${{ github.event.inputs.commit }}'
128+
submodules: recursive
129+
130+
- name: Cache ROCm Installation
131+
id: cache-rocm
132+
uses: actions/cache@v4
133+
with:
134+
path: C:\Program Files\AMD\ROCm
135+
key: rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
136+
137+
- name: ccache
138+
uses: ggml-org/ccache-action@v1.2.16
139+
with:
140+
key: windows-latest-cmake-hip-${{ env.HIPSDK_INSTALLER_VERSION }}-x64
141+
evict-old-files: 1d
142+
143+
- name: Install ROCm
144+
if: steps.cache-rocm.outputs.cache-hit != 'true'
120145
run: |
121146
$ErrorActionPreference = "Stop"
122147
write-host "Downloading AMD HIP SDK Installer"
123-
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-25.Q3-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
148+
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-${{ env.HIPSDK_INSTALLER_VERSION }}-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
124149
write-host "Installing AMD HIP SDK"
125-
Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
150+
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
151+
$completed = $proc.WaitForExit(600000)
152+
if (-not $completed) {
153+
Write-Error "ROCm installation timed out after 10 minutes. Killing the process"
154+
$proc.Kill()
155+
exit 1
156+
}
157+
if ($proc.ExitCode -ne 0) {
158+
Write-Error "ROCm installation failed with exit code $($proc.ExitCode)"
159+
exit 1
160+
}
126161
write-host "Completed AMD HIP SDK installation"
162+
127163
- name: Verify ROCm
128-
id: verify
129164
run: |
130165
# Find and test ROCm installation
131166
$clangPath = Get-ChildItem 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Select-Object -First 1
@@ -134,24 +169,24 @@ jobs:
134169
exit 1
135170
}
136171
& $clangPath.FullName --version
137-
138-
- name: Checkout
139-
id: checkout
140-
uses: actions/checkout@v4.2.2
141-
with:
142-
repository: 'leejet/stable-diffusion.cpp'
143-
ref: '${{ github.event.inputs.commit }}'
144-
submodules: recursive
172+
# Set HIP_PATH environment variable for later steps
173+
echo "HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)" >> $env:GITHUB_ENV
145174
146175
- name: Build
147-
id: cmake_build
148176
run: |
149-
$env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
150-
$env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
151177
mkdir build
152178
cd build
153-
cmake -G "Unix Makefiles" .. -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" -DGGML_HIP=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1100;gfx1101;gfx1030" -DGGML_RPC=ON -DSD_BUILD_SHARED_LIBS=ON
154-
cmake --build . --config Release
179+
$env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
180+
cmake .. `
181+
-G "Unix Makefiles" `
182+
-DSD_HIPBLAS=ON `
183+
-DSD_BUILD_SHARED_LIBS=ON `
184+
-DGGML_NATIVE=OFF `
185+
-DCMAKE_C_COMPILER=clang `
186+
-DCMAKE_CXX_COMPILER=clang++ `
187+
-DCMAKE_BUILD_TYPE=Release `
188+
-DGPU_TARGETS="${{ env.GPU_TARGETS }}"
189+
cmake --build . --config Release --parallel ${env:NUMBER_OF_PROCESSORS}
155190
156191
- name: Upload artifact
157192
id: upload_artifact
@@ -222,6 +257,12 @@ jobs:
222257
ref: '${{ github.event.inputs.commit }}'
223258
submodules: recursive
224259

260+
- name: Dependencies
261+
id: depends
262+
run: |
263+
sudo apt-get update
264+
sudo apt-get install build-essential
265+
225266
- name: Build
226267
id: cmake_build
227268
run: |
@@ -237,6 +278,39 @@ jobs:
237278
name: linux-${{ matrix.build }}
238279
path: ./build/bin/libstable-diffusion.so
239280

281+
linux-vulkan:
282+
runs-on: ubuntu-latest
283+
284+
steps:
285+
- name: Checkout
286+
id: checkout
287+
uses: actions/checkout@v4.2.2
288+
with:
289+
repository: 'leejet/stable-diffusion.cpp'
290+
ref: '${{ github.event.inputs.commit }}'
291+
submodules: recursive
292+
293+
- name: Dependencies
294+
id: depends
295+
run: |
296+
sudo apt-get update
297+
sudo apt-get install build-essential libvulkan-dev glslc
298+
299+
- name: Build
300+
id: cmake_build
301+
run: |
302+
mkdir build
303+
cd build
304+
cmake .. -DSD_BUILD_SHARED_LIBS=ON -DSD_VULKAN=ON
305+
cmake --build . --config Release
306+
307+
- name: Upload artifact
308+
id: upload_artifact
309+
uses: actions/upload-artifact@v4.6.1
310+
with:
311+
name: linux-vulkan
312+
path: ./build/bin/libstable-diffusion.so
313+
240314
linux-cuda12:
241315
runs-on: ubuntu-latest
242316
container: nvidia/cuda:12.8.0-devel-ubuntu24.04
@@ -313,31 +387,96 @@ jobs:
313387
path: ./build/bin/libstable-diffusion.so
314388

315389
linux-hip:
316-
runs-on: ubuntu-22.04
317-
container: rocm/dev-ubuntu-22.04:6.4.4
390+
runs-on: ubuntu-latest
391+
container: rocm/dev-ubuntu-24.04:7.2
392+
393+
env:
394+
ROCM_VERSION: "7.2"
395+
UBUNTU_VERSION: "24.04"
396+
GPU_TARGETS: "gfx1151;gfx1150;gfx1100;gfx1101;gfx1102;gfx1200;gfx1201"
318397

319398
steps:
320-
- name: Dependencies
321-
id: depends
322-
run: |
323-
sudo apt-get update
324-
sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev
325-
hipconfig
326-
399+
- run: apt-get update && apt-get install -y git
327400
- name: Clone
328401
id: checkout
329-
uses: actions/checkout@v4.2.2
402+
uses: actions/checkout@v6
330403
with:
331-
repository: 'leejet/stable-diffusion.cpp'
332-
ref: '${{ github.event.inputs.commit }}'
333404
submodules: recursive
334-
405+
406+
- name: Free disk space
407+
run: |
408+
# Remove preinstalled SDKs and caches not needed for this job
409+
sudo rm -rf /usr/share/dotnet || true
410+
sudo rm -rf /usr/local/lib/android || true
411+
sudo rm -rf /opt/ghc || true
412+
sudo rm -rf /usr/local/.ghcup || true
413+
sudo rm -rf /opt/hostedtoolcache || true
414+
415+
# Remove old package lists and caches
416+
sudo rm -rf /var/lib/apt/lists/* || true
417+
sudo apt clean
418+
419+
- name: Dependencies
420+
id: depends
421+
run: |
422+
sudo apt-get update
423+
sudo apt install -y \
424+
cmake \
425+
hip-dev \
426+
hipblas-dev \
427+
ninja-build \
428+
rocm-dev \
429+
zip
430+
# Clean apt caches to recover disk space
431+
sudo apt clean
432+
sudo rm -rf /var/lib/apt/lists/* || true
433+
434+
- name: Setup ROCm Environment
435+
run: |
436+
# Add ROCm to PATH for current session
437+
echo "/opt/rocm/bin" >> $GITHUB_PATH
438+
439+
# Build regex pattern from ${{ env.GPU_TARGETS }} (match target as substring)
440+
TARGET_REGEX="($(printf '%s' "${{ env.GPU_TARGETS }}" | sed 's/;/|/g'))"
441+
442+
# Remove library files for architectures we're not building for to save disk space
443+
echo "Cleaning up unneeded architecture files..."
444+
cd /opt/rocm/lib/rocblas/library
445+
# Keep only our target architectures
446+
for file in *; do
447+
if printf '%s' "$file" | grep -q 'gfx'; then
448+
if ! printf '%s' "$file" | grep -Eq "$TARGET_REGEX"; then
449+
echo "Removing $file" &&
450+
sudo rm -f "$file";
451+
fi
452+
fi
453+
done
454+
455+
cd /opt/rocm/lib/hipblaslt/library
456+
for file in *; do
457+
if printf '%s' "$file" | grep -q 'gfx'; then
458+
if ! printf '%s' "$file" | grep -Eq "$TARGET_REGEX"; then
459+
echo "Removing $file" &&
460+
sudo rm -f "$file";
461+
fi
462+
fi
463+
done
464+
335465
- name: Build
336466
id: cmake_build
337467
run: |
338468
mkdir build
339469
cd build
340-
cmake .. -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang" -DGGML_HIP=ON -DSD_BUILD_SHARED_LIBS=ON
470+
cmake .. -G Ninja \
471+
-DCMAKE_CXX_COMPILER=amdclang++ \
472+
-DCMAKE_C_COMPILER=amdclang \
473+
-DCMAKE_BUILD_TYPE=Release \
474+
-DSD_HIPBLAS=ON \
475+
-DGPU_TARGETS="${{ env.GPU_TARGETS }}" \
476+
-DAMDGPU_TARGETS="${{ env.GPU_TARGETS }}" \
477+
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
478+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
479+
-DSD_BUILD_SHARED_LIBS=ON
341480
cmake --build . --config Release
342481
343482
- name: Upload artifact Rocm

0 commit comments

Comments
 (0)