Skip to content

Commit 1b72943

Browse files
committed
Try to fix ROCm build
Signed-off-by: Molly Sophia <mollysophia379@gmail.com>
1 parent 2818c44 commit 1b72943

2 files changed

Lines changed: 47 additions & 12 deletions

File tree

.github/workflows/build.yml

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,8 @@ jobs:
186186
defines: '-DRWKV_AVX512=ON'
187187
- build: 'cuda12'
188188
defines: '-DRWKV_CUBLAS=ON'
189-
- build: 'rocm5.5'
190-
defines: '-G "Unix Makefiles" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DRWKV_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1100;gfx1102;gfx1030"'
191-
189+
- build: 'hip'
190+
defines: ''
192191
steps:
193192
- name: Clone
194193
id: checkout
@@ -206,25 +205,52 @@ jobs:
206205

207206
- name: Install rocm-toolkit
208207
id: rocm-toolkit
209-
if: ${{ matrix.build == 'rocm5.5' }}
210-
uses: Cyberhan123/rocm-toolkit@v0.1.0
211-
with:
212-
rocm: '5.5.0'
208+
if: ${{ matrix.build == 'hip' }}
209+
run: |
210+
$ErrorActionPreference = "Stop"
211+
write-host "Downloading AMD HIP SDK Installer"
212+
Invoke-WebRequest -Uri "https://download.amd.com/developer/eula/rocm-hub/AMD-Software-PRO-Edition-24.Q3-WinSvr2022-For-HIP.exe" -OutFile "${env:RUNNER_TEMP}\rocm-install.exe"
213+
write-host "Installing AMD HIP SDK"
214+
Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
215+
write-host "Completed AMD HIP SDK installation"
216+
217+
- name: Verify ROCm
218+
id: rocm-verify
219+
if: ${{ matrix.build == 'hip' }}
220+
run: |
221+
& 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
213222
214223
- name: Install Ninja
215224
id: install-ninja
216-
if: ${{ matrix.build == 'rocm5.5' }}
225+
if: ${{ matrix.build == 'hip' }}
217226
uses: urkle/action-get-ninja@v1
218227
with:
219228
version: 1.11.1
220229

230+
- name: Install ccache
231+
uses: hendrikmuhs/ccache-action@v1.2
232+
with:
233+
key: ${{ github.job }}
234+
221235
- name: Build
222236
id: cmake_build
237+
if: ${{ matrix.build != 'hip' }}
223238
run: |
224239
mkdir build
225240
cd build
226241
cmake .. ${{ matrix.defines }}
227-
cmake --build . --config Release
242+
cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
243+
244+
- name: Build-hip
245+
id: cmake_build_hip
246+
if: ${{ matrix.build == 'hip' }}
247+
run: |
248+
mkdir build
249+
cd build
250+
$env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
251+
$env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
252+
cmake .. -G "Unix Makefiles" -DCMAKE_C_COMPILER="${env:HIP_PATH}\bin\clang.exe" -DCMAKE_CXX_COMPILER="${env:HIP_PATH}\bin\clang++.exe" -DRWKV_HIPBLAS=ON -DGGML_HIP=ON -DCMAKE_BUILD_TYPE=Release
253+
cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
228254
229255
- name: Check AVX512F support
230256
id: check_avx512f
@@ -242,7 +268,7 @@ jobs:
242268
- name: Test
243269
id: cmake_test
244270
# Test AVX-512 only when possible
245-
if: ${{ (matrix.build != 'avx512' || env.HAS_AVX512F == '1') && matrix.build != 'cuda12' && matrix.build != 'rocm5.5'}}
271+
if: ${{ (matrix.build != 'avx512' || env.HAS_AVX512F == '1') && matrix.build != 'cuda12' && matrix.build != 'hip'}}
246272
run: |
247273
cd build
248274
ctest -C Release --verbose

CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ endfunction()
5858

5959
set(GGML_ACCELERATE ${RWKV_ACCELERATE})
6060
set(GGML_CUDA ${RWKV_CUBLAS})
61-
set(GGML_HIPBLAS ${RWKV_HIPBLAS})
61+
set(GGML_HIP ${RWKV_HIPBLAS})
6262
set(GGML_METAL ${RWKV_METAL})
6363
if (RWKV_OPENBLAS)
6464
set(GGML_BLAS_VENDOR "OpenBLAS")
@@ -235,7 +235,7 @@ if (GGML_METAL)
235235
)
236236
endif()
237237

238-
if (GGML_HIPBLAS)
238+
if (GGML_HIP)
239239
# CMake on Windows doesn't support the HIP language yet
240240
if (WIN32)
241241
set(CXX_IS_HIPCC TRUE)
@@ -272,6 +272,12 @@ endif()
272272
if (GGML_CUDA)
273273
set(RWKV_EXTRA_LIBS ${RWKV_EXTRA_LIBS} $<TARGET_OBJECTS:ggml-cuda>)
274274
endif()
275+
if (GGML_HIP)
276+
set(RWKV_EXTRA_LIBS ${RWKV_EXTRA_LIBS} $<TARGET_OBJECTS:ggml-hip>)
277+
endif()
278+
if (GGML_RPC)
279+
set(RWKV_EXTRA_LIBS ${RWKV_EXTRA_LIBS} $<TARGET_OBJECTS:ggml-rpc>)
280+
endif()
275281

276282
target_link_libraries(rwkv PRIVATE $<TARGET_OBJECTS:ggml> $<TARGET_OBJECTS:ggml-base> $<TARGET_OBJECTS:ggml-cpu> ${RWKV_EXTRA_LIBS})
277283

@@ -286,6 +292,9 @@ if (RWKV_BUILD_SHARED_LIBRARY)
286292
if (GGML_CUDA)
287293
set_target_properties(ggml-cuda PROPERTIES POSITION_INDEPENDENT_CODE ON)
288294
endif()
295+
if (GGML_HIP)
296+
set_target_properties(ggml-hip PROPERTIES POSITION_INDEPENDENT_CODE ON)
297+
endif()
289298

290299
target_compile_definitions(ggml PRIVATE GGML_SHARED GGML_BUILD)
291300
set_target_properties(rwkv PROPERTIES POSITION_INDEPENDENT_CODE ON)

0 commit comments

Comments
 (0)