Library
AI Systemsadvanced3 min readNov 24, 2026

Ollama VRAM Budgeting

How to size context, quantisation and concurrency so inference fits in VRAM predictably.

The arithmetic

Weights, KV cache and activation overhead compete for the same pool. On a 32 GB card a 4-bit 27B model consumes roughly 16 GB of weights before any context — leaving little room, and KV cache grows linearly with context and concurrency.

Measure the baseline

nvidia-smi --query-gpu=memory.used,memory.total --format=csv -l 1

Load the model at your target context with one request and watch the high-water mark. That number, not the model size, is your budget.

Reduce KV cost first

KV cache dtype (fp16 to q8) usually recovers more headroom than dropping a quantisation level, and degrades quality less. Cap context at what the task actually needs.

Then consider offload

Partial CPU offload trades throughput for fit. Benchmark tokens/second at each split — the knee is usually sharper than expected.

Guard the ceiling

Set OLLAMA_MAX_LOADED_MODELS=1 and a concurrency limit at the proxy. Two simultaneous large models on one card is the commonest self-inflicted OOM.