LLM VRAM calculator
Estimate GPU memory for inference or fine-tuning: weights, KV-cache, activations and overhead, recomputed as you type.
Model and runtime
7.00B · Q4_K_M · 4,096 ctxPlain numbers mean billions.
Constants: weights ×1.07 metadata factor, 0.6 GB runtime overhead, full AdamW +16 B/param. Decimal GB (1 GB = 10⁹ bytes).
Memory breakdown
Total 7.354 GB7.00B @ Q4_K_M, 4,096 ctx, batch 1 · inference
7.354 GB
| Component | GB | Share |
|---|---|---|
| Weights | 4.539 | 61.7% |
| KV-cache | 2.147 | 29.2% |
| Activations | 0.067 | 0.9% |
| Overhead | 0.600 | 8.2% |
| Total | 7.354 | 100% |
KV-cache = 2 (K+V) × 32 layers × 4,096 ctx × 32 kv-heads × 128 head_dim × 2 B = 2.147 GB
Largest context that fits 24.00 GB: 34,884 tokens.
Fine-tune comparison
| Mode | Total GB | vs inference |
|---|---|---|
| Inference | 7.354 | — |
| Full AdamW | 129.8 | +1665% |
| LoRA (r=16, fp16 base) | 17.81 | +142% |
Quantization comparison
| Quant | B/param | Weights GB | Total GB |
|---|---|---|---|
| FP32 | 4 | 29.96 | 32.77 |
| FP16 / BF16 | 2 | 14.98 | 17.79 |
| INT8 | 1 | 7.490 | 10.30 |
| Q8_0 | 1.063 | 7.962 | 10.78 |
| Q6_K | 0.824 | 6.172 | 8.986 |
| Q5_K_M | 0.693 | 5.191 | 8.005 |
| Q4_K_M (selected) | 0.606 | 4.539 | 7.354 |
| Q4_0 | 0.563 | 4.217 | 7.031 |
| Q3_K_M | 0.488 | 3.655 | 6.470 |
| Q2_K | 0.328 | 2.457 | 5.271 |
Examples
7B fp16
7B, fp16, 4k context, batch 1roughly 17–19 GB14 GB of weights plus KV cache, activations and runtime overhead.
70B Q4_K_M
70B, Q4_K_M, 8k contextabout 45 GB before overheadMeasured GGUF bits-per-weight including block scales, not a naive 0.5 bytes/param.
GQA 8B
Llama 3 8B, 4k contextKV cache about 0.54 GBEight KV heads instead of 32 shrink the cache fourfold versus MHA.
About this tool
The LLM VRAM Calculator estimates GPU memory for self-hosted inference and fine-tuning before you rent or buy hardware. It breaks the total into weights, KV cache, activations and runtime overhead, and shows the formula behind each term so the number is auditable rather than opaque.
Weights use quantization-aware bytes per parameter with a documented metadata factor; the KV cache uses the real number of key/value heads, so grouped-query attention models such as Llama 3 get a much smaller cache than MHA models of the same size. The GPU verdict compares the estimate with common VRAM sizes and reverse-solves the largest context that fits.
Switch to full fine-tuning to add the AdamW state estimate, or LoRA to price only the adapter delta. A quantization comparison table shows the trade-off across fp16, int8 and GGUF Q4/Q5/Q6 levels. All arithmetic happens in the browser; the result is a planning estimate, not a runtime guarantee.
What this tool does not do
- Estimates use decimal GB and documented rules of thumb, not a runtime allocator.
- No network calls, pricing or hardware database is included.
- Paged attention and CPU offloading are not modeled.
How to use this tool
Choose a model
Pick an architecture preset or type a parameter count such as 7, 7.5B or 7500M. Edit layers, hidden size and KV heads in the advanced fields when needed.
Set the workload
Choose quantization, context length, batch size and inference, full fine-tune or LoRA mode.
Read the breakdown
The stacked bar and table show weights, KV cache, activations and overhead separately. Check the GPU verdict and the largest context that fits your budget.
Compare and copy
Use the quantization table to see the memory trade-offs, then copy the summary or download the breakdown CSV for a capacity plan.
Use cases
Pre-purchase checks
Decide whether 24 GB or 48 GB of VRAM covers your target model and context.
Context planning
Reverse-solve the longest context that fits a given GPU before deploying a chat service.
Fine-tune budgeting
Compare full AdamW memory with a LoRA adapter to pick a feasible training setup.
Memory terms
| Term | Estimate |
|---|---|
| Weights | parameters × effective bytes/param × 1.07 metadata factor |
| KV cache | 2 × layers × context × kv_heads × head_dim × bytes (fp16 default) |
| Activations | batch × context × hidden × transient buffers × bytes |
| Runtime overhead | about 0.6 GB for CUDA context, compute buffers and scratch space |
| Full fine-tune | fp16 weights + about 16 bytes/param of master weights, gradients and Adam states |
| LoRA | inference base plus the small B·A adapter delta for the selected rank |
Decimal GB (1e9 bytes) are used throughout; real CUDA allocations vary by runtime and allocator.
Common mistakes
Mistake:Equating 4-bit weights with 0.5 bytes per parameter.
Fix:GGUF Q4_K_M includes block scales and lands near 0.606 bytes/param; the tool uses measured values.
Mistake:Ignoring the KV cache for long contexts.
Fix:KV grows linearly with context and batch and can dominate weights at 32k and beyond.
Mistake:Assuming quantization shrinks the KV cache.
Fix:Cache dtype is usually fp16 regardless of weight quantization; change it explicitly in advanced fields if your runtime does.
Mistake:Treating the estimate as a deployment guarantee.
Fix:Paged attention, offloading and framework buffers shift real allocations in both directions.
Frequently asked questions
How much VRAM does a 70B model need at 4-bit?
Weights alone are roughly 40–45 GB depending on the exact quantization (Q4_K_M is about 0.606 bytes per parameter including block scales). Add KV cache, activations and roughly 0.6 GB of runtime overhead; a 48 GB card is tight at long contexts, an 80 GB card is comfortable.
What is KV cache and why does it grow with context?
Attention keeps a key and a value tensor for every token in the context, for every layer and KV head. Doubling the context roughly doubles this cache. Grouped-query attention reduces the number of KV heads, which is why Llama 3 8B has about a 0.54 GB cache at 4k rather than the 2.1 GB an MHA model would need.
Why does fine-tuning need more memory than inference?
Full AdamW fine-tuning stores fp32 master weights, gradients and two optimizer moments in addition to the model weights — about 16 extra bytes per parameter. LoRA freezes the base model and only trains small B and A matrices, so its extra memory is tiny by comparison.
Does quantization affect KV-cache size?
Usually not: runtimes keep the KV cache in fp16 or bf16 even when weights are 4-bit. The cache term in this calculator is therefore independent of the weight quantization unless you change the cache dtype in the advanced fields.
How accurate are these estimates versus real CUDA allocations?
They are planning estimates with documented constants. vLLM's paged attention, llama.cpp buffers, CUDA graphs, fragmentation and offloading can move real usage in either direction. Leave headroom, especially for long contexts and large batches.
What do the GPU verdict and 'largest context that fits' mean?
The verdict compares the estimated total with a chosen GPU size. The reverse solve binary-searches context length until the total exceeds that budget, so you can see the practical context limit before deploying. If weights alone exceed the budget, the tool says the model does not fit at any context.
References & standards
Related tools
Agent Tool Flowchart Builder
Design agentic tool-call DAGs with decision branches and bounded loops. Validates reachability, cycle handling, and emits clean Mermaid flowcharts — fully in your browser.
AI Agent Memory & Buffer Simulator
Compare sliding window, summary buffer, and vector memory strategies
AI API Client SDK Generator
Generate typed API client SDK files from OpenAPI specifications or cURL requests
AI Code Explainer
Explain code snippets with grounded cloud AI
AI Code Security Auditor
Scan source code for high-confidence OWASP Top 10 vulnerabilities
AI Code Translator
Translate code into idiomatic implementations in another language