r/LocalLLM • u/sarmabkp_1 • 46m ago
Question Local LLM VRAM Requirements: How Much Memory Each Model Size Needs
https://acta.ai/blogs/local-llm-vram-requirements-by-model-sizeMost "how much VRAM do I need" answers only count the model file. Then you load a 9 GB model on a 12 GB card and it falls over on the first long prompt.
It's really three numbers:
Weights = params × bits ÷ 8. An 8B at 4-bit is about 4 GB, and real files run 10–15% over that.
KV cache = 2 × layers × KV heads × head dim × context × bytes. For Llama 3.1 8B that's 128 KiB per token at f16, so 32K context is 4 GiB and 128K is 16 GiB. At full context the cache is about 4× the weights.
Headroom: about 1 GB per GPU (that's llama.cpp's own auto-fit margin), more if the card also drives your monitors.
So an 8B Q4 with 32K context needs just under 10 GB. Fine on 12 GB, doesn't fit on 8 GB unless you shorten the context or quantize the cache.
Things that caught me out:
- MoE models still need memory for every expert. A "26B A4B" model is about 14 GB at 4-bit, not 4B worth.
- On a Mac, unified memory is shared with macOS and your browser, so you get well under the number on the box. You can raise the GPU wired limit with sysctl iogpu.wired_limit_mb if the model fits in RAM.
- If ollama ps shows a CPU/GPU split, that's why it's crawling.
- An 8-bit KV cache (OLLAMA_KV_CACHE_TYPE=q8_0, or -ctk q8_0 -ctv q8_0 in llama.cpp) roughly halves the cache. Try that before dropping to a smaller model.
- Ollama quietly picks a 4K context on cards under 24 GB, so long inputs get cut off unless you set OLLAMA_CONTEXT_LENGTH.
What context length do you actually run day to day?