Skip to content

Instantly share code, notes, and snippets.

@SteelPh0enix
Last active September 19, 2024 21:19
Show Gist options
  • Save SteelPh0enix/8651ed5a6ea571b1cd11b8c9fa47ac47 to your computer and use it in GitHub Desktop.
Save SteelPh0enix/8651ed5a6ea571b1cd11b8c9fa47ac47 to your computer and use it in GitHub Desktop.
Script for building llama.cpp under Windows for ROCm
REM execute via VS native tools command line prompt
REM make sure to clone the repo first, put this script next to the repo dir
REM this script is configured for building llama.cpp w/ ROCm support
REM for a system with Ryzen 9 5900X and RX 7900XT.
REM Unless you have the exact same setup, you may need to change some flags
REM and/or strings here.
set AMDGPU_TARGETS="gfx1100"
set HSA_OVERRIDE_GFX_VERSION="11.0.0"
set ROCM_VERSION="6.1.2"
set USE_ROCM=1
set ROCM_PATH=%HIP_PATH%
set CMAKE_MODULE_PATH=%HIP_PATH%cmake;%CMAKE_MODULE_PATH%
set CMAKE_PREFIX_PATH=%ROCM_PATH%;%CMAKE_PREFIX_PATH%
set PATH=%ROCM_PATH%bin;%PATH%
set LLAMA_CPP_PYTHON_VENV_PATH=%USERPROFILE%\.llama.cpp.venv
call %LLAMA_CPP_PYTHON_VENV_PATH%\Scripts\activate.bat
cd %HOMEPATH%\.llama.cpp
git clean -xddf
git pull
git submodule update --recursive
git lfs pull
REM update Python dependencies
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade sentencepiece transformers protobuf torch
REM you may want to enable CCACHE, i don't want it.
cmake -S . -B build -G Ninja^
-DCMAKE_BUILD_TYPE=Release^
-DCMAKE_CXX_COMPILER=clang++^
-DCMAKE_C_COMPILER=clang^
-DLLAMA_BUILD_TESTS=OFF^
-DLLAMA_BUILD_EXAMPLES=ON^
-DLLAMA_BUILD_SERVER=ON^
-DLLAMA_STANDALONE=ON^
-DLLAMA_CURL=OFF^
-DGGML_CCACHE=OFF^
-DGGML_NATIVE=ON^
-DGGML_LTO=ON^
-DGGML_AVX=ON^
-DGGML_AVX2=ON^
-DGGML_FMA=ON^
-DGGML_OPENMP=ON^
-DAMDGPU_TARGETS=%AMDGPU_TARGETS%^
-DGGML_HIPBLAS=ON^
-DGGML_CUDA_DMMV_X=1026^
-DGGML_CUDA_MMV_Y=64^
-DGGML_CUDA_GRAPHS=ON
cmake --build build --config Release --parallel 24
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment