LLM VRAM Calculator
Estimate the GPU memory needed to run or fine-tune a large language model, or see which models fit the memory you have.
Estimated VRAM required
16.0 GB
9.65B params at Q4_K_M, 262,144 token context, batch 1, inference.
Estimate accuracy: Weights within ~3% of most GGUF files from Q4_K_M up, ~7% for Q3_K_M and Q2_K. KV cache within ~5% for standard GQA models, ~10% for MLA or hybrid state estimates. Real VRAM may vary with framework (vLLM vs llama.cpp vs Transformers), Flash Attention, and driver overhead.
KV cache exceeds model weights: Consider lowering the context length to save on VRAM. Contexts between 8K and 64K are generally more typical for local setups.
Hybrid linear attention applied: 24 of 32 layers use fixed recurrent state, so only 8 full-attention layers contribute to the context-growing KV cache. The fixed state adds about 0.06 GB at batch 1 and does not grow with context length.
Memory by context length
What makes up the total at each context length, with everything else as set above.
16.0 GB at 256K tokens context, your setting
- Weights
- 5.9 GB
- Fixed state
- 0.1 GB
- KV cache
- 8.6 GB
- Runtime
- 1.5 GB
Context length in tokens. Each step to the right doubles it.
The model numbers match its config at Qwen/Qwen3.5-9B @ c202236. Each point is still an estimate, like the total above.
Weights stay the same at every length. The KV cache grows with the context. Fixed state belongs to the linear attention layers, so it stays flat. Runtime is the allowance the calculator adds for buffers, so it grows a little with the cache. Fixed state and runtime together are the overhead in the result above.
| Context | Weights | Fixed state | KV cache | Runtime | Total |
|---|---|---|---|---|---|
| 4K | 5.9 | 0.1 | 0.2 | 0.7 | 6.7 |
| 8K | 5.9 | 0.1 | 0.3 | 0.7 | 6.9 |
| 16K | 5.9 | 0.1 | 0.6 | 0.7 | 7.2 |
| 32K | 5.9 | 0.1 | 1.1 | 0.7 | 7.8 |
| 64K | 5.9 | 0.1 | 2.2 | 0.9 | 8.9 |
| 128K | 5.9 | 0.1 | 4.3 | 1.1 | 11.3 |
| 256KYour setting | 5.9 | 0.1 | 8.6 | 1.5 | 16.0 |
All values in GB, rounded up like the result above.
Hardware that fits
Unified memory machines show a model budget, not their installed memory. We hold back 8 GB for the system, or use the vendor's GPU limit when that's lower. It's a planning estimate, not a hard limit.
Starting from your hardware instead? See every model that fits in 16 GB of VRAM, the smallest size this setup fits.
How to use this tool
Pick a model
Select a model from the dropdown (Llama 3.1, Qwen 2.5, Mistral, Mixtral, Gemma, DeepSeek, Phi-3, and more). The calculator loads that model's parameter count, layer count, and hidden size automatically.
Choose a quantization format
Pick a quantization level: FP16 (full precision, ~2 bytes/param), Q8_0 (~1 byte/param), Q5_K_M, or Q4_K_M (~0.61 bytes/param). Lower precision shrinks the weight memory at a small quality cost.
Set context length and batch size
Enter the context length in tokens (8K, 32K, 128K, etc.) and the batch size. The KV cache grows linearly with both, so long contexts can dominate the total VRAM at low quantization.
Read the VRAM estimate
The calculator returns total VRAM with a breakdown of weights, KV cache, and runtime overhead. It also lists which GPUs and unified-memory machines have enough memory to run that configuration.
See how memory grows with context
Under the result, the Memory by context length chart runs the same math at many context lengths. Switch it to compare weight formats or batch sizes, or open the numbers as a table. Past a model's maximum context, the chart marks the part the model can't run.
Or start from the memory you have
Switch to Find what fits, then pick your GPU or type how much memory you can use, and set the context length. The finder sizes every model preset with the same math and lists the ones that fit, newer and larger models first. Open any of them to see its full breakdown in the calculator.
About this tool
The LLM VRAM Calculator estimates how much GPU memory you need to run or fine-tune a large language model. Pick a model from the dropdown (Llama 3.1, Qwen 2.5, Mistral, Mixtral, Gemma, DeepSeek, Phi-3, and more), choose a quantization format, and set the context length and batch size.
You get total VRAM with a breakdown of weights, KV cache, and runtime overhead, plus the GPUs and unified-memory machines that have enough memory. Already have the hardware? Switch to Find what fits to go the other way: pick a GPU or a memory amount and see every model that fits in it.
Use it before downloading a model to confirm it fits, when shopping for hardware to run a specific size class, or when deciding whether quantization (Q4_K_M, Q5_K_M, Q8_0) buys you enough headroom to run a tier larger. The math follows the usual split of weights, KV cache, and overhead, so treat the result as a planning estimate and leave some headroom for your runtime.
Formula
Total VRAM = weights + KV cache + activation overhead.
- Weights = params × bytes_per_param (FP16 = 2, Q8 ≈ 1, Q4_K_M ≈ 0.61)
- KV cache = 2 × layers × KV_heads × head_dim × context × batch × KV_dtype_bytes, for standard full-context attention
Models without separate KV-head metadata fall back to hidden_size, while sliding-window and cache-compression presets reduce the result when applicable.
For training, use an architecture and batch-size specific budget. A common mixed-precision AdamW estimate is about 18 bytes per parameter before activations, compared with 2 bytes per parameter for FP16 inference. This page's training result is a planning estimate, not a full training-memory model.
When to use it
Use it to choose a model that fits your existing GPU (Find what fits lists them for you), plan a multi-GPU build for a specific model, or compare quantization options before downloading multi-GB GGUF files. For common memory sizes, a page lists every model that fits at Q4_K_M and Q8_0, with 8K and 32K context. There's one for 8 GB, 12 GB, 16 GB, 24 GB, 32 GB, 48 GB and 96 GB of VRAM, and for 64 GB, 128 GB, 256 GB and 512 GB of unified memory, Macs included.
Pair with the Power Cost Estimator to factor running cost over the lifetime of an inference rig, and the RAM Latency Calculator if you're considering CPU offload as a fallback.
Quantization explained
Modern quantization (Q4_K_M, Q5_K_M, etc.) doesn't lower every weight to the same precision.
K-quants store most weights at the target bit width, plus a scale for each small block of weights. The _M mixes also keep some tensors at a higher precision: Q4_K_M stores about half the attention V and FFN down tensors, and the output layer, as Q6_K. That's why Q4_K_M averages about 0.61 bytes per parameter, not the half a byte that 4 bits would suggest.
The trade-off is good: you keep most of the memory savings of pure 4-bit, with quality close to Q8_0 or FP16.
What we don't model
The calculator gives you a static memory ceiling. It doesn't capture transient memory spikes during long generations, batch scheduling overhead in serving engines, or the small reduction from techniques like prefix caching.
The hardware list keeps installed Apple unified memory separate from an estimated model budget based on an 8 GB reserve. That budget is a planning heuristic, not an Apple-defined VRAM limit.
Leave additional headroom for your actual macOS, apps, runtime, context, and batch workload to avoid out-of-memory errors.
Popular models and configurations
Pre-computed VRAM estimates for common model and quantization combinations.
Guides that use this tool
Longer walkthroughs that put this tool next to the others a reader needs.
Frequently asked questions
How much VRAM do I need to run Llama 3.1 70B locally?
Which models fit on my GPU?
What's the difference between Q4_K_M, Q5_K_M, and Q8_0?
Why does context length affect VRAM so much?
What is KV cache and can I reduce it?
How much extra VRAM does training or fine-tuning need?
Can I split a model across multiple GPUs?
Does Apple unified memory count as VRAM?
Why doesn't my model fit even though the math says it should?
Related tools
LLM API Pricing Calculator
Compare API costs across major models (OpenAI, Anthropic, Google) with prompt caching.
Use toolLLM Token Counter
Count tokens in any prompt for GPT, Claude, Gemini, and Llama with exact OpenAI tokenization.
Use toolPower Cost Estimator
Estimate annual electricity costs for your PC, Server, or TV.
Use toolRAM Latency Calculator
Convert DDR3/DDR4/DDR5 timings (CL, tRCD, tRP, tRAS) into true latency in nanoseconds.
Use toolUse this tool on your own site
Drop the LLM VRAM Calculator into your blog, docs, or CMS with one iframe snippet. Free, no signup. See all embeddable tools