Skip to content

Commit

Permalink
Try to fix ROCm build
Browse files Browse the repository at this point in the history
Signed-off-by: Molly Sophia <[email protected]>
  • Loading branch information
MollySophia committed Jan 10, 2025
1 parent 2818c44 commit d913acc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
46 changes: 36 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ jobs:
defines: '-DRWKV_AVX512=ON'
- build: 'cuda12'
defines: '-DRWKV_CUBLAS=ON'
- build: 'rocm5.5'
defines: '-G "Unix Makefiles" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DRWKV_HIPBLAS=ON -DCMAKE_BUILD_TYPE=Release -DAMDGPU_TARGETS="gfx1100;gfx1102;gfx1030"'

- build: 'hip'
defines: ''
steps:
- name: Clone
id: checkout
Expand All @@ -206,25 +205,52 @@ jobs:

- name: Install rocm-toolkit
id: rocm-toolkit
if: ${{ matrix.build == 'rocm5.5' }}
uses: Cyberhan123/[email protected]
with:
rocm: '5.5.0'
if: ${{ matrix.build == 'hip' }}
run: |
$ErrorActionPreference = "Stop"
write-host "Downloading AMD HIP SDK Installer"
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"
write-host "Installing AMD HIP SDK"
Start-Process "${env:RUNNER_TEMP}\rocm-install.exe" -ArgumentList '-install' -NoNewWindow -Wait
write-host "Completed AMD HIP SDK installation"
- name: Verify ROCm
id: rocm-verify
if: ${{ matrix.build == 'hip' }}
run: |
& 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' --version
- name: Install Ninja
id: install-ninja
if: ${{ matrix.build == 'rocm5.5' }}
if: ${{ matrix.build == 'hip' }}
uses: urkle/action-get-ninja@v1
with:
version: 1.11.1

- name: Install ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ github.job }}

- name: Build
id: cmake_build
if: ${{ matrix.build != 'hip' }}
run: |
mkdir build
cd build
cmake .. ${{ matrix.defines }}
cmake --build . --config Release
cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
- name: Build-hip
id: cmake_build_hip
if: ${{ matrix.build == 'hip' }}
run: |
mkdir build
cd build
$env:HIP_PATH=$(Resolve-Path 'C:\Program Files\AMD\ROCm\*\bin\clang.exe' | split-path | split-path)
$env:CMAKE_PREFIX_PATH="${env:HIP_PATH}"
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 -DGGML_RPC=ON
cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS}
- name: Check AVX512F support
id: check_avx512f
Expand All @@ -242,7 +268,7 @@ jobs:
- name: Test
id: cmake_test
# Test AVX-512 only when possible
if: ${{ (matrix.build != 'avx512' || env.HAS_AVX512F == '1') && matrix.build != 'cuda12' && matrix.build != 'rocm5.5'}}
if: ${{ (matrix.build != 'avx512' || env.HAS_AVX512F == '1') && matrix.build != 'cuda12' && matrix.build != 'hip'}}
run: |
cd build
ctest -C Release --verbose
Expand Down
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ endfunction()

set(GGML_ACCELERATE ${RWKV_ACCELERATE})
set(GGML_CUDA ${RWKV_CUBLAS})
set(GGML_HIPBLAS ${RWKV_HIPBLAS})
set(GGML_HIP ${RWKV_HIPBLAS})
set(GGML_METAL ${RWKV_METAL})
if (RWKV_OPENBLAS)
set(GGML_BLAS_VENDOR "OpenBLAS")
Expand Down Expand Up @@ -235,7 +235,7 @@ if (GGML_METAL)
)
endif()

if (GGML_HIPBLAS)
if (GGML_HIP)
# CMake on Windows doesn't support the HIP language yet
if (WIN32)
set(CXX_IS_HIPCC TRUE)
Expand Down Expand Up @@ -269,10 +269,14 @@ target_compile_features(rwkv PUBLIC cxx_std_11)
if (GGML_METAL)
set(RWKV_EXTRA_LIBS ${RWKV_EXTRA_LIBS} $<TARGET_OBJECTS:ggml-metal> $<TARGET_OBJECTS:ggml-blas>)
endif()
if (GGML_CUDA)
if (GGML_CUDA OR GGML_HIP)
set(RWKV_EXTRA_LIBS ${RWKV_EXTRA_LIBS} $<TARGET_OBJECTS:ggml-cuda>)
endif()

if (GGML_RPC)
set(RWKV_EXTRA_LIBS ${RWKV_EXTRA_LIBS} $<TARGET_OBJECTS:ggml-rpc>)
endif()

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

if (RWKV_BUILD_SHARED_LIBRARY)
Expand Down

0 comments on commit d913acc

Please sign in to comment.