πŸ€– AI Tools
Β· 7 min read
Last updated on

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
QuantizationBytes per parameterExample: 24B model
FP16 (full)2 bytes48 GB
Q8_01 byte24 GB
Q5_K_M0.65 bytes15.6 GB
Q4_K_M0.5 bytes12 GB
Q3_K_M0.4 bytes9.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:8b is 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:27b is 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 GBAny 8 GB machine
Qwen3 8B (qwen3:8b)5.2 GB8 GB GPU at short context; 12 GB+ for 32K
DeepSeek R1 14B (deepseek-r1:14b)9.0 GB12-16 GB GPU or 16 GB Mac
Devstral Small 2 24B (devstral-small-2)15 GB24 GB GPU or 24 GB+ Mac
Qwen 3.5 27B (qwen3.5:27b)17 GB24 GB GPU or 32 GB Mac
Qwen3 32B (qwen3:32b)20 GB24 GB GPU (short context) or 32 GB+ Mac
Qwen3-Coder 30B-A3B (qwen3-coder)19 GB24 GB GPU or 32 GB+ Mac
Llama 4 Scout (llama4:scout, 109B total / 17B active MoE)67 GB96 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:

QuantizationSize reductionQuality impactBest for
FP16None (baseline)NoneResearch, max quality
Q8_050%NegligibleWhen you have the VRAM
Q5_K_M67%MinimalSweet spot for most users
Q4_K_M75%Slight degradationFitting larger models
Q3_K_M80%Noticeable on complex tasksLast resort
Q2_K87%SignificantNot 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

SituationWhat happensPerformance
Model fits in VRAMRuns entirely on GPUβœ… Full speed
Model slightly exceeds VRAMOffloads layers to CPU (Apple Silicon: unified memory)⚠️ 30-50% slower
Model far exceeds VRAMHeavy 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:

MacTotal RAMUsable for modelsLargest model (Q4_K_M)
M4 16GB16 GB~11 GB14B
M4 24GB24 GB~18 GB27B
M4 Pro 48GB48 GB~42 GB70B
M4 Max 96GB96 GB~88 GB120B+
Mac Studio 256 GB / 512 GB256-512 GBmost 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

  1. Use quantization β€” Drop from FP16 to Q4_K_M to cut VRAM by 75%
  2. Reduce context length β€” Use --ctx-size 4096 instead of 32K if you don’t need long context
  3. Close other GPU apps β€” Browsers, video players, and displays use VRAM
  4. Use Flash Attention β€” Reduces memory usage for long contexts
  5. Try partial offloading β€” Put most layers on GPU, a few on CPU (--n-gpu-layers 28 in llama.cpp)
  6. 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

BudgetHardwareModels you can run
$0Existing laptop (8GB+)Qwen3 4B-8B
$800Mac Mini M4 24GBUp to 14B models
$2,000Mac Mini M4 Pro 48GBUp to 32B models
$3,500Mac Studio M4 Max 96GBUp to 70B models
$2,500RTX 4090 (24 GB) workstationUp to ~27-32B at Q4 with modest context (VRAM limited)
$1,200/moRunPod A100 80GBAnything 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.