Serve an LLM with llama.cpp
A GGUF model behind an OpenAI-compatible API, in two commands.
llama.cpp runs quantised models fast on a single GPU and splits bigger ones across several. Its llama-server speaks the OpenAI API, so existing clients work unchanged.
Rent a machine with the llama-cpp image
Pick a machine whose GPU memory holds the model; see Choosing a GPU. A 12B model at 4-bit fits in 24 GB with room for a long context.
Start the server
-hf downloads the model from Hugging Face on the first run:
llama-server \
-hf ggml-org/gemma-3-12b-it-GGUF:Q4_K_M \
--host 127.0.0.1 --port 8080 \
-ngl 99 -c 16384The first start takes a few minutes while the model downloads (about 7 GB for this one). On an RTX 4090 we measured 98 tokens per second generating with it, using 17.8 GB of GPU memory (22 November 2026).
Prop
Type
Run it inside tmux so it keeps going when you disconnect; see Connecting.
Open a tunnel and call it
On your computer:
ssh -p 40122 -N -L 8080:localhost:8080 [email protected]Open http://localhost:8080 for the built-in chat, or call the API:
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Explain KV cache in one paragraph."}]}'Several GPUs
On a 2× or 4× machine, llama.cpp spreads the layers over all GPUs by default. Set the share per GPU with --tensor-split 1,1, or keep it to one with CUDA_VISIBLE_DEVICES=0.
On the Strix Halo machine
Build llama.cpp for Vulkan or ROCm instead; see AMD machines.