DevTools Logo

LLM VRAM Calculator

LLM VRAM calculator

Estimate GPU memory for inference or fine-tuning: weights, KV-cache, activations and overhead, recomputed as you type.

Runs in your browser
Try an example

Model and runtime

7.00B · Q4_K_M · 4,096 ctx

Plain 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 GB
Estimates only: real allocations vary by runtime (llama.cpp vs vLLM paged attention) and are not a deployment guarantee.

7.00B @ Q4_K_M, 4,096 ctx, batch 1 · inference

7.354 GB

Fits 24.00 GB — 16.65 GB headroom
Weights 4.539 GBKV-cache 2.147 GBActivations 0.067 GBOverhead 0.600 GB
ComponentGBShare
Weights4.53961.7%
KV-cache2.14729.2%
Activations0.0670.9%
Overhead0.6008.2%
Total7.354100%

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

ModeTotal GBvs inference
Inference7.354—
Full AdamW129.8+1665%
LoRA (r=16, fp16 base)17.81+142%

Quantization comparison

QuantB/paramWeights GBTotal GB
FP32429.9632.77
FP16 / BF16214.9817.79
INT817.49010.30
Q8_01.0637.96210.78
Q6_K0.8246.1728.986
Q5_K_M0.6935.1918.005
Q4_K_M (selected)0.6064.5397.354
Q4_00.5634.2177.031
Q3_K_M0.4883.6556.470
Q2_K0.3282.4575.271

Examples

7B fp16

Input
7B, fp16, 4k context, batch 1
Output
roughly 17–19 GB

14 GB of weights plus KV cache, activations and runtime overhead.

70B Q4_K_M

Input
70B, Q4_K_M, 8k context
Output
about 45 GB before overhead

Measured GGUF bits-per-weight including block scales, not a naive 0.5 bytes/param.

GQA 8B

Input
Llama 3 8B, 4k context
Output
KV cache about 0.54 GB

Eight 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

  1. 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.

  2. Set the workload

    Choose quantization, context length, batch size and inference, full fine-tune or LoRA mode.

  3. 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.

  4. 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

TermEstimate
Weightsparameters × effective bytes/param × 1.07 metadata factor
KV cache2 × layers × context × kv_heads × head_dim × bytes (fp16 default)
Activationsbatch × context × hidden × transient buffers × bytes
Runtime overheadabout 0.6 GB for CUDA context, compute buffers and scratch space
Full fine-tunefp16 weights + about 16 bytes/param of master weights, gradients and Adam states
LoRAinference 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