Free tool · runs in your browser
VRAM calculator for local LLMs
Pick a model, a quant and a context length. We add up the weights, the KV cache and the runtime overhead, then show which GPUs and Macs can hold it. Every formula is on this page, and every result here is an estimate of memory, not a speed. For measured tokens/s on our RTX 4060, see the benchmarks page.
This page has Amazon affiliate links and Runpod and Vast.ai referral links. As an Amazon Associate, we earn from qualifying purchases. You won't pay more. Disclosure.
Estimate for Llama 3.1 8B Instruct, Q4_K_M, 8,192 tokens of context
- Weights 4.5 GB 8.03B params × 4.85 bits per weight ÷ 8
- KV cache 1.0 GB 131,072 bytes per token × 8,192 tokens
- Runtime overhead 0.8 GB compute buffers, 0.5 GB base
Smallest common GPU memory size that fits with room to spare: 8 GB.
Smallest cards that fit it fully (affiliate links, search results, prices vary):
GeForce RTX 5060 Ti 8GB on Amazon GeForce RTX 5060 (8 GB) on Amazon GeForce RTX 3080 10GB on Amazon GeForce RTX 2080 Ti (11 GB) on Amazon
Macs and unified-memory PCs
| Device | Memory options | Smallest option that fits |
|---|---|---|
| Apple M1 | 8 / 16 GB | Fits on GPUfrom 16 GB |
| Apple M1 Pro | 16 / 32 GB | Fits on GPUfrom 16 GB |
| Apple M1 Max | 32 / 64 GB | Fits on GPUfrom 32 GB |
| Apple M1 Ultra | 64 / 128 GB | Fits on GPUfrom 64 GB |
| Apple M2 | 8 / 16 / 24 GB | Fits on GPUfrom 16 GB |
| Apple M2 Pro | 16 / 32 GB | Fits on GPUfrom 16 GB |
| Apple M2 Max | 32 / 64 / 96 GB | Fits on GPUfrom 32 GB |
| Apple M2 Ultra | 64 / 128 / 192 GB | Fits on GPUfrom 64 GB |
| Apple M3 | 8 / 16 / 24 GB | Fits on GPUfrom 16 GB |
| Apple M3 Pro | 18 / 36 GB | Fits on GPUfrom 18 GB |
| Apple M3 Max (40-core GPU) | 48 / 64 / 128 GB | Fits on GPUfrom 48 GB |
| Apple M3 Ultra | 96 / 256 / 512 GB | Fits on GPUfrom 96 GB |
| Apple M4 | 16 / 24 / 32 GB | Fits on GPUfrom 16 GB |
| Apple M4 Pro | 24 / 48 / 64 GB | Fits on GPUfrom 24 GB |
| Apple M4 Max (16-core CPU) | 48 / 64 / 128 GB | Fits on GPUfrom 48 GB |
| Apple M5 | 16 / 24 / 32 GB | Fits on GPUfrom 16 GB |
| AMD Ryzen AI Max+ 395 | 64 / 128 GB | Fits on GPUfrom 64 GB |
| NVIDIA DGX Spark | 128 GB | Fits on GPUfrom 128 GB |
The GPU can use about 2/3 of a Mac's memory (3/4 at 64 GB and up), so a 16 GB Mac holds less than a 16 GB graphics card. "Fits" means total ≤ 94% of usable memory; "tight" means it fits with less headroom. Estimates only. How we estimate
How the calculator works
Running a model on a GPU needs three blocks of memory. Sizes below use GB to mean 1,024³ bytes (GiB), the unit GPU memory is sold in.
1. Weights
"Bits per weight" is the average for the whole GGUF file, higher than the headline number because llama.cpp keeps some tensors at higher precision. We use these values (the same ones the Will it run? tool and the methodology page use):
| Quant | Bits per weight | 8B model | 70B model | Quality |
|---|---|---|---|---|
| FP16 | 16 | 14.9 GB | 130 GB | unquantized |
| Q8_0 | 8.5 | 7.9 GB | 69.3 GB | near-lossless |
| Q6_K | 6.56 | 6.1 GB | 53.5 GB | very close to full quality |
| Q5_K_M | 5.69 | 5.3 GB | 46.4 GB | small quality loss |
| Q4_K_M | 4.85 | 4.5 GB | 39.5 GB | the usual sweet spot |
| Q3_K_M | 3.91 | 3.6 GB | 31.9 GB | noticeable quality loss |
Models released in a non-GGUF official format (DeepSeek-R1 in FP8, gpt-oss in MXFP4) use the official checkpoint size instead. For a mixture-of-experts model, weights use the total parameter count, because every expert must be in memory.
2. KV cache
The 2 is for the key and value tensors. The layer count, KV head count and head dimension come from each model's config.json on Hugging Face. Worked example, Llama 3.1 8B (32 layers, 8 KV heads, head dimension 128, FP16 cache):
131,072 × 8,192 tokens = 1,073,741,824 bytes ≈ 1.0 GB
Bytes per value for the cache type:
| KV cache type | Bytes per value | Size vs FP16 |
|---|---|---|
| FP16 (default) | 2.000 | 100.0% |
| Q8_0 | 1.063 | 53.1% |
| Q4_0 | 0.563 | 28.1% |
Q8_0 stores 32 values in 34 bytes (32 int8 plus a 2-byte scale), Q4_0 in 18 bytes (16 bytes of 4-bit values plus the scale). See context length and VRAM for how fast the cache grows.
3. Runtime overhead
This covers compute buffers for a 512-token batch, and comes to 0.6 GB–1.1 GB for the models we track. Real overhead depends on the runtime and batch settings, which is one reason to treat results as estimates.
Models with sliding-window or linear attention
Some models do not cache every token in every layer. Gemma, gpt-oss and Llama 4 mix full-attention layers with sliding-window layers that keep only the last 128, 512, 1,024 or 8,192 tokens (it varies by model), and some Qwen models mix in linear-attention layers with a small fixed-size state. For these the calculator splits the cache the same way: full layers × context tokens, plus sliding layers × min(context, window), plus any fixed state. That is why their KV cache stays small at long context. Models affected: Llama 4 Scout 17B-16E Instruct, Qwen3.6 27B, Qwen3.6 35B-A3B, Gemma 3 4B, Gemma 3 12B, Gemma 3 27B, Gemma 4 E4B, Gemma 4 12B, Gemma 4 26B-A4B, Gemma 4 31B, gpt-oss-20b, gpt-oss-120b.
What "fits" means
- Fits on GPU: total ≤ 94% of the card's VRAM.
- Tight fit: total is above that but still within the card's VRAM. Close other GPU programs.
- Partial offload: weights spill over into system RAM, as long as the KV cache and overhead stay in VRAM and your RAM (minus 6 GB for the OS) holds the rest. Works, but much slower.
- Won't fit: not enough VRAM and RAM combined at this quant and context.
Memory needed by model and quant at 8K context
The same formulas, precomputed for every model we track, with an FP16 KV cache and 8,192 tokens. Click a model for its full page, or open it in the calculator to change the context.
| Model | Params | FP16 | Q8_0 | Q6_K | Q5_K_M | Q4_K_M | Q3_K_M | Official |
|---|---|---|---|---|---|---|---|---|
| Llama 3.2 1B Instruct calculator | 1.24B | 3.3 GB | 2.3 GB | 2.0 GB | 1.8 GB | 1.7 GB | 1.6 GB | — |
| Llama 3.2 3B Instruct calculator | 3.21B | 7.6 GB | 4.8 GB | 4.1 GB | 3.8 GB | 3.5 GB | 3.1 GB | — |
| Phi-4 Mini 3.8B Instruct calculator | 3.84B | 9.1 GB | 5.7 GB | 4.9 GB | 4.5 GB | 4.1 GB | 3.7 GB | — |
| Qwen3 4B calculator | 4.02B | 9.4 GB | 5.9 GB | 5.0 GB | 4.6 GB | 4.2 GB | 3.8 GB | — |
| Gemma 3 4B calculator | 4.3B | 9.3 GB | 5.6 GB | 4.6 GB | 4.2 GB | 3.7 GB | 3.3 GB | — |
| Mistral 7B Instruct v0.3 calculator | 7.25B | 15.1 GB | 8.8 GB | 7.2 GB | 6.4 GB | 5.7 GB | 4.9 GB | — |
| Qwen2.5 Coder 7B Instruct calculator | 7.62B | 15.5 GB | 8.8 GB | 7.1 GB | 6.3 GB | 5.6 GB | 4.8 GB | — |
| Gemma 4 E4B calculator | 8.0B | 16.1 GB | 9.1 GB | 7.3 GB | 6.5 GB | 5.7 GB | 4.8 GB | — |
| Llama 3.1 8B Instruct calculator | 8.03B | 16.8 GB | 9.8 GB | 7.9 GB | 7.1 GB | 6.3 GB | 5.5 GB | — |
| DeepSeek R1 Distill Llama 8B calculator | 8.03B | 16.8 GB | 9.8 GB | 7.9 GB | 7.1 GB | 6.3 GB | 5.5 GB | — |
| Qwen3 8B calculator | 8.19B | 17.2 GB | 10.1 GB | 8.2 GB | 7.4 GB | 6.6 GB | 5.7 GB | — |
| Gemma 4 12B calculator | 12B | 23.8 GB | 13.3 GB | 10.6 GB | 9.4 GB | 8.2 GB | 6.9 GB | — |
| Gemma 3 12B calculator | 12.2B | 24.6 GB | 13.9 GB | 11.2 GB | 9.9 GB | 8.8 GB | 7.4 GB | — |
| Mistral Nemo 12B Instruct calculator | 12.3B | 24.9 GB | 14.2 GB | 11.4 GB | 10.2 GB | 9.0 GB | 7.7 GB | — |
| Phi-4 14B calculator | 14.7B | 29.6 GB | 16.8 GB | 13.5 GB | 12.0 GB | 10.6 GB | 9.0 GB | — |
| Qwen3 14B calculator | 14.8B | 29.6 GB | 16.7 GB | 13.4 GB | 11.9 GB | 10.5 GB | 8.8 GB | — |
| DeepSeek R1 Distill Qwen 14B calculator | 14.8B | 29.9 GB | 17.0 GB | 13.6 GB | 12.2 GB | 10.7 GB | 9.1 GB | — |
| gpt-oss-20b calculator | 20.9B3.6B active | — | — | — | — | — | — | 13.9 GB |
| Devstral Small 24B calculator | 23.6B | 46.0 GB | 25.4 GB | 20.1 GB | 17.7 GB | 15.4 GB | 12.8 GB | — |
| Mistral Small 3.2 24B Instruct calculator | 24B | 46.8 GB | 25.8 GB | 20.4 GB | 18.0 GB | 15.6 GB | 13.0 GB | — |
| Gemma 4 26B-A4B calculator | 25.8B4.0B active | 49.5 GB | 26.9 GB | 21.1 GB | 18.5 GB | 16.0 GB | 13.1 GB | — |
| Gemma 3 27B calculator | 27.4B | 53.2 GB | 29.3 GB | 23.1 GB | 20.3 GB | 17.6 GB | 14.6 GB | — |
| Qwen3.6 27B calculator | 27.8B | 53.4 GB | 29.2 GB | 22.9 GB | 20.1 GB | 17.4 GB | 14.3 GB | — |
| Qwen3 30B-A3B calculator | 30.5B3.3B active | 58.4 GB | 31.8 GB | 24.9 GB | 21.8 GB | 18.8 GB | 15.5 GB | — |
| Gemma 4 31B calculator | 31.3B | 60.7 GB | 33.4 GB | 26.4 GB | 23.2 GB | 20.1 GB | 16.7 GB | — |
| Qwen3 32B calculator | 32.8B | 63.9 GB | 35.3 GB | 27.9 GB | 24.6 GB | 21.4 GB | 17.8 GB | — |
| Qwen2.5 Coder 32B Instruct calculator | 32.8B | 63.9 GB | 35.3 GB | 27.9 GB | 24.6 GB | 21.4 GB | 17.8 GB | — |
| DeepSeek R1 Distill Qwen 32B calculator | 32.8B | 63.9 GB | 35.3 GB | 27.9 GB | 24.6 GB | 21.4 GB | 17.8 GB | — |
| Qwen3.6 35B-A3B calculator | 36B3.0B active | 68.2 GB | 36.8 GB | 28.7 GB | 25.0 GB | 21.5 GB | 17.6 GB | — |
| Llama 3.3 70B Instruct calculator | 70.5B | 135 GB | 73.2 GB | 57.2 GB | 50.1 GB | 43.2 GB | 35.5 GB | — |
| Llama 4 Scout 17B-16E Instruct calculator | 109B17B active | 205 GB | 110 GB | 85.4 GB | 74.4 GB | 63.8 GB | 51.9 GB | — |
| gpt-oss-120b calculator | 117B5.1B active | — | — | — | — | — | — | 62.0 GB |
| DeepSeek R1 (671B) calculator | 684B37B active | 1276 GB | 679 GB | 524 GB | 455 GB | 388 GB | 313 GB | 643 GB |
Architecture numbers used for each model
Read from each model's config.json on Hugging Face (data refreshed with refresh-models). "KV per token" is the FP16 cache for one token across all layers; sliding-window layers stop growing after their window.
| Model | Attention layout | KV per token (FP16) | Max context |
|---|---|---|---|
| Llama 3.2 1B Instruct | 16 full-attention layers, 8 KV heads (grouped-query) | 32,768 B | 128K |
| Llama 3.2 3B Instruct | 28 full-attention layers, 8 KV heads (grouped-query) | 114,688 B | 128K |
| Phi-4 Mini 3.8B Instruct | 32 full-attention layers, 8 KV heads (grouped-query) | 131,072 B | 128K |
| Qwen3 4B | 36 full-attention layers, 8 KV heads (grouped-query) | 147,456 B | 40K |
| Gemma 3 4B | 5 full-attention, 29 sliding-window (1024 tokens) layers | 139,264 B | 128K |
| Mistral 7B Instruct v0.3 | 32 full-attention layers, 8 KV heads (grouped-query) | 131,072 B | 32K |
| Qwen2.5 Coder 7B Instruct | 28 full-attention layers, 4 KV heads (grouped-query) | 57,344 B | 32K |
| Gemma 4 E4B | 4 full-attention, 20 sliding-window (512 tokens) layers; last 18 layers reuse earlier caches | 57,344 B | 128K |
| Llama 3.1 8B Instruct | 32 full-attention layers, 8 KV heads (grouped-query) | 131,072 B | 128K |
| DeepSeek R1 Distill Llama 8B | 32 full-attention layers, 8 KV heads (grouped-query) | 131,072 B | 128K |
| Qwen3 8B | 36 full-attention layers, 8 KV heads (grouped-query) | 147,456 B | 40K |
| Gemma 4 12B | 8 full-attention, 40 sliding-window (1024 tokens) layers | 344,064 B | 256K |
| Gemma 3 12B | 8 full-attention, 40 sliding-window (1024 tokens) layers | 393,216 B | 128K |
| Mistral Nemo 12B Instruct | 40 full-attention layers, 8 KV heads (grouped-query) | 163,840 B | 128K |
| Phi-4 14B | 40 full-attention layers, 10 KV heads (grouped-query) | 204,800 B | 16K |
| Qwen3 14B | 40 full-attention layers, 8 KV heads (grouped-query) | 163,840 B | 40K |
| DeepSeek R1 Distill Qwen 14B | 48 full-attention layers, 8 KV heads (grouped-query) | 196,608 B | 128K |
| gpt-oss-20b | 12 full-attention, 12 sliding-window (128 tokens) layers | 49,152 B | 128K |
| Devstral Small 24B | 40 full-attention layers, 8 KV heads (grouped-query) | 163,840 B | 128K |
| Mistral Small 3.2 24B Instruct | 40 full-attention layers, 8 KV heads (grouped-query) | 163,840 B | 128K |
| Gemma 4 26B-A4B | 5 full-attention, 25 sliding-window (1024 tokens) layers | 225,280 B | 256K |
| Gemma 3 27B | 10 full-attention, 52 sliding-window (1024 tokens) layers | 507,904 B | 128K |
| Qwen3.6 27B | 16 full-attention, 48 linear-attention layers | 65,536 B | 256K |
| Qwen3 30B-A3B | 48 full-attention layers, 4 KV heads (grouped-query) | 98,304 B | 40K |
| Gemma 4 31B | 10 full-attention, 50 sliding-window (1024 tokens) layers | 901,120 B | 256K |
| Qwen3 32B | 64 full-attention layers, 8 KV heads (grouped-query) | 262,144 B | 40K |
| Qwen2.5 Coder 32B Instruct | 64 full-attention layers, 8 KV heads (grouped-query) | 262,144 B | 32K |
| DeepSeek R1 Distill Qwen 32B | 64 full-attention layers, 8 KV heads (grouped-query) | 262,144 B | 128K |
| Qwen3.6 35B-A3B | 10 full-attention, 30 linear-attention layers | 20,480 B | 256K |
| Llama 3.3 70B Instruct | 80 full-attention layers, 8 KV heads (grouped-query) | 327,680 B | 128K |
| Llama 4 Scout 17B-16E Instruct | 12 full-attention, 36 sliding-window (8192 tokens) layers | 196,608 B | 10240K |
| gpt-oss-120b | 18 full-attention, 18 sliding-window (128 tokens) layers | 73,728 B | 128K |
| DeepSeek R1 (671B) | Multi-head latent attention (MLA) | 70,272 B | 160K |
What this calculator does not tell you
- Speed. This tool only estimates memory. For speed estimates see the Will it run? tool, and for measured llama.cpp tokens/s on our RTX 4060 see the benchmarks page. How the estimates work is on the methodology page.
- Multi-GPU and image models. Splitting a model over two cards adds some overhead per card, and image or video models have different memory rules.
- Your exact setup. Browsers, games and the desktop use VRAM too. Leave a gigabyte or two spare.
Next steps
- Decide whether to buy a card: GPU buy vs rent calculator, best GPU by budget, best used GPU.
- Learn the concepts: how much VRAM you need, quantization explained, context length and VRAM.
- Too big for your card? Rent a cloud GPU.
Frequently asked questions
How much VRAM do I need to run an LLM locally?
Add up three things: the model weights (parameters × bits per weight ÷ 8), the KV cache (which grows with context length) and about 0.5 GB or more of runtime overhead. For Llama 3.1 8B Instruct at Q4_K_M with 8,192 tokens of context that is about 6.3 GB, These are estimates, not measurements.
What is the VRAM formula for LLM weights?
weights in bytes = parameters × bits per weight ÷ 8. A 8B model at Q4_K_M, which averages about 4.85 bits per weight once the tensors llama.cpp keeps at higher precision are counted, takes about 4.5 GB. At FP16 (16 bits) the same model needs about 15.0 GB.
How do I calculate KV cache size?
KV cache bytes = 2 × layers × KV heads × head dimension × context tokens × bytes per value. The 2 is for the key and value tensors. Llama 3.1 8B has 32 layers, 8 KV heads and a head dimension of 128, so at FP16 it needs 131,072 bytes per token, or 1.0 GB at 8,192 tokens.
Does quantizing the KV cache save VRAM?
Yes. In llama.cpp a Q8_0 cache is about 53% the size of FP16 and a Q4_0 cache about 28%. Quantizing the V cache needs flash attention enabled, and a smaller cache can cost some quality, most noticeably at Q4_0. It matters most at long context, where the KV cache can rival the weights.
Can a model run if it does not fit entirely in VRAM?
Yes, with partial offload: some layers stay in system RAM and run on the CPU. The calculator marks a GPU "Partial offload" when the KV cache and overhead fit in VRAM and the remaining weights fit in your system RAM (minus 6 GB kept for the operating system). It works, but generation slows down a lot, because system RAM is several times slower than VRAM.
Why does a mixture-of-experts model need so much memory for its size?
All experts have to be loaded even though only a few are used per token. A model like Qwen3 30B-A3B has 3.3B active parameters but needs memory for all 30.5B. The active count affects speed, not how much memory you need, so the calculator uses total parameters for weights.
How accurate is this VRAM calculator?
It is an estimate from published formulas and real model configs, not a measurement. Real use varies with the runtime (llama.cpp, Ollama, LM Studio), batch size, GPU driver and whether other programs use VRAM, and we have not checked the totals against measured VRAM on every card. We say "fits" at 94% of the card's memory or less, to leave room for the desktop and other apps.