New Tool Radar

Local AI

How to Keep the KV Cache in RAM with llama-server –cache-ram

Use llama-server --cache-ram to keep the KV cache in system RAM on machines with limited VRAM.

Schematic illustration with three step boxes: Check free RAM; Start with the flag; Watch a long chat.

On a machine with a small GPU, the KV cache can spill or grow until the server slows down. The –cache-ram flag tells llama-server to keep the cache in system RAM instead of GPU memory, which trades some speed for room. This guide starts the server with the flag and checks a long conversation.

Before you start

  • llama.cpp installed, with llama-server on your PATH.
  • A GGUF model file, for example a Qwen3 8B Q4_K_M file.
  • At least 16 GB of system RAM, so the cache has somewhere to go.

Check free memory first

Look at free RAM before starting:

free -h

On macOS, use Activity Monitor. You want several gigabytes free after the model itself loads.

Start the server with the flag

Start the server with the cache in RAM:

llama-server -m qwen3-8b-q4_k_m.gguf --cache-ram --port 8080

The server prints its startup lines; the cache now lives in system RAM.

Hold a long conversation

Send a long document and ask several follow-up questions through the chat endpoint. The conversation should keep working further into the context than it did with the cache on the GPU, at a small speed cost per token.

Worked example

Worked example: paste a 10,000-word manual into the chat and ask eight follow-up questions about it. With –cache-ram, the server should still answer the eighth question without evicting the early context; without the flag, the same conversation on a small GPU may slow down or drop context sooner.

Expected result

UNTESTED in this guide: no server was run while writing it. The expected result is that the server starts with the flag and a long conversation stays coherent further into the context.

Limitations

RAM is slower than VRAM, so each token may take slightly longer. The flag does not help if system RAM is also full; in that case, shorten the context or use a smaller model.

Sources

See all