12GB VRAM: 8 Models, 3 Quants, Which GGUF Fits at 8k and 16k
A 12 GB card looks big enough for an 8B model at Q8 by file size, then runs out of memory at 16k context because the cache alone takes 2.42 GB.
📜 Table of Contents
A 12 GB card runs a 7B model at Q8 and a 12.5B model at Q5 and still has room, while a 14B at Q4 does not run at 8k context. Those verdicts come from three numbers: the weight file, the KV cache, and the memory the runtime keeps for itself. Repo listings only give you the first.
The three numbers, for one concrete file
Take Qwen2.5-7B-Instruct at Q4_K_M. The GGUF file is 4,683,074,240 bytes, which the HF API reports exactly. At 4k context the KV cache is 0.23 GB. The runtime needs roughly another gigabyte for the CUDA context, compute buffers and allocator slack. That adds up to 5.91 GB, and the card is 12.
| number | where it comes from | Qwen2.5-7B Q4_K_M |
|---|---|---|
| weights | byte count of the .gguf file, HF API blobs=true | 4.68 GB |
| KV cache | config.json fields, formula below, fp16, 4k context | 0.23 GB |
| runtime reserve | assumption: 1.0 GB headroom on a 12 GB card | 1.00 GB |
| total to plan for | sum | 5.91 GB |
Where the file sizes came from
Every size below is the exact byte count returned by the Hugging Face model API with blobs=true on 2026-11-24, not the rounded figure on the model page. The GB column divides by 1e9, so it reads smaller than the GiB your file manager shows.
| model | GGUF repository | Q4_K_M bytes | GB |
|---|---|---|---|
| Qwen2.5-7B-Instruct | bartowski/Qwen2.5-7B-Instruct-GGUF | 4,683,074,240 | 4.68 |
| Qwen2.5-Coder-7B-Instruct | bartowski/Qwen2.5-Coder-7B-Instruct-GGUF | 4,683,074,336 | 4.68 |
| DeepSeek-R1-Distill-Qwen-7B | bartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF | 4,683,073,504 | 4.68 |
| Mistral-7B-Instruct-v0.3 | bartowski/Mistral-7B-Instruct-v0.3-GGUF | 4,372,812,000 | 4.37 |
| Llama-3.1-8B-Instruct | bartowski/Meta-Llama-3.1-8B-Instruct-GGUF | 4,920,739,232 | 4.92 |
| Qwen3-8B | unsloth/Qwen3-8B-GGUF | 5,027,784,512 | 5.03 |
| gemma-3-12b-it | unsloth/gemma-3-12b-it-GGUF | 7,300,778,336 | 7.30 |
| Qwen2.5-14B-Instruct | bartowski/Qwen2.5-14B-Instruct-GGUF | 8,988,110,976 | 8.99 |
The four Qwen-family 7B files land within 832 bytes of each other, so architecture differences barely move the weight size. What moves the total is the head count, below.
The second number: KV cache per token
Per token, per layer, the cache holds a key and a value for every KV head. In fp16 that is 2 x kv_heads x head_dim x 2 bytes, multiplied by the layer count and the context length. Every field is in the model's own config.json.
| model | layers | heads | KV heads | head_dim | KiB per token |
|---|---|---|---|---|---|
| Qwen2.5-7B-Instruct | 28 | 28 | 4 | 128 | 56 |
| Qwen2.5-Coder-7B-Instruct | 28 | 28 | 4 | 128 | 56 |
| DeepSeek-R1-Distill-Qwen-7B | 28 | 28 | 4 | 128 | 56 |
| Mistral-7B-Instruct-v0.3 | 32 | 32 | 8 | 128 | 128 |
| Llama-3.1-8B-Instruct | 32 | 32 | 8 | 128 | 128 |
| Qwen3-8B | 36 | 32 | 8 | 128 | 144 |
| gemma-3-12b-it | 48 | 16 | 8 | 256 | 512, global layers only |
| Qwen2.5-14B-Instruct | 48 | 40 | 8 | 128 | 192 |
Two 7B models sit 2.3x apart: Qwen2.5-7B keeps 4 KV heads per layer, Mistral-7B-v0.3 keeps 8. head_dim is absent from the Qwen config files, so it is hidden_size divided by heads, 3584/28 = 128 and 5120/40 = 128. Gemma-3 states head_dim 256 directly, and its 48 layers would cost 512 KiB a token if every layer held the full context.
They do not. gemma-3-12b-it sets sliding_window 1024 with a pattern of 6, so five of every six layers only hold the last 1,024 tokens and one in six holds the whole thing. At 16k context that is 1.41 GB instead of 6.44 GB. The per-token figures for the other seven models match the KV cache table published three days ago, which is a useful cross-check: 56 KiB for Qwen2.5-7B, 128 KiB for Mistral-7B.
The third number: the reserve
The gigabyte reserved here is an assumption, not a measurement. On a 12 GB card with a desktop attached, 11.0 GB is roughly what a process can hold before the driver starts reshuffling or the compositor drops out. On a headless card with a small batch, 0.5 GB may hold; push batch or context and 1.5 GB may not be enough. Every verdict below moves with that one number, so treat the totals as a budget you adjust rather than a spec sheet.
The table for a 12 GB card
Verdict is Y when file plus fp16 KV plus the 1.0 GB reserve stays at or under 11.0 GB. The figure next to it is the total to plan for.
| model / quant | 4k | 8k | 16k |
|---|---|---|---|
| Qwen2.5-7B Q4_K_M | Y 5.91 | Y 6.15 | Y 6.62 |
| Qwen2.5-7B Q5_K_M | Y 6.67 | Y 6.91 | Y 7.38 |
| Qwen2.5-7B Q8_0 | Y 9.33 | Y 9.57 | Y 10.04 |
| Qwen3-8B Q4_K_M | Y 6.63 | Y 7.24 | Y 8.45 |
| Qwen3-8B Q5_K_M | Y 7.45 | Y 8.06 | Y 9.27 |
| Qwen3-8B Q8_0 | Y 10.31 | Y 10.92 | n 12.13 |
| Llama-3.1-8B Q4_K_M | Y 6.46 | Y 6.99 | Y 8.07 |
| Llama-3.1-8B Q5_K_M | Y 7.27 | Y 7.80 | Y 8.88 |
| Llama-3.1-8B Q8_0 | Y 10.08 | Y 10.61 | n 11.69 |
| Mistral-7B-v0.3 Q4_K_M | Y 5.91 | Y 6.44 | Y 7.52 |
| Mistral-7B-v0.3 Q8_0 | Y 9.24 | Y 9.77 | Y 10.85 |
| gemma-3-12b-it Q4_K_M | Y 8.90 | Y 9.17 | Y 9.71 |
| gemma-3-12b-it Q5_K_M | Y 10.05 | Y 10.32 | Y 10.86 |
| gemma-3-12b-it Q8_0 | n 14.11 | n 14.38 | n 14.92 |
| Qwen2.5-14B Q4_K_M | Y 10.80 | n 11.60 | n 13.21 |
| Qwen2.5-14B Q5_K_M | n 12.32 | n 13.12 | n 14.73 |
Qwen2.5-Coder-7B and DeepSeek-R1-Distill-Qwen-7B share every number with Qwen2.5-7B, since they are the same 28-layer, 4-KV-head shape.
Three cases where the file size misleads
Qwen3-8B at Q8_0. 8.71 GB of weights on a 12 GB card reads as safe. It is safe at 8k, where the total lands at 10.92 GB, and it fails at 16k, where the cache alone reaches 2.42 GB. Same file, same card, one flag apart.
Qwen2.5-14B at Q4_K_M. 8.99 GB of weights, and it does fit at 4k: 10.80 GB. At 8k the cache adds 1.61 GB and the plan crosses to 11.60 GB. Load it at 8k anyway and llama.cpp moves layers back to system RAM, which works and is slow. The overflow is quiet, which is why the arithmetic matters more than the verdict.
gemma-3-12b-it. Half again the parameters of Qwen3-8B, yet Q5_K_M at 16k needs 10.86 GB while Qwen3-8B Q8_0 at 16k needs 12.13 GB. The window does the work: 1.41 GB of cache at 16k instead of 6.44. The trade is real. Those five local layers cannot see past the last 1,024 tokens, and whether that hurts your task is a question this table cannot answer. Image input adds mmproj-F16.gguf at 854,200,448 bytes, another 0.85 GB the table above does not include.
If it does not fit, cheapest fix first
- Quantise the cache, not the weights. An fp16-to-q8_0 cache halves it: Qwen3-8B at 16k drops from 2.42 GB to 1.21 GB, total 10.92, weights untouched. q4_0 halves it again to 0.60 GB, at a quality cost you should measure on your own prompts rather than assume.
- Cut context. Qwen3-8B Q8_0 passes at 8k and fails at 16k. Most agent loops never need 16k of resident history, and summarising old turns buys the same memory back for free.
- Step down one quant. Qwen3-8B Q5_K_M at 16k is 9.27 GB against 12.13 for Q8_0, and both fit at 8k.
- Offload layers last. It converts a memory problem into a speed problem, and the speed depends on your PCIe and CPU, so it is not something this table can predict.
The container side of the same problem, including why a container silently falls back to CPU, is in the Ollama in Docker write-up. What the quant names mean is in the quantisation explainer, and a bare-metal systemd setup is in the Linux server walk-through.
What this does not cover
No GPU produced any figure here, so nothing in this post is a speed claim. Quality after quantisation was not tested: the numbers say what fits, not what is good. Batch size and parallel slots multiply the cache by the number of slots, and no total above includes that. Vision on gemma needs the extra mmproj file. And the reserve is an assumption you should replace with your own card's behaviour.
FAQ
Does a 12 GB card run a 14B model? At Q4_K_M yes at 4k context, planning 10.80 GB, and no at 8k at 11.60 GB. At Q5_K_M it is over budget even at 4k.
Why is Q4_K_M 4.68 GB for one 7B model and 4.37 GB for another? The quantisation block layout follows the architecture, and files carry different amounts of vocabulary and embedding. These two 7B files differ by 310 MB while their shapes differ more: Qwen2.5-7B is 28 layers with 4 KV heads, Mistral-7B-v0.3 is 32 layers with 8.
Is a q8_0 KV cache safe? It is the usual choice when memory is tight and it halves the cache exactly. Whether it changes your answers you can only settle by running your own prompts both ways.
How do I get my own numbers? Read the .gguf byte count from the HF API with blobs=true, read layers, heads, kv_heads and head_dim from config.json, apply 2 x kv_heads x head_dim x 2 bytes x layers x context, then add your reserve.
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.