Presets use the published layer and head counts of each model.
Lower bits use less memory and cost a little quality.
Smallest common GPU that fits: 8 GB.
| GPU memory | Fits? | Free after load |
|---|---|---|
| 8 GB | Yes | 1.9 GB |
| 12 GB | Yes | 5.9 GB |
| 16 GB | Yes | 9.9 GB |
| 24 GB | Yes | 17.9 GB |
| 32 GB | Yes | 25.9 GB |
| 48 GB | Yes | 41.9 GB |
| 80 GB | Yes | 73.9 GB |
Key takeaways
- Weights take most of the memory: Llama 3.1 8B at 4-bit is 4.5 GB, but 15.0 GB at 16-bit.
- A 70B model at 4-bit needs about 46.5 GB even at a short context, so it does not fit one 24 GB card.
- The KV cache grows with context: 8B at 4-bit adds 1.0 GB at 8,192 tokens and 4.0 GB at 32,768.
- This is an estimate. Runtimes differ by a few percent, so keep 1 to 2 GB of headroom.
How to use the LLM VRAM Calculator
- 1Choose a model preset, or pick Custom architecture and type the parameter count, layers, KV heads and head size.
- 2Choose the weight quantization. 4-bit is the usual choice for local use.
- 3Enter the context length in tokens, and the number of requests you will run in parallel.
- 4Read the total and its three parts, then check the GPU table to see which cards have enough room.
- 5Press Copy link to share the exact settings.
How much VRAM does an LLM need?
An LLM needs roughly its weight file plus the KV cache plus about 10% extra. The weight file is the parameter count times the bytes per weight, so a 70B model at 16-bit is about 131 GB and at 4-bit about 40 GB.
That is why one setting matters most. Going from 16-bit to 4-bit cuts Llama 3.1 8B from 17.6 GB to 6.1 GB in total at an 8,192-token context. Use the AI token counter to see how many tokens your real prompts use before you choose a context length.
How is GPU memory for a model calculated?
The calculator uses three terms. Weights = parameters × bytes per weight. KV cache = 2 × layers × KV heads × head size × context tokens × bytes per value × parallel requests. Total = (weights + KV cache) × 1.10.
The factor of 2 covers the key and the value stored for each token. The 10% overhead stands in for activation buffers and the runtime's own allocations. Real runtimes can differ, which is why the result is an estimate and not a guarantee.
What does quantization do to memory?
Quantization stores each weight in fewer bits, so the file and the memory it needs shrink by the same ratio. The figures here use the average size of llama.cpp block formats, which include the scale values: about 0.61 bytes per weight for Q4_K_M, 0.71 for Q5_K_M and 1.06 for Q8_0.
Lower bit counts lose a little accuracy. Q8 is close to the original, Q5 and Q4 are usually fine for chat and coding help, and anything below 4-bit shows clearer quality loss. Other formats such as GPTQ or AWQ land in a similar range.
Why does the context length change the answer?
The model keeps a key and a value for every token in the context, and that cache lives in VRAM. It grows in a straight line with the context length and with each parallel request. For 8B at 4-bit, 4 parallel requests at 8,192 tokens take 4.0 GB of cache, the same as one request at 32,768.
Newer models use grouped-query attention, which shares key and value heads and shrinks the cache. Llama 3.1 8B keeps 8 KV heads, while the older Llama 2 13B keeps 40. You can also store the cache in 8-bit to nearly halve it. Compare these costs with API pricing in the AI API cost calculator.
What does this calculator not cover?
It assumes a dense model on a single GPU. It does not model mixture-of-experts layouts, where all experts must still be loaded, nor splitting layers across cards, CPU offloading, LoRA adapters, vision encoders or speculative decoding. Each of those changes the real figure.
It also ignores the speed of generation, which depends on memory bandwidth more than on capacity. A model that fits can still run slowly. Treat the result as a way to rule options in or out, then test on your own hardware.
Worked example
Worked example: Llama 3.1 8B at 4-bit with a 32,768-token context
Llama 3.1 8B has about 8.03 billion parameters, 32 layers, 8 KV heads and a head size of 128. At 4-bit (Q4_K_M, 0.606 bytes per weight) the weights are 8.03 × 10⁹ × 0.606 ÷ 1,073,741,824 = 4.5 GB.
The KV cache at 32,768 tokens in 16-bit is 2 × 32 × 8 × 128 × 32,768 × 2 bytes ÷ 1,073,741,824 = 4.0 GB. Add both and apply the 10% overhead: (4.5 GB + 4.0 GB) × 1.10 = 9.4 GB. A 12 GB card fits it with room to spare, and storing the cache in 8-bit brings the total to 7.3 GB.
Compare the 13B model at the same settings. Its 40 KV heads make the cache 25.0 GB, so the total is 35.6 GB and it needs a 48 GB card, even though the weights alone are only 7.3 GB.
VRAM needed by model size and quantization
Total estimate with an 8,192-token context, one request and a 16-bit KV cache.
| Model | 4-bit | 5-bit | 8-bit | 16-bit |
|---|---|---|---|---|
| 7B (Mistral 7B) | 5.6 GB | 6.4 GB | 9.0 GB | 15.9 GB |
| 8B (Llama 3.1 8B) | 6.1 GB | 6.9 GB | 9.8 GB | 17.6 GB |
| 13B (Llama 2 13B) | 15.0 GB | 16.4 GB | 21.0 GB | 33.6 GB |
| 34B (Code Llama 34B) | 22.6 GB | 26.2 GB | 38.4 GB | 70.8 GB |
| 70B (Llama 3.1 70B) | 46.5 GB | 54.1 GB | 79.5 GB | 147 GB |
For example, 70B at 4-bit comes to 46.5 GB, against 147 GB at 16-bit. Sizes are in GB of 1,073,741,824 bytes.
Frequently asked questions
How much VRAM do I need to run Llama 3.1 8B?
About 6.1 GB at 4-bit and 17.6 GB at 16-bit, both with an 8,192-token context. An 8 GB card runs the 4-bit version with a short context. A 24 GB card runs the 16-bit version with room for a longer context. Use the calculator to check your own context length.
Can a 24 GB GPU run a 70B model?
Not fully on the GPU. A 70B model at 4-bit needs about 46.5 GB, roughly twice a 24 GB card. You can offload some layers to system memory, which works but is much slower. Two 24 GB cards fit it, or you can pick a 34B model, which needs about 22.6 GB at 4-bit.
Does a longer context window use more VRAM?
Yes. The KV cache grows in direct proportion to the context length. For Llama 3.1 8B in 16-bit, the cache is 1.0 GB at 8,192 tokens and 4.0 GB at 32,768 tokens. The weights stay the same, so the effect is small for short contexts and large for very long ones.
What is the KV cache?
The KV cache holds the attention keys and values the model has already computed for every token in the conversation, so it does not recompute them for each new token. It speeds up generation but uses VRAM that grows with context length, the number of layers and the number of parallel requests.
How accurate is this estimate?
It is usually within about 10% of what a runtime such as llama.cpp reports for dense models, but not exact. Frameworks differ in buffer sizes, and some reserve extra memory for the graph or the display. Leave 1 to 2 GB free, and test on your hardware before you buy a card for one specific model.
Does 4-bit quantization hurt quality?
A little. 8-bit is nearly identical to the original model, and 4-bit with good block formats such as Q4_K_M keeps most of the quality for chat, summaries and coding help. Quality loss grows below 4-bit and is larger for small models. If you have the memory, 5-bit or 8-bit is a safe choice.
Is my data sent anywhere?
No. The calculation runs in your browser and nothing you enter is uploaded or stored. The model presets are built into the page. For more tools for working with language models, see our AI tools section.
Sources
- Hugging Face: KV cache strategies
- Ainslie et al.: GQA, grouped-query attention (arXiv)
- Meta: The Llama 3 Herd of Models (arXiv)
Last reviewed by the ToolsFiesta team.