A model file can fit in system RAM while the server needs more memory to process prompts. When a llama.cpp CPU server on Linux is killed for running out of memory, reducing the context or loading a smaller model file can restore inference.
A container or service can hit its own memory limit even when the host has RAM to spare. Exit status 137 usually means SIGKILL. The kernel log or the server's memory cgroup can establish whether the Linux out-of-memory killer was responsible.
A smaller context reduces the memory reserved for the key-value (KV) cache. It also leaves fewer tokens for the prompt, conversation history, and generated response.
Steps to recover from a llama.cpp system-memory OOM kill on Linux:
- Confirm the out-of-memory kill at the time of the failed startup.
On a systemd host where you already have access to the kernel journal, substitute local times that bracket your failed launch. The query searches the current boot unless you specify another retained boot, such as with -b -1 for the previous boot.
$ journalctl -k --no-pager \ --since '2026-03-15 14:20:00' --until '2026-03-15 14:25:00' \ | grep -Ei 'out of memory: killed process [0-9]+ \(llama-server\)'
A matching entry should name llama-server as the victim at the time it exited. If you know the failed process ID, it should match too. No match leaves the cause unconfirmed.
On cgroup v2, a rise in oom_kill in the same server cgroup from before to after the exit can corroborate the kill. The path below applies when that cgroup is mounted at /sys/fs/cgroup/, such as inside a still-running container. On the host, the file is in the server's cgroup directory. A single reading is cumulative, a rise in a shared cgroup can count another process, and exit 137 alone leaves the cause unconfirmed.
$ grep '^oom_kill ' /sys/fs/cgroup/memory.events
- Identify the allocation driving memory use from the failed launch settings and server log.
KV cache or context initialization messages point to context pressure. An abrupt kill can leave only the last startup message, so a large configured context is a reason to try a smaller one with the same GGUF. If the log instead shows model-weight allocation failing, a smaller, lower-bit GGUF of the same model uses less memory for weights and may reduce output quality.
Related: How to quantize a GGUF model with llama.cpp - Relaunch the failed server with a smaller allocation.
For context pressure, change --ctx-size in the existing launch settings and keep the same GGUF, memory limit, and other launch options. The foreground example runs from the directory containing Qwen3-0.6B-Q8_0.gguf and lowers context from 40960 to 2048 tokens. Its loopback address and port stay the same. For weight pressure, the smaller GGUF file goes in the -m argument.
Related: How to start the llama.cpp server$ llama-server -m Qwen3-0.6B-Q8_0.gguf \ --ctx-size 2048 --threads 2 --parallel 1 \ --host 127.0.0.1 --port 8080
- Check server readiness from a second terminal.
$ curl -fsS http://127.0.0.1:8080/health {"status":"ok"}
HTTP 503 can occur while the model is loading. The ok response shows the server is ready to accept requests.
Related: How to check llama.cpp server health - Send a short completion request to the recovered server.
$ curl -fsS http://127.0.0.1:8080/completion \ --json '{"prompt":"The sky is","n_predict":6,"temperature":0}' {"index":0,"content":" blue, the ground is green", ##### snipped #####
The --json option requires curl 7.82.0 or later. A response with generated text in content and stop set to true confirms that inference finished. The wording can vary.