AI & Computing

GPU Memory (VRAM) Calculator for LLMs

Enter the model size, precision and context to estimate how much VRAM you need.

Your numbers

Grouped-query attention models share key/value heads, e.g. 8 KV heads for 32 heads = 0.25
%

Your results

Total VRAM needed (GB)
Total VRAM needed (GB)
—
Model weights (GB)
—
KV cache (GB)
—
Fits on
—

GPU Memory (VRAM) Calculator for LLMs by TheCalcTools

How the GPU Memory (VRAM) Calculator for LLMs works

Model weights take parameters × bytes per parameter: 2 bytes at FP16, 1 byte at INT8 and about half a byte with 4-bit quantisation. An 8-billion-parameter model needs about 16 GB at FP16 or 4.5 GB at 4 bits.

The KV cache stores keys and values for every token in context: 2 × layers × hidden size × (KV heads ÷ heads) × context × batch × bytes. It grows with long contexts and many concurrent users.

Add 10 to 20% for activations, the CUDA context and fragmentation. Results are estimates; serving frameworks differ.

The formula

Weights (GB) = parameters × bits ÷ 8 ÷ 10⁹KV cache (GB) = 2 × layers × hidden × KV ratio × context × batch × bytes ÷ 10⁹

Worked example

Using the default values shown in the calculator:

Parameters (billions)8
Weight precisionFP16 / BF16 (16-bit)
Layers32
Hidden size4096
KV heads ÷ attention heads (1 = no GQA)0.25
Context length (tokens)8192
Batch size (concurrent sequences)1
KV cache precision16-bit
Runtime overhead10 %
  1. 8B parameters at 16-bit: 8 × 2 = 16.0 GB of weights.
  2. KV cache for 8,192 tokens: 1.07 GB. With 10% overhead: 18.8 GB, so it fits on One 24 GB GPU.

Result:

Total VRAM needed (GB)18.8
Model weights (GB)16.0
KV cache (GB)1.07
Fits onOne 24 GB GPU

Frequently asked questions

Can I run a 70B model on a 24 GB GPU?

Not fully on the GPU: 70B at 4 bits is about 40 GB of weights. You would need two 24 GB GPUs, a 48 GB GPU, or CPU offloading, which is much slower.

Where do I find layers and hidden size?

In the model’s config.json on its model card (num_hidden_layers, hidden_size, num_attention_heads, num_key_value_heads).

Sources and further reading

More in AI & Computing · All calculators

This calculator gives estimates for information only. Check important results independently before you rely on them. See our disclaimer.