LLM VRAM Calculator
Pick a model and a card to see how many gigabytes it really takes to serve — weights, the KV cache your context length creates, and the runtime overhead nobody mentions. Every formula is printed on the page.
Tout s’exécute dans votre navigateur — rien de ce que vous saisissez ne quitte la page.
⚠ Cet outil n’est pas encore entièrement traduit en Français ; la version anglaise est affichée. La traduction est en cours.
Estimation mémoire
Qwen2.5 7B Instruct · BF16 / FP16 · 8,2K jetons · GeForce RTX 4090
Tient
- Poids
- Cache KV
- Surcoût
4,53 Go de marge restants
Comment nous calculons
Chaque chiffre est de l’arithmétique sur vos réglages. Rien n’est mesuré, rien n’est téléchargé, aucun tableau de benchmarks n’est utilisé.
- poids = paramètres × octets par paramètre
- cache KV = 2 × couches × têtes KV × dim. de tête × contexte × lot × octets par élément
- surcoût = 1 Go + 10 % de (poids + cache KV)
- total = poids + cache KV + surcoût
- tient si total ≤ VRAM × GPU × 0,95
- contexte max = (utilisable − 1,1 × poids − 1 Go) ÷ (1,1 × octets par jeton)
- jetons/s max = bande passante × GPU ÷ (paramètres actifs × octets par paramètre)
- Les modèles à mélange d’experts chargent tous les experts : la mémoire suit le total des paramètres, la vitesse les paramètres actifs.
- L’attention latente, à fenêtre glissante et linéaire sont hors périmètre : cette formule de cache KV ne les décrit pas.
- Les chiffres multi-GPU supposent un partage égal et ignorent le surcoût du parallélisme tensoriel.
- Ce sont des estimations, pas des garanties : la taille des fichiers quantifiés varie et le surcoût est une réserve forfaitaire.
Three things compete for the same memory
When a language model is loaded, the card holds three different things, and only one of them is the model file you downloaded. First the weights: one number per parameter, at whatever precision you chose. Second the KV cache: the keys and values of every token the model has already seen, kept so that the next token does not have to re-read the whole conversation. Third the runtime overhead: the engine, its allocator, kernel buffers and the CUDA context, which cost memory whether or not a single token is generated.
- Weights scale with the number of parameters and the precision. They are the same size at 500 tokens of context and at 50,000.
- KV cache scales with context length, batch size and the number of layers — it is the term that turns a comfortable fit into an out-of-memory crash.
- Overhead is roughly fixed per process, which is why a model that "just fits" on paper usually does not fit in practice.
Weights: the part you can plan exactly
Weight memory is plain multiplication: parameters × bytes per parameter. A 7-billion-parameter model at BF16 is 7 × 10⁹ × 2 = 14 × 10⁹ bytes, or 14 GB. The same model at 4-bit quantization is roughly 4.3 GB. Nothing about your prompt changes that number, which is why it is the safest figure on the page.
| Format | Bytes per parameter | 7B model | 70B model |
|---|---|---|---|
| FP32 | 4 | 28 GB | 280 GB |
| BF16 / FP16 | 2 | 14 GB | 140 GB |
| FP8 / INT8 | 1 | 7 GB | 70 GB |
| Q8_0 (approx.) | 1.06 | 7.4 GB | 74.2 GB |
| Q5_K_M (approx.) | 0.71 | 5.0 GB | 49.7 GB |
| Q4_K_M (approx.) | 0.61 | 4.3 GB | 42.7 GB |
| Q2_K (approx.) | 0.37 | 2.6 GB | 25.9 GB |
The K-quant rows are averages, not formulas: a GGUF block stores a scale next to its low-bit weights, so a file labelled Q4_K_M is a little larger than exactly four bits per parameter, and the ratio drifts between checkpoints. Hence the approx. on every such row.
A smaller weight format buys you the ability to load a model. It does not reduce the KV cache, which is allocated at run time in its own precision. If your plan fails at long context, the fix is a smaller cache — FP8, fewer sequences or less context — not a smaller weight file.
KV cache: the part that grows with your context
Every layer stores one key vector and one value vector per KV head for every token in the conversation, in both the prompt and the generated answer. The formula is therefore exact arithmetic on the architecture: 2 × layers × KV heads × head dimension × context × batch × bytes per element. The leading 2 is the key and the value; the KV-head count is what makes grouped-query attention matter, because several query heads can share a single key/value head.
Worked example — Qwen2.5 7B (28 layers, 4 KV heads, 128-wide heads) at 8,192 tokens, batch 1, FP16 cache: 2 × 28 × 4 × 128 × 8192 × 1 × 2 = 469,762,048 bytes, about 0.47 GB. Push the context to 32,768 and the same cache is 1.88 GB; run four sequences at once and it is 7.5 GB. On a 24 GB card that difference decides whether the model runs at all.
This is also why grouped-query attention replaced multi-head attention so quickly. A model with 32 KV heads instead of 8 would need four times the cache at the same context, and four times the memory bandwidth to read it — the trade-off stage 11 of the course demonstrates with a live simulation.
Mixture of experts: memory and speed stop tracking each other
A sparse mixture-of-experts model keeps every expert in memory but routes each token through only a few of them. Qwen1.5-MoE, for example, has 14.3 billion parameters in total and touches about 2.7 billion of them per token. That splits the two questions this page answers: memory follows the total, because all 60 experts must be loadable, while speed follows the active count, because only the chosen experts are read from memory during a decode step.
Practically, a 14B MoE that needs about 28.6 GB of weights at BF16 can generate tokens at roughly the speed of a 2.7B dense model on the same card — but it still will not fit on a 24 GB GPU.
What this page deliberately does not model
- Throughput beyond the bandwidth ceiling. The tokens-per-second figure is bandwidth ÷ bytes read per token: a batch-1 upper bound. Real engines lose 20–50% of it to attention over the cache, kernel launches and sampling.
- Tensor-parallel inefficiency. Splitting a model across GPUs duplicates some buffers, so the multi-GPU estimate is optimistic by a few percent.
- Fragmentation. A server that has answered thousands of requests of varying length ends up with a fragmented cache, so production deployments reserve more than the arithmetic asks for.
The model architecture table and the GPU table are static data files in this site’s source, each row linked to the official config file or manufacturer page it came from. The arithmetic runs in your browser; no request leaves the page and no benchmark number is fetched at run time. When a value could not be verified, the tables say so instead of filling it in.
Questions fréquentes
- How much VRAM do I need for a 70B model?
- Use the formula rather than a rule of thumb. Weights = 70 × 10⁹ × bytes per parameter: 140 GB at BF16, 70 GB at FP8, about 42.7 GB at Q4_K_M. Then add the KV cache: 2 × layers × KV heads × head dimension × context × batch × bytes per element. For an 80-layer model with 8 KV heads and 128-wide heads at 8,192 tokens and batch 1 in FP16 that is 2.68 GB. Add overhead of 1 GB plus 10% of the two, and you land near 50.9 GB at Q4_K_M with an 8K context — one 80 GB card, or several smaller ones. At BF16 the same plan needs well over 150 GB.
- Why does my model fit on paper but crash with an out-of-memory error?
- Almost always because the paper estimate left something out. The usual omissions are the KV cache at your real context length, the runtime’s own allocations, and the fact that a card cannot give all of its VRAM to one process. This page keeps 5% of the card back for exactly that reason. If you are right at the limit, lower the batch size or the context before buying different hardware.
- Does quantization make the KV cache smaller?
- Not by itself. The weight format and the cache precision are separate settings: a Q4_K_M file can still allocate an FP16 cache. The cache shrinks only when you store it in FP8 or INT8, halving the per-element cost, or when you reduce what it holds — a shorter context, a smaller batch, or an architecture with fewer KV heads.
- Why are DeepSeek-style and sliding-window models excluded?
- Because the KV formula on this page does not describe them. Multi-head latent attention compresses keys and values into a shared low-rank latent, and sliding-window attention only keeps the last N tokens, so their real cache is a fraction of what the standard formula predicts. Rather than print a number that is wrong by an order of magnitude, the model list only contains architectures the formula actually models.
- Can I run a model across several GPUs?
- Yes, and the calculator multiplies usable memory by the card count, keeping the same 5% reserve on the total. Treat that as a lower bound: tensor parallelism duplicates some buffers and adds communication, so a real two-card deployment typically needs a little more headroom than the arithmetic suggests. Both cards should also be the same model — mixing VRAM sizes wastes capacity.
- How accurate is the tokens-per-second figure?
- It is a ceiling, not a prediction. Decoding one token requires streaming the active weights once, so the fastest possible rate is memory bandwidth divided by bytes read per token — about 239 tokens per second for a 7B model at BF16 on an H100 SXM. A good engine on a single stream typically reaches 50–80% of that, and batching raises total throughput while lowering per-stream speed. Measure on your own hardware before quoting it to anyone.
- Where do the model and GPU numbers come from?
- Each model row lists the numbers from its official config.json on Hugging Face — layers, hidden size, attention heads, KV heads, head dimension and maximum context — with the repository linked as the source, and the parameter count from the repository’s own safetensors metadata. GPU memory and bandwidth come from the manufacturer’s specification page. Where a figure could not be read from an official source it is left empty and rendered as a dash rather than guessed.
Le cours correspondant
Cet outil accompagne ces étapes du parcours gratuit en 11 étapes.
Outils liés
- LLM API Cost Calculator →
Turn a token count and a traffic guess into a real monthly bill. Set the prompt size, the answer size and how many requests you expect, and every priced model is compared side by side.
- Cheapest LLM API Finder →
Sort and filter the whole public model catalogue by what it actually costs you: input price, output price, a blended price weighted to your own input:output mix, and the context window that decides whether your documents fit at all.