By the end of this guide you will be able to work out how much memory a model needs before you download it, and to read what a loaded model really takes. An 8 GB laptop is enough to start.
Who this is for, and what you need
This is for anyone choosing a model for a machine, or a machine for a model. It covers GGUF models run with Ollama or llama.cpp. It does not cover vLLM, MLX or image models, which allocate memory differently.
- A calculator.
- The model’s parameter count, layers and attention heads (Step 2 shows where to read them).
- Optional: Ollama, to compare the sum with what your machine loads.
Units matter here. llama.cpp prints MiB and GiB (1 GiB = 1.074 GB). ollama ps prints GB. A file of 4.58 GiB is 4.92 GB: same file. This post uses GB unless it says MiB.
Step 1: the weights
A model is a list of numbers. The quantisation says how many bits each one takes on average:
weights (GB) = parameters (billions) × bits per weight ÷ 8For Llama 3.1 8B (8.03 billion parameters) at Q4_K_M: 8.03 × 4.89 ÷ 8 = 4.91 GB. The file is 4.92 GB.
Bits per weight is not a constant of the format. Q4_K_M stores most tensors at 4 bits and some at 6, and the mix depends on the model. In our own quantisation run of a 7B, 169 tensors came out as Q4_K and 29 as Q6_K.
| Q4_K_M on | Bits per weight | Source |
|---|---|---|
| Llama 3.1 8B | 4.89 | llama.cpp quantize README (4.8944, read 2026-11-15); our load log prints the same |
| Qwen2.5 7B | 4.91 | printed by llama-quantize in our run of 2026-11-15, and by the load log |
| Mistral Small 24B | 4.86 | our load log, 2026-11-15 |
An earlier version of this post gave 4.85. We found no primary source for that figure. Use 4.9 for a quick sum. Q8_0 is 8.50 and FP16 is 16.00 in both the README and our logs.
Better still, skip the multiplication: the weights are the file size. Ollama’s library page and Hugging Face both show it. Files that bundle a vision encoder come out higher (our gemma4:26b prints 5.32 bits per weight). Which quantisation to pick is its own question: how to pick the right GGUF file.
Step 2: the context cache
While it works, the model stores two vectors (K and V) per token, in every layer. That is the KV cache. It does not depend on the quantisation of the file:
cache per token (bytes) = layers × KV heads × head dimension × 2 (K and V) × 2 (bytes at 16 bits)
cache (GB) = cache per token × context tokens × slots ÷ 1,000,000,000| Model | Layers | KV heads | Head dim | Bytes per token | Checked |
|---|---|---|---|---|---|
| Llama 3.1 8B | 32 | 8 | 128 | 131,072 | load log |
| Qwen2.5 7B | 28 | 4 | 128 | 57,344 | load log |
| Mistral Small 24B | 40 | 8 | 128 | 163,840 | load log |
| Qwen2.5 32B | 64 | 8 | 128 | 262,144 | config.json only |
| Llama 3.3 70B | 80 | 8 | 128 | 327,680 | config.json only |
“KV heads” is the number that matters, not attention heads. Llama 3.1 8B has 32 attention heads and 8 KV heads (grouped-query attention). Qwen2.5 7B has only 4, so its cache is less than half of Llama’s.
Where to read the three values, without leaving your terminal:
curl -s localhost:11434/api/show -d '{"model":"llama3.1:8b"}' | python3 -c "
import sys, json
for k, v in json.load(sys.stdin)['model_info'].items():
if any(t in k for t in ('block_count', 'head_count', 'embedding_length')): print(k, '=', v)"What it printed on our machine on 2026-11-15:
llama.attention.head_count = 32
llama.attention.head_count_kv = 8
llama.block_count = 32
llama.embedding_length = 4096Layers are block_count. Head dimension is embedding_length ÷ head_count: 4,096 ÷ 32 = 128. On Hugging Face the same values are num_hidden_layers, num_key_value_heads and head_dim in config.json.
So Llama 3.1 8B at 32,768 tokens: 131,072 × 32,768 = 4,294,967,296 bytes, 4.29 GB. More than the weights.
Step 3: multiply by the parallel slots
A server that answers several people at once keeps one context per slot. In Ollama the setting is OLLAMA_NUM_PARALLEL, and its FAQ says that parallel processing ends up “increasing the context size by the number of parallel requests”. The default is 1.
We can see it happen. Our second machine runs 8 slots. When we asked for Mistral Small with num_ctx 4096, Ollama started llama.cpp’s server like this (from its journal, 2026-11-15):
llama-server ... -c 32768 -np 8 ...
llama_context: n_seq_max = 8
llama_context: n_ctx_seq = 4096
llama_kv_cache: size = 5120.00 MiB ( 4096 cells, 40 layers, 8/8 seqs), K (f16): 2560.00 MiB, V (f16): 2560.00 MiBThe formula gives 163,840 × 4,096 × 8 = 5,368,709,120 bytes, which is 5,120 MiB exactly. In all 13 loads we checked, the formula and the log agree to the last MiB.
If you run llama.cpp’s server yourself, the convention is the other way round: -c is the total, and slots share it. Its README lists -np as “default: -1, -1 = auto” and a unified cache shared across slots as the default in that mode (read 2026-11-15). Check n_ctx_seq in your own log.
Step 4: add the compute buffers
llama.cpp also reserves working memory for the calculation itself. It is small, and it depends on the batch size Ollama picked more than on the model:
| Load (from our logs) | Batch | GPU compute buffer | Host compute buffer |
|---|---|---|---|
| Llama 3.1 8B, 4k, 1 slot | 512 | 112 MiB | 20 MiB |
| Llama 3.1 8B, 32k, 1 slot | 1,024 | 280 MiB | 96 MiB |
| Llama 3.1 8B, 16k × 8 slots | 2,048 | 496 MiB | 128 MiB |
| Mistral Small 24B, 4k × 8 slots | 1,024 | 448 MiB | 48 MiB |
| Mistral Small 24B, 8k × 8 slots | 2,048 | 912 MiB | 112 MiB |
Plan 0.5 GB for a small model and 1 GB for a larger one with many slots.
Worked examples, checked against real loads
These loads had already happened: our earlier benchmark runs and normal traffic. We read the lines llama.cpp printed back from journalctl -u ollama, added the GPU buffers, and compared with the size Ollama reported. Nothing was loaded to write this. Full table: load-log receipt. Machines: two DGX Spark (GB10, 128 GB unified), Ollama 0.30.10 and 0.34.0.
| Load | Model on GPU | KV cache | Compute | Sum | Ollama reported |
|---|---|---|---|---|---|
| Llama 3.1 8B Q4_K_M, 4k, 1 slot | 4,403.49 | 512.00 | 112.01 | 5,027.50 MiB = 5.27 GB | 5.27 GB |
| Llama 3.1 8B Q4_K_M, 32k, 1 slot | 4,403.49 | 4,096.00 | 280.02 | 8,779.51 MiB = 9.21 GB | 9.21 GB |
| Llama 3.1 8B Q4_K_M, 32k × 8 slots | 4,403.49 | 32,768.00 | 280.02 | 37,451.51 MiB = 39.27 GB | 39.27 GB |
| Qwen2.5 7B Q4_K_M, 32k, 1 slot | 4,168.09 | 1,792.00 | 328.02 | 6,288.11 MiB = 6.59 GB | 6.59 GB |
| Qwen2.5 7B FP16, 32k, 1 slot | 13,486.77 | 1,792.00 | 328.02 | 15,606.79 MiB = 16.36 GB | 16.36 GB |
| Mistral Small 24B Q4_K_M, 4k × 8 slots | 13,302.36 | 5,120.00 | 448.02 | 18,870.38 MiB = 19.79 GB | 19.79 GB |
| Mistral Small 24B Q4_K_M, 8k × 8 slots | 13,302.36 | 10,240.00 | 912.04 | 24,454.40 MiB = 25.64 GB | 25.64 GB |
Where Ollama’s size was recorded in bytes, the sum is within 2 bytes of it; elsewhere it matches to 0.01 GB. The reported sizes come from our earlier runs: num_ctx, quantisation speed, structured extraction, and Mistral Small at 4k and 8k.
Two things the table shows. The Q4_K_M and FP16 rows of Qwen2.5 7B have the same cache, to the MiB: quantisation does not touch it. And 8 slots turned a 9.21 GB load into a 39.27 GB one without changing the model.
What the spec sheet won’t tell you
ollama ps reports the GPU buffers, not everything the process holds. Three pieces sit outside it:
- The token embedding table stays on the host side. For Llama 3.1 8B that is 281.81 MiB; for Qwen2.5 7B at FP16, 1,039.50 MiB. This is why Ollama can report a loaded model smaller than its file.
- The host compute buffer, from the table in Step 4.
- The process itself. On 2026-11-15
nvidia-smishowed the one largellama-serverprocess at 8,993 MiB while its buffers added up to 8,779.51 MiB: 213 MiB more.nvidia-smidoes not name the model, so that pairing is our reading.
With every buffer counted, the 32k Llama load is 9.60 GB, not 9.21. On unified memory all of it comes out of the same pool.
Dedicated VRAM, shared memory and unified memory
A graphics card with its own VRAM. Everything in the “Sum” column must fit in it. Keep back what your desktop already uses.
Windows “shared GPU memory”. It is not extra VRAM. Microsoft’s DirectX team describes it as ordinary system memory that the GPU may borrow, up to half of physical RAM. NVIDIA drivers since 536.40 spill into it when VRAM runs out rather than crash, at lower speed, and NVIDIA documents how to turn that off per program. If a model is suddenly very slow on Windows, look there first.
Integrated GPUs have no VRAM of their own: all of it is shared system memory.
Apple silicon. One pool for CPU and GPU. macOS gives each GPU a recommended working-set limit (Apple’s Metal documentation), and Apple publishes no fixed fraction of RAM for it. Apple’s own MLX LM README shows how to raise the wired limit with sudo sysctl iogpu.wired_limit_mb=N on macOS 15 or later. We have not measured a Mac for this post.
Machines like ours (DGX Spark, GB10). Also one pool. NVIDIA’s known issues page says nvidia-smi cannot show memory use on it, and ours prints [N/A]. The model competes with everything else on the box, so the number to watch is MemAvailable in /proc/meminfo.
Fitting is not the same as running fast. Speed depends on memory bandwidth, where a dedicated card usually wins: see the hardware catalogue by budget.
Partial offload, and what it costs
If the sum does not fit, llama.cpp can put some layers on the GPU and run the rest on the CPU. Its server README lists -ngl (layers on the GPU) with default auto, and a --fit option, on by default, that adjusts unset arguments to the device memory. In ollama ps you see it as a split: the FAQ’s example is 48%/52% CPU/GPU.
The cost is speed: tokens pass through every layer, so the CPU layers set the pace. We have no number of our own for this. Every load in our logs is fully on the GPU (offloaded 33/33 layers to GPU). Before accepting a split, try in this order: less context, fewer slots, a smaller quantisation, a smaller model.
Read what a running model really uses
ollama psOn our main machine, 2026-11-15:
NAME ID SIZE PROCESSOR CONTEXT UNTIL
bge-m3:latest 790764642607 664 MB 100% GPU 8192 Forever
llama3.1:8b 4fc21a39517b 9.2 GB 100% GPU 32768 Forever
nomic-embed-text:latest 0a109f422b47 323 MB 100% GPU 2048 ForeverCONTEXT is per slot. If PROCESSOR is not 100% GPU, part of the model is on the CPU.
The load log has the detail. On Linux with systemd:
journalctl -u ollama --no-pager | grep -E "file size|model buffer size|llama_kv_cache: size|compute buffer size|n_ctx_seq|offloaded"For the 32k Llama load above it prints:
print_info: file size = 4.58 GiB (4.89 BPW)
load_tensors: offloaded 33/33 layers to GPU
load_tensors: CPU_Mapped model buffer size = 281.81 MiB
load_tensors: CUDA0 model buffer size = 4403.49 MiB
llama_context: n_ctx_seq = 32768
llama_kv_cache: size = 4096.00 MiB ( 32768 cells, 32 layers, 1/1 seqs), K (f16): 2048.00 MiB, V (f16): 2048.00 MiB
sched_reserve: CUDA0 compute buffer size = 280.02 MiB
sched_reserve: CUDA_Host compute buffer size = 96.02 MiBWith llama.cpp on its own, the same lines appear on the terminal when the server starts. On a dedicated NVIDIA card, confirm with:
nvidia-smi --query-gpu=memory.used,memory.total --format=csv
nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csvThe second command works on the GB10 too; the first does not.
The site’s calculator against these loads
The VRAM explorer used to run a simpler sum: a cache borrowed from a reference model, a flat 1.5 GB, and no slots. It came out up to 3.81 GB high at one slot and too low with several: 7.69 GB short for Mistral Small at 8k × 8. On 2026-11-16 we replaced it with the sum in this guide: each model’s own cache, times the slots you pick, plus an allowance for buffers (0.5 GB at one slot up to 24B; 1.1 GB otherwise). Here is how it compares:
| Load | Explorer | Ollama reported | Difference |
|---|---|---|---|
| Llama 3.1 8B Q4_K_M, 4k, 1 slot | 5.95 GB | 5.27 GB | 0.68 GB over |
| Llama 3.1 8B Q4_K_M, 32k, 1 slot | 9.70 GB | 9.21 GB | 0.49 GB over |
| Qwen2.5 7B Q4_K_M, 32k, 1 slot | 7.04 GB | 6.59 GB | 0.45 GB over |
| Mistral Small 24B Q4_K_M, 4k × 8 slots | 20.88 GB | 19.79 GB | 1.09 GB over |
| Mistral Small 24B Q4_K_M, 8k × 8 slots | 26.24 GB | 25.64 GB | 0.60 GB over |
It is always above, by 0.4 to 1.5 GB across the 13 loads, because it counts the whole file and Ollama only the part that goes to the GPU. The calculator on our product pages uses the same sum at one slot.
What fits in each memory size
Planning figures at Q4_K_M, 8k context, one slot, from the explorer’s sum: 6.48 GB for an 8B, 11.16 GB for a 14B, 23.30 GB for a 32B, 46.94 GB for a 70B. A card keeps 0.5 GB back; unified or system memory keeps 3 GB up to 16 GB, 4 GB up to 32 GB and 6 GB above. “Tight” means over 85% of what is left.
| Memory | Usable | 8B | 14B | 32B | 70B |
|---|---|---|---|---|---|
| 8 GB card | 7.5 GB | tight | no | no | no |
| 12 GB card | 11.5 GB | yes | tight | no | no |
| 16 GB card | 15.5 GB | yes | yes | no | no |
| 24 GB card | 23.5 GB | yes | yes | tight | no |
| 16 GB unified | 13 GB | yes | tight | no | no |
| 32 GB unified | 28 GB | yes | yes | yes | no |
| 64 GB unified | 58 GB | yes | yes | yes | yes |
The 32B on a 24 GB card is the instructive case. At 8k and one slot it fits with 0.2 GB to spare; a second slot adds 2.15 GB of cache and it is out. Context and slots decide. For which model to run in each row: best local LLMs by hardware and task.
The mistakes people make
- Counting only the file. At 32k, Llama 3.1 8B’s cache (4.29 GB) is nearly as large as its weights.
- Leaving the default context. Ollama’s context length page says the default follows your VRAM: 4k under 24 GiB, 32k from 24 to 48, 256k from 48 up (read 2026-11-15; its FAQ still says 4,096). By the formula, 256k on Llama 3.1 8B is 34.4 GB of cache per slot. Set
num_ctxyourself; we explain how, and the day this broke our second machine, in Ollama num_ctx memory usage, measured. - Forgetting the slots. See the 39.27 GB row.
- Sizing for the trained context. A model that accepts 128k tokens does not need 128k reserved. Count your real documents with the tokenizer.
- Mixing GiB and GB. A 7% error before you start.
- Expecting a longer prompt to use more memory. The cache is reserved in full at load. An empty chat and a full one cost the same.
- Ignoring what else is loaded. Other models, a desktop, a browser. Subtract them first.
When the simple formula does not apply
- Models that mix layer types. Our
gemma4:26bkeeps the full context in only 5 of its 30 layers; the other 25 keep a 1,536-token window. From 4k to 128k its reported size went from 17.20 to 18.36 GB. Ourqwen3.6:35bkeeps a cache in 10 of 40 layers. For these, load once and read the log. - Quantised cache. Ollama’s FAQ describes
OLLAMA_KV_CACHE_TYPE:q8_0uses about half the memory of the defaultf16,q4_0about a quarter, with some loss of precision. We have not tried it; our logs all sayK (f16). - Vision models add an encoder and its own compute buffer.
- Other engines and backends. Everything measured here is llama.cpp on CUDA under Ollama 0.30.10 and 0.34.0. GitHub listed v0.40.16 as the latest Ollama release on 2026-11-15, so compare with your own log.
One oddity for the record: for gemma4:26b the log shows two cache buffers, and the size Ollama reported matches the sum with only the second one. The 80 MiB of the first is missing from it.
Frequent questions
Is system RAM the same as VRAM for this sum? The sum is the same. On a card, it must fit in VRAM to run on the GPU; on unified memory, in whatever the system leaves free.
Does a smaller quantisation shrink the context cache? No. It shrinks the weights only.
Why does ollama ps show less than the file size? Part of the file stays on the host side and is not counted. Qwen2.5 7B at FP16 is a 15.24 GB file that reported 14.52 GB at 4k.
Can I run a model larger than my VRAM? Yes, with partial offload, more slowly. We have not measured by how much.
How much does one more user cost? One more slot: bytes per token × context. For Mistral Small at 8k, 1.34 GB each.
Limits
One hardware family, one engine, two Ollama versions. No Mac, no Windows, no dedicated card of our own in these numbers, no partial offload, no quantised cache. The per-process overhead is a single reading. The receipts are linked so you can check each figure.
Next steps
- Shortlist models for your memory in the VRAM explorer.
- See real loaded sizes for more models in our DGX Spark review after 7 weeks.
- A 24B worked through end to end: Mistral Small 24B, measured.
Let’s talk for 15 minutes
We run this sum with your team’s real documents and number of users, and measure it on hardware before recommending anything. If you want it for your company, ask for a 15-minute call or see how we work in consulting.