12GB VRAM: 8 Models, 3 Quants, Which GGUF Fits at 8k and 16k

🔧 AI Tools 2026-11-24 8 min read

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.

numberwhere it comes fromQwen2.5-7B Q4_K_M
weightsbyte count of the .gguf file, HF API blobs=true4.68 GB
KV cacheconfig.json fields, formula below, fp16, 4k context0.23 GB
runtime reserveassumption: 1.0 GB headroom on a 12 GB card1.00 GB
total to plan forsum5.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.

modelGGUF repositoryQ4_K_M bytesGB
Qwen2.5-7B-Instructbartowski/Qwen2.5-7B-Instruct-GGUF4,683,074,2404.68
Qwen2.5-Coder-7B-Instructbartowski/Qwen2.5-Coder-7B-Instruct-GGUF4,683,074,3364.68
DeepSeek-R1-Distill-Qwen-7Bbartowski/DeepSeek-R1-Distill-Qwen-7B-GGUF4,683,073,5044.68
Mistral-7B-Instruct-v0.3bartowski/Mistral-7B-Instruct-v0.3-GGUF4,372,812,0004.37
Llama-3.1-8B-Instructbartowski/Meta-Llama-3.1-8B-Instruct-GGUF4,920,739,2324.92
Qwen3-8Bunsloth/Qwen3-8B-GGUF5,027,784,5125.03
gemma-3-12b-itunsloth/gemma-3-12b-it-GGUF7,300,778,3367.30
Qwen2.5-14B-Instructbartowski/Qwen2.5-14B-Instruct-GGUF8,988,110,9768.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.

modellayersheadsKV headshead_dimKiB per token
Qwen2.5-7B-Instruct2828412856
Qwen2.5-Coder-7B-Instruct2828412856
DeepSeek-R1-Distill-Qwen-7B2828412856
Mistral-7B-Instruct-v0.332328128128
Llama-3.1-8B-Instruct32328128128
Qwen3-8B36328128144
gemma-3-12b-it48168256512, global layers only
Qwen2.5-14B-Instruct48408128192

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 / quant4k8k16k
Qwen2.5-7B Q4_K_MY 5.91Y 6.15Y 6.62
Qwen2.5-7B Q5_K_MY 6.67Y 6.91Y 7.38
Qwen2.5-7B Q8_0Y 9.33Y 9.57Y 10.04
Qwen3-8B Q4_K_MY 6.63Y 7.24Y 8.45
Qwen3-8B Q5_K_MY 7.45Y 8.06Y 9.27
Qwen3-8B Q8_0Y 10.31Y 10.92n 12.13
Llama-3.1-8B Q4_K_MY 6.46Y 6.99Y 8.07
Llama-3.1-8B Q5_K_MY 7.27Y 7.80Y 8.88
Llama-3.1-8B Q8_0Y 10.08Y 10.61n 11.69
Mistral-7B-v0.3 Q4_K_MY 5.91Y 6.44Y 7.52
Mistral-7B-v0.3 Q8_0Y 9.24Y 9.77Y 10.85
gemma-3-12b-it Q4_K_MY 8.90Y 9.17Y 9.71
gemma-3-12b-it Q5_K_MY 10.05Y 10.32Y 10.86
gemma-3-12b-it Q8_0n 14.11n 14.38n 14.92
Qwen2.5-14B Q4_K_MY 10.80n 11.60n 13.21
Qwen2.5-14B Q5_K_Mn 12.32n 13.12n 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

  1. 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.
  2. 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.
  3. 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.
  4. 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.

Related Articles
2026-08-12
AI Evaluation Tools 2026: 8 Open Source Frameworks for Measuring LLM Quality
2026-08-20
Best Free AI Writing Tools in 2026: 7 Options That Work Without a Credit Card
2026-07-25
Best Ai Music Generator Free in 2026: Top 10 Tools Compared
2026-08-25
Best AI Translation Tool in Baku 2026: 6 Tools for Business & the Oil Sector
2026-08-29
Best AI Social Media Generator in Gold Coast 2026: 6 Tools for Tourism Businesses
2026-07-19
AI API Gateway Comparison: Unified Management for Multiple AI Models

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.

💬 Comments (0)

No comments yet. Be the first!

Login to comment