To rebuild llama.cpp with Vulkan support instead of HIP, you need to clean your existing build and reconfigure it with the appropriate Vulkan flags. Here's how to do it:
Cleaning the Existing Build
First, clean your existing build to ensure a fresh start:
cd llama.cpp
rm -rf build
# OR on Windows
# rmdir /s /q build
Installing Vulkan Dependencies
Before rebuilding, make sure you have the necessary Vulkan dependencies installed:
-
On Ubuntu/Debian:
sudo apt-get install libvulkan-dev glslang-tools
-
On Fedora:
sudo dnf install vulkan-devel glslc glslang
-
On Windows:
Install the Vulkan SDK
Rebuilding with Vulkan Support
Now rebuild llama.cpp with Vulkan support:
Using CMake (Recommended)
cmake -B build -DGGML_VULKAN=ON
cmake --build build --config Release
You can add other options as needed:
cmake -B build -DGGML_VULKAN=ON -DLLAMA_BUILD_SERVER=ON -DLLAMA_BUILD_EXAMPLES=ON
cmake --build build --config Release -j$(nproc)
Using Make (Alternative)
If you prefer using make directly:
make clean
GGML_VULKAN=1 make -j$(nproc)
Verifying Vulkan Support
After building, you can verify Vulkan support is enabled by running:
./build/bin/llama-cli --help
You should see Vulkan-related options listed.
When running a model, check if Vulkan is detected:
./build/bin/llama-cli -m your-model.gguf -ngl 99
You should see output like:
ggml_vulkan: Found X Vulkan devices:
ggml_vulkan: 0 = [Your GPU Name] | uma: X | fp16: X | ...
Troubleshooting
If you encounter build errors:
-
Ensure all submodules are updated:
git submodule update --init --recursive
-
If you continue to have issues, you might need to do a completely fresh clone:
cd ..
rm -rf llama.cpp
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
git submodule update --init --recursive
-
For specific Vulkan shader compilation issues (as seen in search result [1]), you may need to specify a different Vulkan version:
cmake -B build -DGGML_VULKAN=ON -DGGML_VULKAN_TARGET=vulkan1.2
The build process should generate all the necessary binaries with Vulkan support enabled, which you can then use to run inference on your GPU[3][5][9].