Skip to content

fix(k8s): the ollama-64gib tier is OOMKilled when llama-server's prompt cache fills the node's memory #2382

Closed

Description

@dan-petty

Problem Description

The ollama-64gib pod restarted 5 times, and Kubernetes gives OOMKilled (exit 137) as the reason of the last restart (2026-10-27, 18:49 to 19:37 UTC). Each restart unloads the models of the ollama-64gib-standard tier, so the gateway fails or retries the calls in flight, and the next call waits for a model load.

The container has no memory limit (requests.memory: 8Gi, no limits), so the node ran out of memory. The node has 15.3 GiB of memory, and kubectl top node showed 79 % in use 3 minutes after the restart.

The last lines of the killed container are from llama-server, which Ollama 0.34.4 runs:

slot      release: id  0 | task 1434 | stop processing: n_tokens = 81367, truncated = 0
srv   prompt_save:  - saving prompt with length 81367, total state size = 3172.830 MiB (draft: 319.702 MiB)

llama-server saves the state of an idle slot into a prompt cache in host memory. Its default size limit is 8,192 MiB (--cache-ram, environment variable LLAMA_ARG_CACHE_RAM, llama.cpp tools/server/README.md). With OLLAMA_CONTEXT_LENGTH=160000, one saved prompt can take more than 3 GiB, so the cache can take half of the node's memory beside the model.

Reproduction Steps

  1. kubectl -n llm describe pod -l app.kubernetes.io/name=ollama-64gib | grep -A4 'Last State'
  2. kubectl -n llm logs <ollama-64gib-pod> --previous --tail=20
  3. Send long prompts (80k tokens) to qwen3.8:27b or gemma4:31b on the tier, one after another.

Expected vs Actual Behavior

  • Expected: the tier keeps its models loaded, and host memory stays below what the node has.
  • Actual: the node runs out of memory and Kubernetes kills Ollama.

Environment Diagnostics

devops-cli 0.7.1 (main at 69928b0). k8s/llm/profiles/ollama-profiles.yaml, tier ollama-64gib: image ollama/ollama:0.34.4, OLLAMA_CONTEXT_LENGTH=160000, OLLAMA_MAX_LOADED_MODELS=2, OLLAMA_KV_CACHE_TYPE=q8_0, no memory limit.

Questions to answer

  • Does Ollama 0.34.4 pass LLAMA_ARG_CACHE_RAM, or an OLLAMA_* setting, to llama-server? If it does, set a cache size that fits the node, and a memory limit on the container that names the real budget.
  • How much host memory does the tier use with no prompt cache: the model files that Ollama maps, the draft model and the CPU buffers?
  • Is the memory limit of the other tiers also unset?

Related

Activity

  1. added
    source/agent
    type/bug
    on Oct 27, 2026
  2. dan-petty commented on Oct 27, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/bug. The item fixes an OOM defect in the Ollama tier.
    • Priority: P1-High.
    • Value: High. It restores stable model serving for the tier.
    • Effort: Medium.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    source/agenttype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions