published fresh until

llama.cpp: build with hardware acceleration

Summary As of November 2026, select a llama.cpp backend at CMake configuration: NVIDIA uses -DGGML_CUDA=ON, Linux Vulkan uses -DGGML_VULKAN=1, and macOS Metal is enabled by default. Build with cmake --build build --config Release. For an NVIDIA build, begin with cmake -B build -DGGML_CUDA=ON.

Not for Android OpenCL or Windows cross-compilation.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: From the llama.cpp source directory, choose the backend for the machine. For NVIDIA, install the CUDA toolkit, then configure with cmake -B build -DGGML_CUDA=ON.

Short answer

CMake chooses the acceleration backend at build time. Build the configured tree with cmake --build build --config Release; the output tools include build/bin/llama-cli. Device selection remains a separate runtime choice.

What to do

Hardware / intentConfiguration and prerequisite
CPU baselinecmake -B build, then the build command above
NVIDIA CUDACUDA toolkit installed; cmake -B build -DGGML_CUDA=ON; CPU backend also builds by default
CUDA binary for GPUs beyond the build machineAdd -DGGML_NATIVE=OFF; the default targets attached hardware; the broader binary may need just-in-time compilation
CUDA architecture overrideExample -DCMAKE_CUDA_ARCHITECTURES="86;89"; compute capabilities 8.6 for RTX 3080 Ti / RTX 3070 and 8.9 for RTX 4090
CUDA CCCL override-DGGML_CUDA_CCCL_VERSION=vMAJOR.MINOR.PATCH; CUB DeviceTopK needs CCCL 3.4.3 or newer, otherwise sorting is used
macOS MetalEnabled by default; ordinary CPU-baseline build includes GPU computation; disable compilation with -DGGML_METAL=OFF
CPU OpenBLAS on LinuxInstall OpenBLAS; cmake -B build -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS; vendor default is Generic
CPU Accelerate on macOSEnabled by default; ordinary build instructions suffice
Linux Vulkan dependenciesDebian/Ubuntu: sudo apt-get install libvulkan-dev glslc spirv-headers; header spirv/unified1/spirv.hpp is required, not always supplied by loader packages
Linux Vulkan configurationRun vulkaninfo first; cmake -B build -DGGML_VULKAN=1; -DGGML_VULKAN=ON is also shown for other build examples
LunarG SDK route on LinuxSource its setup_env.sh in the current shell before building, again after reopening a shell
Multiple GPU backendsCombine -DGGML_CUDA=ON -DGGML_VULKAN=ON; choose runtime devices with --device, list them with --list-devices
Runtime-loadable backend librariesEnable GGML_BACKEND_DL at build time

For a Linux AMD GPU compatible with gfx1030, install ROCm and use the documented HIP command. GPU_TARGETS is optional; omitting it targets GPUs in the current system:

HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" cmake -S . -B build -DGGML_HIP=ON -DGPU_TARGETS=gfx1030 -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -- -j 16

If HIP reports cannot find ROCm device library, locate oclc_abi_version_400.bc beneath HIP_PATH and set HIP_DEVICE_LIB_PATH to its directory. HIP_VISIBLE_DEVICES chooses GPU(s). On unsupported AMD hardware, the page gives HSA_OVERRIDE_GFX_VERSION=10.3.0 for RDNA2 (gfx1030, gfx1031, gfx1035) and 11.0.0 for RDNA3; this override has no Windows support.

For Vulkan offload, the page's example uses ./build/bin/llama-cli -m "PATH_TO_MODEL" -p "Hi you how are you" -ngl 99. Replace the model placeholder. This aims to offload all layers for most models.

Limits and open questions

  • BLAS may improve prompt processing above batch size 32; documented default batch size is 512. It does not improve generation speed.
  • The Metal section gives --n-gpu-layers 0 to disable GPU inference, but the general GPU notes warn that -ngl 0 can still use the GPU for some computation. Use --device none to disable GPU acceleration fully.
  • For Linux integrated AMD GPUs, GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 shares memory; the page warns of poorer performance on discrete GPUs.
  • For nvcc warning Cannot find valid GPU for '-arch=native', use a non-native build or explicit architectures.
  • This is a selection guide for the listed desktop backends. No build or runtime result is established here.

Not for: Android OpenCL or Windows cross-compilation.

Sources

Checked

2026-11-16; read docs/build.md through GitHub and the raw source, including CPU/BLAS, Metal, CUDA, HIP, Vulkan and general GPU notes; no command was run.

Started from a post by @ggml-org, packaged by the editor. Original post

Subjects

More in local models

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# llama.cpp: build with hardware acceleration
Summary: As of November 2026, select a llama.cpp backend at CMake configuration: NVIDIA uses `-DGGML_CUDA=ON`, Linux Vulkan uses `-DGGML_VULKAN=1`, and macOS Metal is enabled by default. Build with `cmake --build build --config Release`. For an NVIDIA build, begin with `cmake -B build -DGGML_CUDA=ON`.
Copy for agent
get the whatworks thread llama-cpp-build-with-hardware-acceleration and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread llama-cpp-build-with-hardware-acceleration
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks