Ollama Memory Calculator
Will this model fit? Weights, KV cache and Ollama's default context, for your machine.
Short answer: a model in Ollama needs its download size, plus a KV cache that grows with the context length and with every parallel request, plus a few hundred MB to a few GB of working buffers. The KV cache is the part people miss. Ollama picks a 256K context by default on machines with plenty of GPU memory, so a small model can use many times its own size.
Weights KV cache Buffers Your GPU memory
Set it for Ollama:
Or pin this model's context in Ollama Herd, so every machine loads it the same way:
How the estimate works
Memory = download size + KV cache + buffers. The KV cache is the only part that changes with your settings:
- Per token, each attention layer stores a key and a value for every KV head: layers × KV heads × (key + value length) × 2 bytes at f16. For
qwen3-coder:30bthat is 48 × 4 × 256 × 2 = 96 KB per token. - Per parallel slot, the whole context is reserved again.
OLLAMA_NUM_PARALLEL=4means four KV caches. - Sliding-window layers (Gemma 3 and 4, gpt-oss) keep only the window plus one batch of tokens, so those models grow much more slowly with context. Hybrid models (Qwen 3.5, 3.6, 3.8) cache only their attention layers plus a fixed recurrent state, and Ollama runs them one request at a time. MLA models (GLM-4.7-Flash) cache one compressed row per layer.
- q8_0 and q4_0 KV caches store about 1.06 and 0.56 bytes per value instead of 2.
The calculator also follows Ollama's own rules, read from its source: the default context comes from GPU memory, a context is capped at the model's maximum, the batch size grows with context, and an automatic context that doesn't fit falls back from 256K to 32K to 4K. Buffers are a fit to the measured loads below. Models we haven't loaded are labelled as estimates.
Ollama's default context on your machine
Ollama picks the context from total GPU memory: 256K at 47 GiB or more, 32K from 23 GiB, otherwise 4K. On a Mac that is the GPU's share of unified memory (about two thirds on small Macs, three quarters above 32 GB), not the RAM on the box.
| Machine | GPU memory Ollama sees | Default context |
|---|---|---|
| Mac, 16 GB | about 11 GB | 4K |
| Mac, 24 GB | about 16 GB | 4K |
| Mac, 32 GB | about 21 GB | 4K |
| Mac, 36 GB | about 27 GB | 32K |
| Mac, 48 GB | about 36 GB | 32K |
| Mac, 64 GB | about 48 GB | 256K |
| Mac, 96 GB | about 72 GB | 256K |
| Mac, 128 GB | about 96 GB | 256K |
| Mac, 192 GB | about 144 GB | 256K |
| Mac, 256 GB | about 192 GB | 256K |
| Mac, 512 GB | about 384 GB | 256K |
| NVIDIA, 8 GB VRAM | 8 GB | 4K |
| NVIDIA, 12 GB VRAM | 12 GB | 4K |
| NVIDIA, 16 GB VRAM | 16 GB | 4K |
| NVIDIA, 24 GB VRAM | 24 GB | 32K |
| NVIDIA, 32 GB VRAM | 32 GB | 32K |
| NVIDIA, 48 GB VRAM | 48 GB | 256K |
| NVIDIA, 80 GB VRAM | 80 GB | 256K |
| CPU only | none | 4K |
Memory per model at common context lengths
One request at a time (OLLAMA_NUM_PARALLEL=1), default f16 KV cache, the default tag's download. Each extra parallel slot adds its own KV cache. A dash means the model's maximum context is shorter.
| Model | Download | 8K context | 32K context | 128K context |
|---|---|---|---|---|
Qwen2.5-Coder 1.5B qwen2.5-coder:1.5b | 1.0 GB | 1.6 GB | 2.6 GB | – |
Llama 3.2 1B llama3.2:1b | 1.3 GB | 2.0 GB | 3.0 GB | 7.4 GB |
Llama 3.2 3B llama3.2:3b | 2.0 GB | 3.3 GB | 6.4 GB | 18.8 GB |
Phi-3 Mini 3.8B (128k) phi3:3.8b | 2.2 GB | 5.8 GB | 15.7 GB | 55.5 GB |
Qwen3 4B (Thinking 2507) qwen3:4b | 2.5 GB | 4.1 GB | 8.0 GB | 23.6 GB |
Gemma 3 4B gemma3:4b | 3.3 GB | 4.1 GB | 4.9 GB | 8.2 GB |
Qwen2.5-Coder 7B qwen2.5-coder:7b | 4.7 GB | 5.5 GB | 7.2 GB | – |
Llama 3.1 8B llama3.1:8b | 4.9 GB | 6.4 GB | 9.8 GB | 23.9 GB |
DeepSeek-R1-0528-Qwen3 8B (distill) deepseek-r1:8b | 5.2 GB | 6.8 GB | 10.7 GB | 26.3 GB |
Qwen3 8B qwen3:8b | 5.2 GB | 6.8 GB | 10.7 GB | – |
Gemma 4 E4B gemma4:e4b | 6.6 GB | 7.1 GB | 7.8 GB | 10.6 GB |
Qwen3.5 9B qwen3.5:9b | 6.6 GB | 7.3 GB | 8.3 GB | 12.7 GB |
Mistral Nemo 12B (2407) mistral-nemo:12b | 7.1 GB | 8.8 GB | 13.1 GB | 30.3 GB |
Gemma 4 12B gemma4:12b | 7.6 GB | 8.7 GB | 9.4 GB | 12.5 GB |
Gemma 3 12B gemma3:12b | 8.2 GB | 9.7 GB | 11.6 GB | 19.5 GB |
DeepSeek-R1-Distill-Qwen 14B deepseek-r1:14b | 9.0 GB | 11.0 GB | 16.1 GB | 36.5 GB |
Qwen2.5-Coder 14B qwen2.5-coder:14b | 9.0 GB | 11.0 GB | 16.1 GB | – |
Phi-4 14B phi4:14b | 9.1 GB | 11.1 GB | – | – |
Qwen3 14B qwen3:14b | 9.3 GB | 11.0 GB | 15.3 GB | – |
Codestral 22B codestral:22b | 12.6 GB | 14.8 GB | 20.7 GB | – |
gpt-oss 20B gpt-oss:20b | 13.8 GB | 14.4 GB | 15.2 GB | 18.8 GB |
Devstral Small 24B (2505) devstral:24b | 14.3 GB | 16.0 GB | 20.3 GB | 37.6 GB |
Mistral Small 24B (2501) mistral-small | 14.3 GB | 16.0 GB | 20.3 GB | – |
Devstral Small 2 24B devstral-small-2:24b | 15.2 GB | 16.9 GB | 21.2 GB | 38.4 GB |
Gemma 3 27B gemma3:27b | 17.4 GB | 19.3 GB | 21.6 GB | 31.2 GB |
Qwen3.8 27B qwen3.8:27b | 17.7 GB | 20.6 GB | 22.6 GB | 30.5 GB |
Qwen3.6 27B qwen3.6:27b | 17.8 GB | 20.6 GB | 22.6 GB | 30.6 GB |
Gemma 4 26B-A4B gemma4:26b | 18.0 GB | 18.9 GB | 19.7 GB | 23.1 GB |
Qwen3-Coder 30B-A3B qwen3-coder:30b | 18.6 GB | 19.7 GB | 22.4 GB | 33.2 GB |
Qwen3 30B-A3B (Thinking 2507) qwen3:30b | 18.6 GB | 19.7 GB | 22.4 GB | 33.2 GB |
Command R 32B (08-2024) command-r:35b | 18.7 GB | 20.4 GB | 24.7 GB | 42.0 GB |
GLM-4.7-Flash 30B-A3B glm-4.7-flash | 19.0 GB | 19.8 GB | 21.4 GB | 27.9 GB |
DeepSeek-R1-Distill-Qwen 32B deepseek-r1:32b | 19.9 GB | 22.4 GB | 29.1 GB | 56.0 GB |
Qwen2.5-Coder 32B qwen2.5-coder:32b | 19.9 GB | 22.4 GB | 29.1 GB | – |
QwQ 32B qwq:32b | 19.9 GB | 22.4 GB | 29.1 GB | – |
Qwen3 32B qwen3:32b | 20.2 GB | 22.7 GB | 29.4 GB | – |
Gemma 4 31B gemma4:31b | 20.4 GB | 23.1 GB | 25.4 GB | 35.4 GB |
Qwen3.6 35B-A3B qwen3.6:35b-a3b | 22.6 GB | 24.6 GB | 25.4 GB | 28.8 GB |
DeepSeek-R1-Distill-Llama 70B deepseek-r1:70b | 42.5 GB | 45.6 GB | 53.9 GB | 87.2 GB |
Llama 3.3 70B llama3.3:70b | 42.5 GB | 45.6 GB | 53.9 GB | 87.2 GB |
Qwen2.5 72B qwen2.5:72b | 47.4 GB | 50.5 GB | 58.8 GB | – |
gpt-oss 120B gpt-oss:120b | 65.4 GB | 66.1 GB | 67.2 GB | 72.1 GB |
Command A 111B command-a | 67.1 GB | 69.0 GB | – | – |
Qwen3.5 122B-A10B qwen3.5:122b-a10b | 81.4 GB | 82.1 GB | 83.0 GB | 86.5 GB |
Qwen3 235B-A22B (Thinking 2507) qwen3:235b-a22b | 142 GB | 144 GB | 149 GB | 169 GB |
DeepSeek-R1 671B (0528) deepseek-r1:671b | 404 GB | 446 GB | 569 GB | 1061 GB |
DeepSeek-V3 671B deepseek-v3:671b | 404 GB | 446 GB | 569 GB | 1061 GB |
Measured, not guessed
We loaded each model in Ollama with a set context, parallel-slot count and KV type, and summed the KV, compute and output buffers llama-server reports for that load. Weights are the download size.
40 loads of 12 models on Ollama 0.40.3, Apple M4 Max, 128 GB, measured 2026-10-26. The KV cache column matches llama-server's own buffer sizes on every load; the largest error in the total is 3.1%.
| Model | Context | KV | KV cache (predicted / measured) | Total (predicted / measured) | Error |
|---|---|---|---|---|---|
llama3.2:3b | 128K (default) × 1 | f16 | 15.03 / 15.03 GB | 18.8 / 18.8 GB | +0.1% |
qwen3:8b | 40K (default) × 1 | f16 | 6.04 / 6.04 GB | 12.1 / 12.0 GB | +0.4% |
llama3.1:8b | 8K × 1 | f16 | 1.07 / 1.07 GB | 6.4 / 6.3 GB | +1.4% |
llama3.1:8b | 32K × 1 | f16 | 4.29 / 4.29 GB | 9.8 / 9.6 GB | +2.5% |
llama3.1:8b | 128K × 1 | f16 | 17.18 / 17.18 GB | 23.9 / 23.9 GB | -0.1% |
qwen3:8b | 8K × 1 | f16 | 1.21 / 1.21 GB | 6.8 / 6.7 GB | +1.7% |
qwen3:8b | 32K × 1 | f16 | 4.83 / 4.83 GB | 10.7 / 10.4 GB | +2.4% |
qwen3:8b | 40K × 1 | f16 | 6.04 / 6.04 GB | 12.1 / 12.0 GB | +0.4% |
gemma3:27b | 8K × 1 | f16 | 1.54 / 1.54 GB | 19.3 / 19.5 GB | -1.0% |
gemma3:27b | 32K × 1 | f16 | 3.56 / 3.56 GB | 21.6 / 21.7 GB | -0.5% |
gemma3:27b | 128K × 1 | f16 | 11.39 / 11.39 GB | 30.4 / 30.4 GB | +0.0% |
gpt-oss:20b | 8K × 1 | f16 | 0.23 / 0.23 GB | 14.4 / 14.3 GB | +0.9% |
gpt-oss:20b | 32K × 1 | f16 | 0.84 / 0.84 GB | 15.2 / 15.0 GB | +1.9% |
gpt-oss:20b | 128K × 1 | f16 | 3.28 / 3.28 GB | 18.8 / 18.7 GB | +1.0% |
glm-4.7-flash | 8K × 1 | f16 | 0.44 / 0.44 GB | 19.8 / 19.8 GB | +0.4% |
glm-4.7-flash | 32K × 1 | f16 | 1.77 / 1.77 GB | 21.4 / 21.2 GB | +1.0% |
gemma4:12b | 8K × 1 | f16 | 0.81 / 0.81 GB | 8.7 / 8.8 GB | -0.5% |
gemma4:12b | 32K × 1 | f16 | 1.21 / 1.21 GB | 9.4 / 9.3 GB | +1.2% |
gemma4:12b | 128K × 1 | f16 | 3.15 / 3.15 GB | 12.5 / 12.6 GB | -0.7% |
qwen3.5:9b | 8K × 1 | f16 | 0.32 / 0.32 GB | 7.3 / 7.5 GB | -2.9% |
qwen3.5:9b | 32K × 1 | f16 | 1.13 / 1.13 GB | 8.3 / 8.4 GB | -1.2% |
qwen3.5:9b | 128K × 1 | f16 | 4.35 / 4.35 GB | 12.7 / 13.1 GB | -3.1% |
qwen3.8:27b | 8K × 1 | f16 | 1.35 / 1.35 GB | 20.6 / 20.5 GB | +0.2% |
qwen3.8:27b | 32K × 1 | f16 | 3.07 / 3.07 GB | 22.6 / 22.6 GB | -0.3% |
qwen3-coder:30b | 8K × 1 | f16 | 0.81 / 0.81 GB | 19.7 / 19.6 GB | +0.8% |
qwen3-coder:30b | 32K × 1 | f16 | 3.22 / 3.22 GB | 22.4 / 22.1 GB | +1.4% |
qwen3-coder:30b | 128K × 1 | f16 | 12.88 / 12.88 GB | 33.2 / 33.0 GB | +0.7% |
deepseek-r1:70b | 8K × 1 | f16 | 2.68 / 2.68 GB | 45.6 / 45.7 GB | -0.3% |
deepseek-r1:70b | 32K × 1 | f16 | 10.74 / 10.74 GB | 53.9 / 53.9 GB | +0.0% |
qwen2.5-coder:7b | 32K × 1 | f16 | 1.88 / 1.88 GB | 7.2 / 7.0 GB | +2.8% |
llama3.1:8b | 32K × 1 | q8_0 | 2.28 / 2.28 GB | 7.8 / 7.6 GB | +3.0% |
gemma3:27b | 32K × 1 | q8_0 | 1.89 / 1.89 GB | 19.9 / 20.0 GB | -0.5% |
qwen3-coder:30b | 32K × 1 | q8_0 | 1.71 / 1.71 GB | 20.9 / 20.6 GB | +1.4% |
llama3.1:8b | 8K × 4 | f16 | 4.29 / 4.29 GB | 9.6 / 9.5 GB | +0.4% |
llama3.1:8b | 32K × 4 | f16 | 17.18 / 17.18 GB | 22.8 / 23.2 GB | -1.4% |
gemma3:27b | 8K × 4 | f16 | 6.17 / 6.17 GB | 23.9 / 24.3 GB | -1.4% |
gemma3:27b | 32K × 4 | f16 | 13.35 / 13.35 GB | 31.3 / 32.2 GB | -2.8% |
gpt-oss:20b | 32K × 4 | f16 | 3.45 / 3.45 GB | 18.0 / 18.1 GB | -0.5% |
qwen3.5:9b | 32K × 1 | f16 | 1.13 / 1.13 GB | 8.3 / 8.4 GB | -1.2% |
qwen3-coder:30b | 32K × 4 | f16 | 12.88 / 12.88 GB | 32.2 / 32.2 GB | -0.1% |
Every load here ran on Ollama's llama.cpp engine (llama-server), which runs GGUF models on every platform. On Apple Silicon, Ollama 0.40 and later run some models on its MLX engine instead; MLX allocates memory differently, and those runs are not covered.
When one machine isn't enough
If the model you want doesn't fit, or two models you use together don't fit side by side, a second machine is often cheaper than a bigger one. Ollama Herd puts several machines that each run Ollama behind one endpoint. It doesn't use this formula: once the fleet has loaded a model, it uses that model's real resident size to decide where it fits, and its kv_cache_bloat health check warns when the KV cache takes more than 30% of a machine's model memory. To keep a model's context the same on every machine, pin it with FLEET_NUM_CTX_OVERRIDES, as the calculator shows above.
Frequently asked questions
How much memory does a 70B model need in Ollama?
More than its download. deepseek-r1:70b is a 42.5 GB download and measured 45.7 GB loaded at an 8K context and 53.9 GB at 32K, with one request at a time and the default f16 KV cache. Every parallel slot adds its own KV cache on top.
Why does Ollama use more memory than the model's download size?
Because of the KV cache, which grows with the context length, and Ollama picks a large context by default on machines with a lot of GPU memory. On a 128 GB Mac, llama3.2:3b is a 2.0 GB download but measured 18.8 GB loaded, because Ollama gave it its full 128K context.
Does OLLAMA_NUM_PARALLEL use more memory?
Yes. Each parallel slot gets its own KV cache for the full context. llama3.1:8b at a 32K context measured 9.6 GB with one slot and 23.2 GB with four.
Does a q8_0 KV cache halve memory use?
It roughly halves the KV cache, not the model. q8_0 stores about 1.06 bytes per value instead of 2. llama3.1:8b at 32K went from a 4.3 GB to a 2.3 GB KV cache, and from 9.6 GB to 7.6 GB in total.
Is the size in ollama ps accurate?
Close for most models, but it counts only the GPU-side buffers, and on Ollama 0.40.3 it under-reported some sliding-window models badly: gemma3:27b showed 18.6 GB at a 128K context while llama-server's own buffers came to 30.4 GB. Leave headroom.
Related Reading
- How much RAM you need on a Mac: which Mac runs a 30B, 70B or 120B model
- Why the biggest models won't load: the GPU wired limit and
iogpu.wired_limit_mb - Ollama parallel requests:
OLLAMA_NUM_PARALLELand the queue - Local models tested on Apple Silicon