Skip to content
Koit Academy

LLM VRAM calculator

Your numbers

The numbers filled in are an example. Replace them with yours.

GPU memory needed

About 21 GiB

15 GiB for the weights and 4.5 GiB for the KV cache (144 KiB a token × 32,768 tokens × 1), plus 10% overhead. It needs at least a 24 GB card, or several smaller ones.

How it adds up

ItemWeightsTotal
16-bit weights15 GiB21 GiB
8-bit weights7.5 GiB13 GiB
4-bit weights3.7 GiB9 GiB

Find the layers, KV heads and head dimension in the model’s config.json, where they are usually called num_hidden_layers, num_key_value_heads and head_dim. Overhead varies with the inference engine; leave room beyond this figure for the desktop and other programs if the GPU also drives a display.

Worked out from the numbers you enter. Calculated in this browser; nothing you enter is sent anywhere or stored.

How to use it · free, no signup

How to use the LLM VRAM Calculator

Enter a model’s size, its precision and the context you want to run to estimate the GPU memory it needs, weights and KV cache included. Calculated in your browser.

  1. 01

    Enter the model size

    Parameters in billions, and the bits per weight you will run it at.

  2. 02

    Enter the context

    The tokens of context and how many sequences run at once.

  3. 03

    Add the architecture

    Layers, KV heads and head dimension, from the model’s config.json.

Weights plus the KV cache

Running a language model takes memory for two main things: the weights, and the KV cache that holds the keys and values of tokens already processed. The weights are parameters times bytes per parameter: 2 bytes at 16 bits, 1 at 8 bits and half a byte at 4 bits. The KV cache is 2 × layers × KV heads × head dimension × context × sequences × bytes per element, as Sebastian Raschka’s explanation of the KV cache sets out. The starting values are his example, an 8-billion-parameter model with 36 layers, 8 KV heads and a head dimension of 128.

PartMemory
Weights, 8 billion × 2 bytes15 GiB
KV cache per token144 KiB
KV cache for 32,768 tokens4.5 GiB
Total with 10% overheadAbout 21 GiB

Quantisation and context

Lowering the precision of the weights is the biggest saving: 8 bits halves them and 4 bits quarters them, usually with a small loss in quality. The KV cache does not shrink with the weights. It grows with every token of context and every sequence served at once, so a long context or a busy server can need more memory for the cache than for the model. Some engines can also store the cache at 8 bits, which the KV cache bits field covers.

Reading the result

  • Leave headroom. A card that only just fits will fail when the context grows or another program uses memory.
  • Check the engine. Some pre-allocate the whole KV cache up front; raise the overhead to match what yours reports.
  • Several cards add up, but splitting a model across them has its own overhead and needs an engine that supports it.
  • Gigabytes on the box are GiB here. A “24 GB” card holds 24 GiB.

Local or through an API

Running a model yourself trades a GPU for per-token charges. To compare, price the same workload through an API with the AI API cost calculator, and check how long answers take at the speed your hardware manages with the tokens per second calculator. To see how much text fits in the context you are planning for, use the context window calculator.

Published by Koit Academy. Who runs it, how it is paid and how its tools are checked.

Questions

What people ask about the LLM VRAM Calculator

How much VRAM does a language model need?
Roughly parameters times bytes per parameter for the weights, plus the KV cache. An 8-billion-parameter model at 16 bits needs about 15 GiB for its weights alone.
How much does 4-bit quantisation save?
The weights take a quarter of their 16-bit size: about 33 GiB instead of 130 GiB for a 70-billion-parameter model. Quality usually drops a little, more for small models.
What is the KV cache?
Memory that stores the keys and values of tokens already processed, so they are not recomputed. It grows with context length and with the number of sequences served at once.
Where do I find the layers and KV heads?
In the model’s config.json, usually as num_hidden_layers, num_key_value_heads and head_dim, or hidden size divided by attention heads.
Why is my real usage higher than this?
Inference engines reserve extra memory for activations, buffers and their own bookkeeping, and some pre-allocate the whole KV cache. Raise the overhead to match what your engine reports.