How Much VRAM Do You Need to Run an LLM Locally?

 

The one formula that ends the guessing

Every "can my machine run this model?" question reduces to one equation:

Total memory ≈ weights + KV cache + overhead

The weights are fixed: parameter count times bytes per parameter. Full precision (FP16) costs 2 bytes per parameter. Quantization shrinks that: Q8_0 is about 1 byte per parameter, and Q4_K_M — the standard sweet spot for local inference — is about 0.57 bytes per parameter. A handy rule of thumb: ~0.6 GB of memory per billion parameters at 4-bit, plus 2–4 GB of headroom for context and runtime overhead.

The KV cache is the part people forget. During generation, the model stores attention keys and values for every token in the conversation, and that cache grows with context length. Its size follows another formula: 2 × layers × hidden dimension × context length × bytes per element. Longer chats need more memory — the same model that loads fine can run out of memory in the middle of a long conversation.

The cheat-sheet table

Applying the formula at Q4_K_M with modest context gives this practical map:

Model classMemory needed (Q4, 8K context)Hardware that fits
3–4B (Phi-4-mini class)~3–4 GBAlmost any 8GB+ machine
8B (Qwen3-8B, Llama 3.1 8B)~6–7 GB16GB Mac or PC, any 8GB GPU
13–14B (Qwen3-14B)~9–10 GB12GB GPU (RTX 4070 class)
27–35B (Qwen3-32B)~20–23 GB24GB GPU (RTX 3090/4090) or 48GB unified
70B class (Llama 3.3 70B)~47 GB (8K) / ~55 GB (32K)2× 24GB GPUs, or 64GB+ unified memory

At Q8 the weights roughly double; at full FP16 they roughly quadruple. This is why almost nobody runs large models unquantized at home — Q4_K_M loses only a few percent of quality while cutting memory by a factor of three.


Source: techtactician.com

Worked examples: three models people actually run

Qwen3-8B. 8 billion parameters × ~0.57 bytes = ~5 GB of weights. Add ~2 GB of KV cache and overhead and you land around 6–7 GB. It runs on an 8GB consumer GPU or a 16GB laptop without breaking a sweat.

Qwen3-32B. ~20 GB of weights at Q4. With an 8K context window you're at roughly 23 GB total — a 24GB RTX 3090 or 4090 fits it, but a 32K context pushes you past what a single 24GB card comfortably holds. This is the quality tier where local AI gets seriously good for coding and agent work, and also where VRAM planning starts to matter.

Llama 3.3 70B. ~43 GB of weights at Q4_K_M, plus ~4 GB of KV cache at 8K context (~12 GB at 32K) and overhead — roughly 47 GB at 8K, 55 GB at 32K. Three realistic ways to run it: two 24GB NVIDIA GPUs pooled together, a single 48GB+ workstation card with a modest context, or an Apple Silicon Mac with 64GB+ unified memory. A single 24GB GPU can only hold about half the model; the rest falls back to system RAM and speed collapses to a few tokens per second.

Step by step: size a model for your machine

  1. Check your available memory. On NVIDIA GPUs, run nvidia-smi in a terminal to see free VRAM. On a Mac, use Activity Monitor — but remember unified memory is shared with the OS and apps, so don't budget all of it.
  2. Pick the largest quant you can fit, not the largest model. A Q5 or Q6 version of a 32B model usually beats a Q3 version of a 70B model. Quality degrades noticeably below Q4, so prefer higher precision on a smaller model over starving a bigger one.
  3. Set your context budget honestly. RAG, agents and long documents need 32K+; casual chat is fine at 8K. Every extra thousand tokens of context adds cache memory — calculate it or use an online VRAM calculator before you buy hardware.
  4. Load it and watch. With Ollama, set OLLAMA_CONTEXT_LENGTH=32768 (or your chosen value) and run ollama run qwen3:32b; Ollama offloads as many layers as fit in VRAM automatically. With llama.cpp's llama-server, use --n-gpu-layers to control how much goes to the GPU and watch VRAM with nvidia-smi while prompting.

A note on Apple Silicon and unified memory

Macs with M-series chips are now a top-tier local AI platform, especially above 32B parameters, because unified memory acts as VRAM. An M3 Max with 64GB of unified memory can hold a 70B model at Q4 with a modest context — something no single consumer NVIDIA card can do. The trade-off is bandwidth: unified memory is slower than a discrete GPU's VRAM, so tokens per second lag behind an RTX 4090 class card, but the model actually fits, which is what matters most.



Source: lmstudioguide.com

When the model doesn't fit

You have four levers, in order of preference:

  • Shrink the context. It's the variable part of the equation. Halving context roughly halves the KV cache, and it costs nothing.
  • Drop one quant level. Q4_K_M to Q4_K_S, or Q5 to Q4 — each step frees a few gigabytes with minimal quality change.
  • Drop a size class. A 14B model at Q5 usually outperforms a starved 32B model at Q3, and it runs 2–3× faster.
  • Use partial CPU offload. llama.cpp can stream layers from system RAM, but expect 1–10 tokens/sec — fine for batch jobs, painful for chat. Treat it as a bridge, not a plan.

If nothing fits, that's what hosted APIs and cloud GPU rentals are for — our hosted vs self-hosted inference cost comparison walks through the break-even math.

Troubleshooting

"It loaded fine, then crashed mid-conversation." That's the KV cache outgrowing VRAM as context accumulates. Lower the context length or start a fresh chat.

"It's running but painfully slow." You're probably offloading to CPU or system RAM — the model doesn't fully fit in fast memory. Check nvidia-smi during generation.

"I want better quality without buying hardware." Move up one quant level on the same size class, or move up one size class at the same quant — but only if the math above says it fits.

The bottom line

VRAM sizing is arithmetic: ~0.6 GB per billion parameters at Q4, plus the KV cache for the context you'll actually use, plus headroom. 8GB runs the 8B class, 24GB runs the 32B class, and the 70B class needs 48GB+ of fast memory or 64GB of unified memory. Size the model to the machine before you buy anything — and if you want to see the software side, our guides to running an open model with Ollama, quantizing to GGUF and picking an inference engine are the natural next steps.



Comments

Popular posts from this blog

Open-Source AI Weekly: Bonsai, GigaChat 4 Lead

Claude Claims Proof of Riemann Hypothesis After 167 Years

How to Build an AI Agent with LangGraph in 30 Minutes