Building llama.cpp from source gives you the latest tools and the backend your hardware needs, such as Metal on macOS or CUDA on NVIDIA. The build uses CMake and produces the binaries in a build/bin folder.
What you need
- Git and CMake installed, plus a C++ compiler
- About 2 GB of free disk space for the source and build
- A terminal in a working folder
Step 1: Clone the source
Run git clone https://github.com/ggml-org/llama.cpp and enter the folder with cd llama.cpp. The converter scripts and the build docs live in this checkout.
Step 2: Configure for your backend
For a CPU-only build run cmake -B build. On macOS, Metal is enabled by default; add -DGGML_METAL=OFF to disable it. On NVIDIA, add -DGGML_CUDA=ON; for Vulkan, add -DGGML_VULKAN=ON.
Step 3: Build and verify
Run cmake –build build –config Release. When it finishes, the tools are in build/bin/. Confirm with ./build/bin/llama-cli –help, which should print the tool options without an error.
Worked example: CPU build on Linux
The table below is a synthetic example. The CMake commands come from the llama.cpp build docs; the paths are the documented ones.
| Step | Command | Expected result |
|---|---|---|
| Clone | git clone https://github.com/ggml-org/llama.cpp | Source downloaded |
| Configure | cmake -B build | Build files created |
| Build | cmake –build build –config Release | Binaries in build/bin/ |
Expected result (UNTESTED). the build finishes without errors and ./build/bin/llama-cli –help prints the tool options. This check was not run live; the commands come from the cited build docs.
Limits
- A full build takes several minutes and needs a working compiler.
- CUDA builds need the CUDA toolkit installed first.
- Metal is macOS-only; a Linux build cannot enable it.
- Prebuilt release binaries exist for users who do not need a custom build.
