Skip to content

Commit c8f7a8e

Browse files
committed
build: Enable ROCm(HIP) build release on Windows
1 parent c2d8ffc commit c8f7a8e

2 files changed

Lines changed: 271 additions & 40 deletions

File tree

.github/workflows/build.yml

Lines changed: 129 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,33 @@ on:
77
description: "Create new release"
88
required: true
99
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-
]
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+
# ]
3737

3838
env:
3939
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
@@ -164,8 +164,6 @@ jobs:
164164
defines: "-DGGML_NATIVE=OFF -DGGML_AVX512=ON -DGGML_AVX=ON -DGGML_AVX2=ON -DSD_BUILD_SHARED_LIBS=ON"
165165
- build: "cuda12"
166166
defines: "-DSD_CUDA=ON -DSD_BUILD_SHARED_LIBS=ON -DCMAKE_CUDA_ARCHITECTURES=90;89;86;80;75"
167-
# - build: "rocm5.5"
168-
# defines: '-G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DSD_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1100;gfx1102;gfx1030" -DSD_BUILD_SHARED_LIBS=ON'
169167
- build: 'vulkan'
170168
defines: "-DSD_VULKAN=ON -DSD_BUILD_SHARED_LIBS=ON"
171169
steps:
@@ -184,19 +182,12 @@ jobs:
184182
method: "network"
185183
sub-packages: '["nvcc", "cudart", "cublas", "cublas_dev", "thrust", "visual_studio_integration"]'
186184

187-
- name: Install rocm-toolkit
188-
id: rocm-toolkit
189-
if: ${{ matrix.build == 'rocm5.5' }}
190-
uses: Cyberhan123/rocm-toolkit@v0.1.0
185+
- name: ccache
186+
uses: ggml-org/ccache-action@v1.2.16
191187
with:
192-
rocm: "5.5.0"
188+
key: windows-latest-cmake-${{ matrix.build }}-${{ env.HIPSDK_INSTALLER_VERSION }}-x64
189+
evict-old-files: 1d
193190

194-
- name: Install Ninja
195-
id: install-ninja
196-
if: ${{ matrix.build == 'rocm5.5' }}
197-
uses: urkle/action-get-ninja@v1
198-
with:
199-
version: 1.11.1
200191
- name: Install Vulkan SDK
201192
id: get_vulkan
202193
if: ${{ matrix.build == 'vulkan' }} https://sdk.lunarg.com/sdk/download/1.4.328.1/windows/vulkansdk-windows-X64-1.4.328.1.exe
@@ -277,6 +268,103 @@ jobs:
277268
path: |
278269
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-${{ matrix.build }}-x64.zip
279270
271+
windows-latest-cmake-hip:
272+
runs-on: windows-2022
273+
274+
env:
275+
HIPSDK_INSTALLER_VERSION: "25.Q3"
276+
GPU_TARGETS: "gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032"
277+
278+
steps:
279+
- uses: actions/checkout@v3
280+
with:
281+
submodules: recursive
282+
283+
- name: Cache ROCm Installation
284+
id: cache-rocm
285+
uses: actions/cache@v4
286+
with:
287+
path: C:\Program Files\AMD\ROCm
288+
key: rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
289+
290+
- name: ccache
291+
uses: ggml-org/ccache-action@v1.2.16
292+
with:
293+
key: windows-latest-cmake-hip-${{ env.HIPSDK_INSTALLER_VERSION }}-x64
294+
evict-old-files: 1d
295+
296+
- name: Install ROCm
297+
if: steps.cache-rocm.outputs.cache-hit != 'true'
298+
run: |
299+
$ErrorActionPreference = "Stop"
300+
write-host "Downloading AMD HIP SDK Installer"
301+
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"
302+
write-host "Installing AMD HIP SDK"
303+
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
304+
$completed = $proc.WaitForExit(600000)
305+
if (-not $completed) {
306+
Write-Error "ROCm installation timed out after 10 minutes. Killing the process"
307+
$proc.Kill()
308+
exit 1
309+
}
310+
if ($proc.ExitCode -ne 0) {
311+
Write-Error "ROCm installation failed with exit code $($proc.ExitCode)"
312+
exit 1
313+
}
314+
write-host "Completed AMD HIP SDK installation"
315+
316+
- name: Verify ROCm
317+
run: |
318+
# Find and test ROCm installation
319+
$clangPath = Get-ChildItem 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Select-Object -First 1
320+
if (-not $clangPath) {
321+
Write-Error "ROCm installation not found"
322+
exit 1
323+
}
324+
& $clangPath.FullName --version
325+
# Set HIP_PATH environment variable for later steps
326+
echo "HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)" >> $env:GITHUB_ENV
327+
328+
- name: Build
329+
run: |
330+
mkdir build
331+
cd build
332+
$env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
333+
cmake .. `
334+
-G "Unix Makefiles" `
335+
-DGGML_NATIVE=OFF `
336+
-DCMAKE_C_COMPILER=clang `
337+
-DCMAKE_CXX_COMPILER=clang++ `
338+
-DCMAKE_BUILD_TYPE=Release `
339+
-DSD_HIPBLAS=ON `
340+
-DSD_BUILD_SHARED_LIBS=ON `
341+
-DGPU_TARGETS="${{ env.GPU_TARGETS }}"
342+
cmake --build . --config Release --parallel ${env:NUMBER_OF_PROCESSORS}
343+
344+
- name: Get commit hash
345+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
346+
uses: pr-mpt/actions-commit-hash@v2
347+
348+
- name: Pack artifacts
349+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
350+
run: |
351+
md "build\bin\rocblas\library\"
352+
md "build\bin\hipblaslt\library"
353+
cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
354+
cp "${env:HIP_PATH}\bin\hipblaslt.dll" "build\bin\"
355+
cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
356+
cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
357+
cp "${env:HIP_PATH}\bin\hipblaslt\library\*" "build\bin\hipblaslt\library\"
358+
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip .\build\bin\*
359+
360+
- name: Upload artifacts
361+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
362+
uses: actions/upload-artifact@v4
363+
with:
364+
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip
365+
path: |
366+
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip
367+
280368
release:
281369
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
282370

@@ -286,6 +374,7 @@ jobs:
286374
- ubuntu-latest-cmake
287375
- macOS-latest-cmake
288376
- windows-latest-cmake
377+
- windows-latest-cmake-hip
289378

290379
steps:
291380
- name: Clone

.github/workflows/rocm-build.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: ROCm Build
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+
jobs:
42+
windows-latest-cmake:
43+
runs-on: windows-2022
44+
45+
env:
46+
HIPSDK_INSTALLER_VERSION: "25.Q3"
47+
GPU_TARGETS: "gfx1151;gfx1200;gfx1201;gfx1100;gfx1101;gfx1102;gfx1030;gfx1031;gfx1032"
48+
49+
steps:
50+
- name: Clone
51+
id: checkout
52+
uses: actions/checkout@v3
53+
with:
54+
submodules: recursive
55+
56+
- name: Cache ROCm Installation
57+
id: cache-rocm
58+
uses: actions/cache@v4
59+
with:
60+
path: C:\Program Files\AMD\ROCm
61+
key: rocm-${{ env.HIPSDK_INSTALLER_VERSION }}-${{ runner.os }}
62+
63+
- name: ccache
64+
uses: ggml-org/ccache-action@v1.2.16
65+
with:
66+
key: windows-latest-cmake-hip-${{ env.HIPSDK_INSTALLER_VERSION }}-x64
67+
evict-old-files: 1d
68+
69+
- name: Install ROCm
70+
if: steps.cache-rocm.outputs.cache-hit != 'true'
71+
id: depends
72+
run: |
73+
$ErrorActionPreference = "Stop"
74+
write-host "Downloading AMD HIP SDK Installer"
75+
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"
76+
write-host "Installing AMD HIP SDK"
77+
$proc = Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -PassThru
78+
$completed = $proc.WaitForExit(600000)
79+
if (-not $completed) {
80+
Write-Error "ROCm installation timed out after 10 minutes. Killing the process"
81+
$proc.Kill()
82+
exit 1
83+
}
84+
if ($proc.ExitCode -ne 0) {
85+
Write-Error "ROCm installation failed with exit code $($proc.ExitCode)"
86+
exit 1
87+
}
88+
write-host "Completed AMD HIP SDK installation"
89+
90+
- name: Verify ROCm
91+
id: verify
92+
run: |
93+
# Find and test ROCm installation
94+
$clangPath = Get-ChildItem 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | Select-Object -First 1
95+
if (-not $clangPath) {
96+
Write-Error "ROCm installation not found"
97+
exit 1
98+
}
99+
& $clangPath.FullName --version
100+
echo "HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)" >> $env:GITHUB_ENV
101+
102+
103+
- name: Build
104+
id: cmake_build
105+
run: |
106+
mkdir build
107+
cd build
108+
$env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
109+
cmake .. `
110+
-G "Unix Makefiles" `
111+
-DCMAKE_C_COMPILER=clang `
112+
-DCMAKE_CXX_COMPILER=clang++ `
113+
-DCMAKE_BUILD_TYPE=Release `
114+
-DSD_HIPBLAS=ON `
115+
-DGPU_TARGETS="${{ env.GPU_TARGETS }}"
116+
cmake --build . --config Release --parallel ${env:NUMBER_OF_PROCESSORS}
117+
118+
- name: Get commit hash
119+
id: commit
120+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
121+
uses: pr-mpt/actions-commit-hash@v2
122+
123+
- name: Pack artifacts
124+
id: pack_artifacts
125+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
126+
run: |
127+
md "build\bin\rocblas\library\"
128+
md "build\bin\hipblaslt\library"
129+
cp "${env:HIP_PATH}\bin\hipblas.dll" "build\bin\"
130+
cp "${env:HIP_PATH}\bin\hipblaslt.dll" "build\bin\"
131+
cp "${env:HIP_PATH}\bin\rocblas.dll" "build\bin\"
132+
cp "${env:HIP_PATH}\bin\rocblas\library\*" "build\bin\rocblas\library\"
133+
cp "${env:HIP_PATH}\bin\hipblaslt\library\*" "build\bin\hipblaslt\library\"
134+
7z a sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip .\build\bin\*
135+
136+
- name: Upload artifacts
137+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip
141+
path: |
142+
sd-${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }}-bin-win-rocm-x64.zip

0 commit comments

Comments
 (0)