How Much VRAM Do You Need for AI Models? (2026 Calculator)
Some links in this article are affiliate links. We earn a commission at no extra cost to you when you purchase through them. Full disclosure.
The #1 question before running a local model: will it fit? Hereβs the formula and a quick reference for every popular model.
The formula
VRAM needed β (Parameters Γ Bytes per parameter) + Context overhead
| Quantization | Bytes per parameter | Example: 24B model |
|---|---|---|
| FP16 (full) | 2 bytes | 48 GB |
| Q8_0 | 1 byte | 24 GB |
| Q5_K_M | 0.65 bytes | 15.6 GB |
| Q4_K_M | 0.5 bytes | 12 GB |
| Q3_K_M | 0.4 bytes | 9.6 GB |
Context overhead: Add ~1-4 GB depending on context length. A 64K context window adds ~2 GB. A 128K context adds ~4 GB.
Detailed VRAM calculation
For a more precise estimate, use this expanded formula:
Total VRAM = Model weights + KV cache + Activation memory + Overhead
Model weights = Parameters Γ Bytes per parameter
KV cache = 2 Γ attention_layers Γ num_kv_heads Γ head_dim Γ context_length Γ batch_size Γ bytes_per_value
Activation memory β 5-10% of model weights
Overhead β 500 MB - 1 GB (CUDA context, framework buffers)
The KV-cache formula uses the number of key/value heads and the head dimension, not hidden_size. Modern models use grouped-query attention (GQA): many query heads share a few KV heads, so using hidden_size overstates the cache several times. All three values are in the modelβs config.json on Hugging Face (num_hidden_layers, num_key_value_heads, head_dim). bytes_per_value is 2 for the default FP16 cache; an 8-bit KV cache halves it.
Worked example 1: Qwen3 8B, 32K context, FP16 cache. From its config.json: 36 layers, 8 KV heads, head_dim 128.
- Per token: 2 Γ 36 Γ 8 Γ 128 Γ 2 bytes = 147,456 bytes (144 KiB)
- 32,768 tokens Γ 144 KiB = 4.5 GiB of KV cache
- Weights:
qwen3:8bis a 5.2 GB download in Ollama - Total β 5.2 + 4.5 + ~1 GB overhead β 10.7 GB, so a full 32K context does not fit on an 8 GB GPU even though the weights do. At 8K context the cache is ~1.1 GiB.
Worked example 2: Qwen3.5 27B, 32K context. Qwen3.5 is a hybrid model: per its config.json, only every fourth layer (16 of 64) uses full attention with a KV cache (4 KV heads, head_dim 256); the other layers use linear attention with a fixed-size state.
- Per token: 2 Γ 16 Γ 4 Γ 256 Γ 2 bytes = 65,536 bytes (64 KiB)
- 32,768 tokens Γ 64 KiB = 2 GiB of KV cache
- Weights:
qwen3.5:27bis a 17 GB download in Ollama (default Q4_K_M) - Total β 17 + 2 + ~1.5 GB β 20.5 GB: fits a 24 GB GPU, not a 16 GB one.
Download size is the best quick estimate for weights, because it already reflects the real quantization mix (some tensors stay at higher precision). That is why 27B Γ 0.5 bytes = 13.5 GB underestimates the 17 GB file.
Quick reference
Ollama download sizes for the default tag (checked on ollama.com on December 3, 2026). Add the KV cache for your context length on top.
| Model (Ollama tag) | Download (default quant) | Practical minimum |
|---|---|---|
Qwen3 4B (qwen3:4b) | 2.5 GB | Any 8 GB machine |
Qwen3 8B (qwen3:8b) | 5.2 GB | 8 GB GPU at short context; 12 GB+ for 32K |
DeepSeek R1 14B (deepseek-r1:14b) | 9.0 GB | 12-16 GB GPU or 16 GB Mac |
Devstral Small 2 24B (devstral-small-2) | 15 GB | 24 GB GPU or 24 GB+ Mac |
Qwen 3.5 27B (qwen3.5:27b) | 17 GB | 24 GB GPU or 32 GB Mac |
Qwen3 32B (qwen3:32b) | 20 GB | 24 GB GPU (short context) or 32 GB+ Mac |
Qwen3-Coder 30B-A3B (qwen3-coder) | 19 GB | 24 GB GPU or 32 GB+ Mac |
Llama 4 Scout (llama4:scout, 109B total / 17B active MoE) | 67 GB | 96 GB+ Mac or multi-GPU |
Mixture-of-experts models such as Llama 4 Scout and Qwen3-Coder 30B-A3B are fast for their size because few parameters are active per token, but all weights must still be in memory.
For a broader hardware buying guide, see Best GPU for AI Locally in 2026.
Quantization impact on quality
Not all quantizations are equal. Hereβs how they affect output quality for coding tasks:
| Quantization | Size reduction | Quality impact | Best for |
|---|---|---|---|
| FP16 | None (baseline) | None | Research, max quality |
| Q8_0 | 50% | Negligible | When you have the VRAM |
| Q5_K_M | 67% | Minimal | Sweet spot for most users |
| Q4_K_M | 75% | Slight degradation | Fitting larger models |
| Q3_K_M | 80% | Noticeable on complex tasks | Last resort |
| Q2_K | 87% | Significant | Not recommended |
The difference between Q5_K_M and Q4_K_M is usually imperceptible in conversation. For coding, Q5_K_M preserves more accuracy in syntax and logic. Going below Q4 causes measurable drops in code correctness.
For a deep comparison of quantization formats, see our GGUF vs GPTQ vs AWQ guide.
What happens when you donβt have enough VRAM
| Situation | What happens | Performance |
|---|---|---|
| Model fits in VRAM | Runs entirely on GPU | β Full speed |
| Model slightly exceeds VRAM | Offloads layers to CPU (Apple Silicon: unified memory) | β οΈ 30-50% slower |
| Model far exceeds VRAM | Heavy CPU offloading or crashes | β 5-10x slower or fails |
On Apple Silicon Macs, βVRAMβ is unified memory shared with the system. A 32GB Mac can run a 24GB model because the OS uses ~4-6GB, leaving ~26GB for the model.
On NVIDIA GPUs, VRAM is separate. A 24GB RTX 4090 can only fit models up to ~22GB (some VRAM used by the OS/driver).
Apple Silicon unified memory
On Macs with Apple Silicon, GPU and CPU share the same memory pool. This changes the math:
- Total available for models = Total RAM - OS usage (~4-6 GB)
- No separate VRAM β the model uses whatever memory is free
- Slower than discrete GPU β memory bandwidth is lower than NVIDIA HBM
- But no offloading penalty β unlike NVIDIA where CPU offload crosses PCIe
Practical limits on Apple Silicon:
| Mac | Total RAM | Usable for models | Largest model (Q4_K_M) |
|---|---|---|---|
| M4 16GB | 16 GB | ~11 GB | 14B |
| M4 24GB | 24 GB | ~18 GB | 27B |
| M4 Pro 48GB | 48 GB | ~42 GB | 70B |
| M4 Max 96GB | 96 GB | ~88 GB | 120B+ |
| Mac Studio 256 GB / 512 GB | 256-512 GB | most of it (see note) | 235B-class MoE at Q4 (e.g. qwen3:235b, 142 GB) |
The current Mac Studio ships with M5 Max or M5 Ultra and up to 512 GB of unified memory (Apple specs). macOS caps how much unified memory the GPU may wire by default; on large-memory Macs you can raise it with sudo sysctl iogpu.wired_limit_mb=<MB> (resets on reboot), leaving headroom for the OS.
Use Ollama or llama.cpp with Metal acceleration for best performance on Mac.
Tips for fitting larger models
- Use quantization β Drop from FP16 to Q4_K_M to cut VRAM by 75%
- Reduce context length β Use
--ctx-size 4096instead of 32K if you donβt need long context - Close other GPU apps β Browsers, video players, and displays use VRAM
- Use Flash Attention β Reduces memory usage for long contexts
- Try partial offloading β Put most layers on GPU, a few on CPU (
--n-gpu-layers 28in llama.cpp) - Consider a smaller model β A 14B at Q5 often beats a 27B at Q3 in quality
Choosing the right quantization
Have plenty of VRAM? β Q8_0 (best quality)
Model barely fits? β Q5_K_M (sweet spot)
Model doesn't fit? β Q4_K_M (acceptable quality loss)
Still doesn't fit? β Smaller model (don't go below Q4)
Going below Q4 quantization causes noticeable quality degradation, especially for coding tasks. Itβs better to use a smaller model at Q5 than a larger model at Q3.
Hardware recommendations by budget
| Budget | Hardware | Models you can run |
|---|---|---|
| $0 | Existing laptop (8GB+) | Qwen3 4B-8B |
| $800 | Mac Mini M4 24GB | Up to 14B models |
| $2,000 | Mac Mini M4 Pro 48GB | Up to 32B models |
| $3,500 | Mac Studio M4 Max 96GB | Up to 70B models |
| $2,500 | RTX 4090 (24 GB) workstation | Up to ~27-32B at Q4 with modest context (VRAM limited) |
| $1,200/mo | RunPod A100 80GB | Anything up to 70B |
See our GPU vs CPU guide for when you need a GPU and best AI models for Mac for Apple Silicon recommendations.
Related: Best GPU for AI Locally 2026 Β· GGUF vs GPTQ vs AWQ Β· Ollama Complete Guide Β· GPU Memory Planning Β· GPU vs CPU for AI Inference Β· Best AI Models for Mac Β· Best Ollama Models for Coding Β· Best Cloud GPU Providers
What changed in this update
December 3, 2026: corrected the KV-cache formula (it uses KV heads and head dimension, not hidden size, which overstated the cache for grouped-query-attention models) and added two worked examples from the modelsβ own config files, including Qwen3.5βs hybrid attention. Replaced estimated sizes with Ollama download sizes, corrected Llama 4 Scout (a 109B-total MoE, 67 GB in Ollama, not 70B/35 GB), and replaced the non-existent Mac Studio βM4 Ultra 192GBβ row with current Mac Studio memory configurations.