Tech & Digital
LLM GPU Memory (VRAM) Calculator
Running a large language model locally or on a server starts with one practical question: will it fit in the GPU's memory? The dominant factor is the size of the model's weights, which equals the number of parameters multiplied by the number of bytes used to store each one. Full 32-bit floating point uses 4 bytes per parameter, the 16-bit formats FP16 and BF16 that are standard for inference use 2, 8-bit integer quantisation uses 1, and 4-bit quantisation uses half a byte. A model with 7 billion parameters therefore needs about 28 gigabytes in FP32, 14 in FP16, 7 in INT8 and 3.5 in 4-bit form, just for its weights. On top of the weights, inference needs memory for intermediate activations, the key-value cache that stores attention information for every token in the context, and the framework itself. The key-value cache in particular grows with context length and batch size, so long conversations or many simultaneous users can require far more than the weights alone. This calculator multiplies parameters by bytes per parameter to get the weights, adds an overhead percentage you choose, with 20 percent as a typical starting point for modest contexts, and, if you enter the memory of one GPU, estimates how many GPUs are needed. It reports results in gigabytes and in gibibytes, since GPU memory is often quoted in binary units. A 7-billion-parameter model in FP16 needs about 16.8 gigabytes with 20 percent overhead, which fits on a 24-gigabyte card, while a 70-billion-parameter model in 4-bit form needs about 42 gigabytes, or two 24-gigabyte GPUs. Treat the result as an estimate and check the documentation of the model and inference software you use.
How to use this calculator
- Enter the model's number of parameters in billions.
- Choose the precision or quantisation you will use.
- Set an overhead percentage; increase it for long contexts or large batches.
- Optionally enter the memory of one GPU.
- Read the estimated memory and number of GPUs.
The key-value cache
During generation, transformer models store keys and values for every previous token in each layer so they do not have to recompute them. This cache grows linearly with context length and with the number of sequences processed in parallel. For long contexts of tens or hundreds of thousands of tokens, it can rival or exceed the size of the weights.
Techniques such as grouped-query attention, cache quantisation and paged attention reduce this memory, and inference frameworks often let you cap the context length to fit a given GPU.
Quantisation trade-offs
Quantising weights to 8 or 4 bits makes large models runnable on consumer hardware, with quality losses that are often small for 8-bit and more noticeable, though frequently acceptable, for 4-bit, depending on the method and model. Some formats keep certain sensitive layers at higher precision.
Memory is not the only constraint. Throughput depends on memory bandwidth and compute, and splitting a model across several GPUs adds communication overhead, so a model that fits may still run slowly.
Formula & method
Weights memory (GB) = parameters (billions) × bytes per parameterTotal estimate = weights × (1 + overhead)GPUs needed = total ÷ memory per GPU, rounded upLong contexts and large batches need more memory for the KV cache than a fixed percentage suggestsWeights (GB) = parameters (billions) × bytes per parameter. Total = weights × (1 + overhead). GiB = GB × 10⁹ ÷ 1024³. GPUs = ⌈total ÷ GPU memory⌉.
Worked example
A 7B model in FP16
- Weights = 7 × 2 = 14 GB.
- Total = 14 × 1.2 = 16.8 GB (15.65 GiB).
- GPUs with 24 GB: ⌈16.8 ÷ 24⌉ = 1.
Answer: The model needs about 17 GB and fits on one 24 GB GPU.
Frequently asked questions
How much VRAM does a 7B model need?
About 14 GB of weights in FP16, roughly 17 GB with overhead; about 4–5 GB in 4-bit form.
Why does precision matter?
Each parameter takes 4, 2, 1 or 0.5 bytes depending on the format.
What is the overhead for?
Activations, the key-value cache and framework memory during inference.
Is training memory the same?
No. Training needs gradients and optimiser states, several times more memory.
What is the difference between GB and GiB?
GB is 10⁹ bytes; GiB is 2³⁰ bytes, about 7% larger.
Can I split a model across GPUs?
Yes, most inference frameworks support tensor or pipeline parallelism.