Skip to content

Commit 59ebdf0

Browse files
authored
chrore: enable Windows ROCm(HIP) build release (leejet#956)
* build: fix missing commit sha in macOS and Ubuntu build zip name The build workflows for macOS and Ubuntu incorrectly check for the "main" branch instead of "master" when retrieving the commit hash for naming the build artifacts. * build: correct Vulkan SDK installation condition in build workflow * build: Enable Windows ROCm(HIP) build release Refer to the build workflow of llama.cpp to add a Windows ROCm (HIP) build release to the workflow. Since there are many differences between the HIP build and other builds, this commit add a separate "windows-latest-cmake-hip" job, instead of enabling the ROCm matrix entry in the existing Windows build job. Main differences include: - Install ROCm SDK from AMD official installer. - Add a cache step for ROCm installation and a ccache step for build processing, since the HIP build takes much longer time than other builds. - Include the ROCm/HIP artifact in the release assets.
1 parent 4ffcbca commit 59ebdf0

File tree

1 file changed

+102
-18
lines changed

1 file changed

+102
-18
lines changed

.github/workflows/build.yml

Lines changed: 102 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
6666
- name: Get commit hash
6767
id: commit
68-
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) || github.event.inputs.create_release == 'true' }}
68+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
6969
uses: pr-mpt/actions-commit-hash@v2
7070

7171
- name: Fetch system info
@@ -118,7 +118,7 @@ jobs:
118118
119119
- name: Get commit hash
120120
id: commit
121-
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) || github.event.inputs.create_release == 'true' }}
121+
if: ${{ ( github.event_name == 'push' && github.ref == 'refs/heads/master' ) || github.event.inputs.create_release == 'true' }}
122122
uses: pr-mpt/actions-commit-hash@v2
123123

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

@@ -286,6 +369,7 @@ jobs:
286369
- ubuntu-latest-cmake
287370
- macOS-latest-cmake
288371
- windows-latest-cmake
372+
- windows-latest-cmake-hip
289373

290374
steps:
291375
- name: Clone

0 commit comments

Comments
 (0)