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.

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:30b that is 48 × 4 × 256 × 2 = 96 KB per token.
  • Per parallel slot, the whole context is reserved again. OLLAMA_NUM_PARALLEL=4 means 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.

MachineGPU memory Ollama seesDefault context
Mac, 16 GBabout 11 GB4K
Mac, 24 GBabout 16 GB4K
Mac, 32 GBabout 21 GB4K
Mac, 36 GBabout 27 GB32K
Mac, 48 GBabout 36 GB32K
Mac, 64 GBabout 48 GB256K
Mac, 96 GBabout 72 GB256K
Mac, 128 GBabout 96 GB256K
Mac, 192 GBabout 144 GB256K
Mac, 256 GBabout 192 GB256K
Mac, 512 GBabout 384 GB256K
NVIDIA, 8 GB VRAM8 GB4K
NVIDIA, 12 GB VRAM12 GB4K
NVIDIA, 16 GB VRAM16 GB4K
NVIDIA, 24 GB VRAM24 GB32K
NVIDIA, 32 GB VRAM32 GB32K
NVIDIA, 48 GB VRAM48 GB256K
NVIDIA, 80 GB VRAM80 GB256K
CPU onlynone4K

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.

ModelDownload8K context32K context128K context
Qwen2.5-Coder 1.5B qwen2.5-coder:1.5b1.0 GB1.6 GB2.6 GB–
Llama 3.2 1B llama3.2:1b1.3 GB2.0 GB3.0 GB7.4 GB
Llama 3.2 3B llama3.2:3b2.0 GB3.3 GB6.4 GB18.8 GB
Phi-3 Mini 3.8B (128k) phi3:3.8b2.2 GB5.8 GB15.7 GB55.5 GB
Qwen3 4B (Thinking 2507) qwen3:4b2.5 GB4.1 GB8.0 GB23.6 GB
Gemma 3 4B gemma3:4b3.3 GB4.1 GB4.9 GB8.2 GB
Qwen2.5-Coder 7B qwen2.5-coder:7b4.7 GB5.5 GB7.2 GB–
Llama 3.1 8B llama3.1:8b4.9 GB6.4 GB9.8 GB23.9 GB
DeepSeek-R1-0528-Qwen3 8B (distill) deepseek-r1:8b5.2 GB6.8 GB10.7 GB26.3 GB
Qwen3 8B qwen3:8b5.2 GB6.8 GB10.7 GB–
Gemma 4 E4B gemma4:e4b6.6 GB7.1 GB7.8 GB10.6 GB
Qwen3.5 9B qwen3.5:9b6.6 GB7.3 GB8.3 GB12.7 GB
Mistral Nemo 12B (2407) mistral-nemo:12b7.1 GB8.8 GB13.1 GB30.3 GB
Gemma 4 12B gemma4:12b7.6 GB8.7 GB9.4 GB12.5 GB
Gemma 3 12B gemma3:12b8.2 GB9.7 GB11.6 GB19.5 GB
DeepSeek-R1-Distill-Qwen 14B deepseek-r1:14b9.0 GB11.0 GB16.1 GB36.5 GB
Qwen2.5-Coder 14B qwen2.5-coder:14b9.0 GB11.0 GB16.1 GB–
Phi-4 14B phi4:14b9.1 GB11.1 GB––
Qwen3 14B qwen3:14b9.3 GB11.0 GB15.3 GB–
Codestral 22B codestral:22b12.6 GB14.8 GB20.7 GB–
gpt-oss 20B gpt-oss:20b13.8 GB14.4 GB15.2 GB18.8 GB
Devstral Small 24B (2505) devstral:24b14.3 GB16.0 GB20.3 GB37.6 GB
Mistral Small 24B (2501) mistral-small14.3 GB16.0 GB20.3 GB–
Devstral Small 2 24B devstral-small-2:24b15.2 GB16.9 GB21.2 GB38.4 GB
Gemma 3 27B gemma3:27b17.4 GB19.3 GB21.6 GB31.2 GB
Qwen3.8 27B qwen3.8:27b17.7 GB20.6 GB22.6 GB30.5 GB
Qwen3.6 27B qwen3.6:27b17.8 GB20.6 GB22.6 GB30.6 GB
Gemma 4 26B-A4B gemma4:26b18.0 GB18.9 GB19.7 GB23.1 GB
Qwen3-Coder 30B-A3B qwen3-coder:30b18.6 GB19.7 GB22.4 GB33.2 GB
Qwen3 30B-A3B (Thinking 2507) qwen3:30b18.6 GB19.7 GB22.4 GB33.2 GB
Command R 32B (08-2024) command-r:35b18.7 GB20.4 GB24.7 GB42.0 GB
GLM-4.7-Flash 30B-A3B glm-4.7-flash19.0 GB19.8 GB21.4 GB27.9 GB
DeepSeek-R1-Distill-Qwen 32B deepseek-r1:32b19.9 GB22.4 GB29.1 GB56.0 GB
Qwen2.5-Coder 32B qwen2.5-coder:32b19.9 GB22.4 GB29.1 GB–
QwQ 32B qwq:32b19.9 GB22.4 GB29.1 GB–
Qwen3 32B qwen3:32b20.2 GB22.7 GB29.4 GB–
Gemma 4 31B gemma4:31b20.4 GB23.1 GB25.4 GB35.4 GB
Qwen3.6 35B-A3B qwen3.6:35b-a3b22.6 GB24.6 GB25.4 GB28.8 GB
DeepSeek-R1-Distill-Llama 70B deepseek-r1:70b42.5 GB45.6 GB53.9 GB87.2 GB
Llama 3.3 70B llama3.3:70b42.5 GB45.6 GB53.9 GB87.2 GB
Qwen2.5 72B qwen2.5:72b47.4 GB50.5 GB58.8 GB–
gpt-oss 120B gpt-oss:120b65.4 GB66.1 GB67.2 GB72.1 GB
Command A 111B command-a67.1 GB69.0 GB––
Qwen3.5 122B-A10B qwen3.5:122b-a10b81.4 GB82.1 GB83.0 GB86.5 GB
Qwen3 235B-A22B (Thinking 2507) qwen3:235b-a22b142 GB144 GB149 GB169 GB
DeepSeek-R1 671B (0528) deepseek-r1:671b404 GB446 GB569 GB1061 GB
DeepSeek-V3 671B deepseek-v3:671b404 GB446 GB569 GB1061 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%.

ModelContextKVKV cache (predicted / measured)Total (predicted / measured)Error
llama3.2:3b128K (default) × 1f1615.03 / 15.03 GB18.8 / 18.8 GB+0.1%
qwen3:8b40K (default) × 1f166.04 / 6.04 GB12.1 / 12.0 GB+0.4%
llama3.1:8b8K × 1f161.07 / 1.07 GB6.4 / 6.3 GB+1.4%
llama3.1:8b32K × 1f164.29 / 4.29 GB9.8 / 9.6 GB+2.5%
llama3.1:8b128K × 1f1617.18 / 17.18 GB23.9 / 23.9 GB-0.1%
qwen3:8b8K × 1f161.21 / 1.21 GB6.8 / 6.7 GB+1.7%
qwen3:8b32K × 1f164.83 / 4.83 GB10.7 / 10.4 GB+2.4%
qwen3:8b40K × 1f166.04 / 6.04 GB12.1 / 12.0 GB+0.4%
gemma3:27b8K × 1f161.54 / 1.54 GB19.3 / 19.5 GB-1.0%
gemma3:27b32K × 1f163.56 / 3.56 GB21.6 / 21.7 GB-0.5%
gemma3:27b128K × 1f1611.39 / 11.39 GB30.4 / 30.4 GB+0.0%
gpt-oss:20b8K × 1f160.23 / 0.23 GB14.4 / 14.3 GB+0.9%
gpt-oss:20b32K × 1f160.84 / 0.84 GB15.2 / 15.0 GB+1.9%
gpt-oss:20b128K × 1f163.28 / 3.28 GB18.8 / 18.7 GB+1.0%
glm-4.7-flash8K × 1f160.44 / 0.44 GB19.8 / 19.8 GB+0.4%
glm-4.7-flash32K × 1f161.77 / 1.77 GB21.4 / 21.2 GB+1.0%
gemma4:12b8K × 1f160.81 / 0.81 GB8.7 / 8.8 GB-0.5%
gemma4:12b32K × 1f161.21 / 1.21 GB9.4 / 9.3 GB+1.2%
gemma4:12b128K × 1f163.15 / 3.15 GB12.5 / 12.6 GB-0.7%
qwen3.5:9b8K × 1f160.32 / 0.32 GB7.3 / 7.5 GB-2.9%
qwen3.5:9b32K × 1f161.13 / 1.13 GB8.3 / 8.4 GB-1.2%
qwen3.5:9b128K × 1f164.35 / 4.35 GB12.7 / 13.1 GB-3.1%
qwen3.8:27b8K × 1f161.35 / 1.35 GB20.6 / 20.5 GB+0.2%
qwen3.8:27b32K × 1f163.07 / 3.07 GB22.6 / 22.6 GB-0.3%
qwen3-coder:30b8K × 1f160.81 / 0.81 GB19.7 / 19.6 GB+0.8%
qwen3-coder:30b32K × 1f163.22 / 3.22 GB22.4 / 22.1 GB+1.4%
qwen3-coder:30b128K × 1f1612.88 / 12.88 GB33.2 / 33.0 GB+0.7%
deepseek-r1:70b8K × 1f162.68 / 2.68 GB45.6 / 45.7 GB-0.3%
deepseek-r1:70b32K × 1f1610.74 / 10.74 GB53.9 / 53.9 GB+0.0%
qwen2.5-coder:7b32K × 1f161.88 / 1.88 GB7.2 / 7.0 GB+2.8%
llama3.1:8b32K × 1q8_02.28 / 2.28 GB7.8 / 7.6 GB+3.0%
gemma3:27b32K × 1q8_01.89 / 1.89 GB19.9 / 20.0 GB-0.5%
qwen3-coder:30b32K × 1q8_01.71 / 1.71 GB20.9 / 20.6 GB+1.4%
llama3.1:8b8K × 4f164.29 / 4.29 GB9.6 / 9.5 GB+0.4%
llama3.1:8b32K × 4f1617.18 / 17.18 GB22.8 / 23.2 GB-1.4%
gemma3:27b8K × 4f166.17 / 6.17 GB23.9 / 24.3 GB-1.4%
gemma3:27b32K × 4f1613.35 / 13.35 GB31.3 / 32.2 GB-2.8%
gpt-oss:20b32K × 4f163.45 / 3.45 GB18.0 / 18.1 GB-0.5%
qwen3.5:9b32K × 1f161.13 / 1.13 GB8.3 / 8.4 GB-1.2%
qwen3-coder:30b32K × 4f1612.88 / 12.88 GB32.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