LLM VRAM calculator

Enter the size of the model in billions of parameters, the precision of its weights and the shape of its attention layers. The calculator adds the weights, the KV cache for your context length and batch, and an allowance for runtime overhead, then tells you whether it fits the memory you have and how long a context would.

%
GiB
Total memory16.58 GB
Total in GiB15.44 GiB
Model weights
14 GB
KV cache
1.074 GB
Overhead allowance
1.51 GB
KV cache per token
128 KiB
In the available memory
Fits
Longest context that fits
71,923

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Enter the number of parameters in billions and pick the precision the weights are stored in.
  2. Copy layers, KV heads and head dimension from the model’s configuration.
  3. Set the context length you plan to use and how many sequences run at once.
  4. Pick the KV cache precision (16-bit unless your runtime quantizes the cache) and an overhead allowance.
  5. Enter the memory of your GPU, or the sum of several, to see whether it fits and the longest context that does.

Formula

  • Weights = parameters × bytes per parameter (4, 2, 1 or 0.5 bytes).
  • KV cache = 2 × layers × KV heads × head dimension × context × batch × bytes per value.
  • Total = (weights + KV cache) × (1 + overhead ÷ 100).
  • Longest context = (memory ÷ (1 + overhead ÷ 100) − weights) ÷ (KV cache per token × batch), rounded down.

Models with grouped-query attention have fewer KV heads than attention heads, which is why the KV heads field is separate: use the KV figure, not the total number of heads.

Worked example

A model of 7 billion parameters at 16 bits, 32 layers, 8 KV heads of dimension 128, context 8192, one sequence, 10 % allowance:

  • weights 7 × 10⁹ × 2 = 14 GB;
  • KV cache per token 2 × 32 × 8 × 128 × 2 = 131,072 bytes = 128 KiB, for 8192 tokens 1,073,741,824 bytes = 1.074 GB;
  • allowance 10 % of 15.074 GB = 1.51 GB;
  • total 16.58 GB, which is 15.44 GiB.

With 24 GiB available it fits, and the longest context is (25,769,803,776 ÷ 1.1 − 14 × 10⁹) ÷ 131,072 = 71,923 tokens.

Tips

  • Precision matters most. Going from 16 to 4 bits cuts the weights to a quarter; the KV cache only shrinks if the runtime stores it at lower precision too.
  • Long contexts and batches grow linearly. Doubling the context or the batch doubles the KV cache, so a model that fits at 8k tokens may not at 128k.
  • Splitting across GPUs adds memory, but each card also needs its own buffers: keep the allowance generous.
  • This is an estimate from the formulas above, not a measurement; real use depends on the runtime and its settings.

Frequently asked questions

How much memory do the weights of a model take?

Parameters × bytes per parameter. At 16 bits each parameter takes 2 bytes, so 7 billion parameters need 14 GB; at 8 bits 7 GB, at 4 bits 3.5 GB, at 32 bits 28 GB.

How is the KV cache calculated?

2 × layers × KV heads × head dimension × context length × batch × bytes per value. The 2 stands for keys and values. With 32 layers, 8 KV heads of 128 at 16 bits that is 128 KiB per token, so 8192 tokens take 1 GiB.

Where do I find layers, KV heads and head dimension?

In the model's configuration file, usually named like num_hidden_layers, num_key_value_heads and head_dim. If there is no head_dim, divide the hidden size by the number of attention heads.

What is the overhead allowance for?

Runtimes also need memory for activations, temporary buffers and their own code, and 4-bit formats store scale factors on top of the 4 bits. The amount depends on the software, so the calculator adds a percentage you choose instead of guessing; 10 % is the default.

Why are there GB and GiB?

1 GB is 10⁹ bytes and 1 GiB is 2³⁰ = 1,073,741,824 bytes, about 7.4 % more. The available memory is entered in GiB; if your figure is in decimal GB, multiply it by 0.931.

More in Developer

All tools in this category: Developer ·Updated November 6, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.