LLM VRAM calculator
How it adds up
| Item | Weights | Total |
|---|---|---|
| 16-bit weights | 15 GiB | 21 GiB |
| 8-bit weights | 7.5 GiB | 13 GiB |
| 4-bit weights | 3.7 GiB | 9 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.
01
Enter the model size
Parameters in billions, and the bits per weight you will run it at.
02
Enter the context
The tokens of context and how many sequences run at once.
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.
| Part | Memory |
|---|---|
| Weights, 8 billion × 2 bytes | 15 GiB |
| KV cache per token | 144 KiB |
| KV cache for 32,768 tokens | 4.5 GiB |
| Total with 10% overhead | About 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?
How much does 4-bit quantisation save?
What is the KV cache?
Where do I find the layers and KV heads?
Why is my real usage higher than this?
Related tools
Tokens per Second Calculator
How long an AI answer takes to generate
Open itToken Counter
An estimate of the tokens in any text
Open itContext Window Calculator
How many words and pages fit in a context window
Open itPassword Generator
Generate strong passwords in your browser and see what they are actually worth
Open itAI Prompt Generator
One clear prompt from its parts
Open itAI Image Prompt Generator
A detailed image prompt from its parts
Open it