GPU memory for inference is weights plus KV cache plus runtime overhead. Weights = parameters x bytes per parameter (2 for FP16, 1 for FP8, about 0.5 for INT4). KV cache = 2 x layers x KV heads x head dimension x bytes x tokens, where tokens = context length x concurrent sequences. Llama 3.1 8B at FP16 with one 8k sequence needs about 19 GB.
Assumptions, and when this does not apply
The arithmetic covers inference of dense decoder-only transformer models (Llama, Mistral-style and similar) served by an engine that keeps a KV cache, such as vLLM, TensorRT-LLM or Hugging Face TGI. It uses decimal units: 1 GB = 1,000,000,000 bytes, which is how GPU vendors state memory. Tools such as nvidia-smi report MiB, so check the real total on the machine with nvidia-smi --query-gpu=memory.total --format=csv.
It does not cover, or needs adjusting for:
- Training and fine-tuning. Gradients and optimizer states add several times the weight memory. Full fine-tuning with Adam needs far more than inference.
- Mixture-of-experts models. All experts must be resident, so weight memory follows total parameters even though compute follows active parameters.
- Multimodal models. Vision encoders and image tokens add memory and tokens not counted here.
- Models with different attention layouts (sliding-window, multi-head latent attention). Read the KV formula from the model's own architecture.
- Speculative decoding and LoRA adapters. Draft models and adapters add their own weights and cache.
The three parts of GPU memory
- Weights. Parameters x bytes per parameter. 16-bit formats (FP16, BF16) use 2 bytes, FP8 uses 1, and 4-bit formats (INT4, AWQ, GPTQ) use about 0.5 plus small per-group scale factors. The simplest check is the total size of the model's
.safetensorsfiles. - KV cache. For every token in every active sequence, each layer stores one key and one value vector per KV head:
2 x layers x KV heads x head dimension x bytes per elementbytes per token. Multiply by tokens = context length x concurrent sequences. NVIDIA's inference optimization guide gives the same per-token formula. - Runtime overhead. CUDA or ROCm context, activations for the batch being processed, communication buffers and allocator fragmentation. It varies with engine, batch size and settings. This guide uses a stated planning assumption: the larger of 2 GB or 10% of weights plus KV cache. Replace it with a measured number once the model is running.
Then compare the total with usable GPU memory, not nameplate memory. Engines leave a margin: vLLM, for example, takes a configurable fraction (gpu_memory_utilization; the default has been 0.9 in many releases, check your version) and uses what is left after weights and activations for KV cache blocks. This guide treats 90% of nameplate as usable.
The Llama 3.1 8B and 70B configuration numbers
The inputs come from the models' published configuration (config.json on the Hugging Face model pages, which require accepting Meta's license to view) and Table 3 of Meta's Llama 3 paper. Head dimension is hidden size divided by attention heads.
| Value | Llama 3.1 8B | Llama 3.1 70B |
|---|---|---|
| Parameters (from the published safetensors) | 8,030,261,248 | 70,553,706,496 |
Layers (num_hidden_layers) | 32 | 80 |
| Hidden size | 4,096 | 8,192 |
| Attention heads | 32 | 64 |
KV heads (num_key_value_heads, grouped-query attention) | 8 | 8 |
| Head dimension | 4,096 / 32 = 128 | 8,192 / 64 = 128 |
Vocabulary (vocab_size) | 128,256 | 128,256 |
Maximum context (max_position_embeddings) | 131,072 tokens | 131,072 tokens |
Grouped-query attention is why these models are cheaper to serve than their size suggests: 8 KV heads instead of 32 or 64 cuts KV cache by 4x (8B) and 8x (70B) compared with one KV head per attention head.
Weights at FP16, FP8 and INT4
Worked example: weight memory
- 8B at FP16: 8,030,261,248 x 2 = 16,060,522,496 bytes = 16.06 GB
- 8B at FP8: 8,030,261,248 x 1 = 8.03 GB; at INT4: x 0.5 = 4.02 GB
- 70B at FP16: 70,553,706,496 x 2 = 141.11 GB; FP8 70.55 GB; INT4 35.28 GB
The INT4 figures are lower bounds. Many 4-bit checkpoints keep the token embedding and output layers at 16-bit. For these models that is 2 x 128,256 x 4,096 = 1.05 billion parameters (8B) and 2 x 128,256 x 8,192 = 2.10 billion (70B). At 2 bytes instead of 0.5 that adds about 1.6 GB and 3.2 GB. Group-wise scales add roughly another 1-3%. Read the checkpoint's file sizes before you commit.
Precision also changes quality and speed. FP8 is widely used for serving on GPUs with native FP8 support; 4-bit formats save the most memory but should be checked on your own evaluation set.
KV cache at 8k and 32k context, 1 and 16 sequences
Worked example: KV bytes per token at 16-bit
- 8B: 2 x 32 layers x 8 KV heads x 128 x 2 bytes = 131,072 bytes (128 KiB) per token
- 70B: 2 x 80 layers x 8 KV heads x 128 x 2 bytes = 327,680 bytes (320 KiB) per token
- 8B, one 8,192-token sequence: 131,072 x 8,192 = 1,073,741,824 bytes = 1.07 GB
- 8B, 16 sequences at 32,768 tokens: 131,072 x 32,768 x 16 = 68.72 GB, more than four times the FP16 weights
| Scenario (context x sequences) | Tokens held | Llama 3.1 8B | Llama 3.1 70B |
|---|---|---|---|
| 8k x 1 | 8,192 | 1.07 (0.54) | 2.68 (1.34) |
| 8k x 16 | 131,072 | 17.18 (8.59) | 42.95 (21.47) |
| 32k x 1 | 32,768 | 4.29 (2.15) | 10.74 (5.37) |
| 32k x 16 | 524,288 | 68.72 (34.36) | 171.80 (85.90) |
These are worst cases: every sequence at full context at the same moment. Paged KV cache engines such as vLLM allocate blocks as tokens arrive, so average use is lower when prompts are short. Size for the worst case you will allow (via max_model_len and max_num_seqs in vLLM), not the average you hope for. An FP8 KV cache halves this part, with an accuracy trade-off you should test.
Totals: weights plus KV cache plus overhead
Each cell is weights + 16-bit KV cache + overhead (the larger of 2 GB or 10%), in GB.
| Model and weights | 8k x 1 | 8k x 16 | 32k x 1 | 32k x 16 |
|---|---|---|---|---|
| 8B FP16 (16.06) | 19.1 | 36.6 | 22.4 | 93.3 |
| 8B FP8 (8.03) | 11.1 | 27.7 | 14.3 | 84.4 |
| 8B INT4 (4.02) | 7.1 | 23.3 | 10.3 | 80.0 |
| 70B FP16 (141.11) | 158.2 | 202.5 | 167.0 | 344.2 |
| 70B FP8 (70.55) | 80.6 | 124.9 | 89.4 | 266.6 |
| 70B INT4 (35.28) | 41.8 | 86.0 | 50.6 | 227.8 |
Two lessons stand out. First, at long context and real concurrency the KV cache, not the weights, decides the GPU: the 8B model at INT4 still needs 80 GB for 16 sequences at 32k. Second, quantizing weights helps the 70B model most at short context; at 32k x 16 the cache dominates whatever the weight precision.
Worked example: the arithmetic behind two cells
8B FP16, 8k x 1: 16.06 + 1.07 = 17.13 GB. 10% is 1.71, below the 2 GB floor, so overhead is 2 GB. Total 19.13 GB.
70B FP8, 8k x 16: 70.55 + 42.95 = 113.50 GB. Overhead 10% = 11.35. Total 124.85 GB.
Public GPU memory sizes
Nameplate memory and bandwidth from vendor datasheets and product pages. These are facts about the hardware, not an offer; GPU classes can be quoted subject to supplier availability, with the exact model confirmed in writing.
| GPU | Memory | Bandwidth | Usable at 90% |
|---|---|---|---|
| NVIDIA L4 | 24 GB | 300 GB/s | 21.6 GB |
| NVIDIA L40S | 48 GB GDDR6 with ECC | 864 GB/s | 43.2 GB |
| NVIDIA A100 40GB | 40 GB HBM2 | 1,555 GB/s | 36 GB |
| NVIDIA A100 80GB | 80 GB HBM2e | 1,935 GB/s (PCIe), 2,039 GB/s (SXM) | 72 GB |
| NVIDIA H100 SXM | 80 GB | 3.35 TB/s | 72 GB |
| NVIDIA H100 NVL | 94 GB | 3.9 TB/s | 84.6 GB |
| NVIDIA H200 (SXM and NVL) | 141 GB HBM3e | 4.8 TB/s | 126.9 GB |
| NVIDIA B200 (in DGX B200) | 1,440 GB across 8 GPUs = 180 GB each | 64 TB/s across 8 = 8 TB/s each | 162 GB |
| AMD Instinct MI300X | 192 GB HBM3 | 5.3 TB/s peak | 172.8 GB |
NVIDIA's DGX B200 page states system totals; the per-GPU figures are that total divided by eight. Other B200 products may state different per-GPU capacity, so check the datasheet for the exact system you are quoted.
Worked examples: which GPU fits
Worked example A: internal assistant, 8B FP16, 8k, one user at a time
Need 19.13 GB. L4 usable 21.6 GB: fits with 2.5 GB spare. It will not take a second 8k sequence comfortably (each adds 1.07 GB of cache plus activations), so expect one or two concurrent users.
Worked example B: 8B FP16, 32k, 16 concurrent sequences
Need 93.3 GB. That is over an 80 GB card (72 usable) and an H100 NVL (84.6 usable). Options: an H200 (126.9 usable), or keep the 80 GB card and use an FP8 KV cache: 16.06 + 34.36 = 50.42, plus 5.04 overhead = 55.46 GB, which fits.
Worked example C: 70B FP8, 8k, 16 sequences
Need 124.85 GB. One H200 at 126.9 usable fits, but with under 2% to spare: tight. Two 80 GB GPUs with tensor parallelism split weights and cache: 113.50 / 2 = 56.75 GB each, plus 10% = 62.43 GB per GPU, under 72. This is the more comfortable choice.
Worked example D: 70B FP16, 32k, 16 sequences
Need 344.2 GB. Per GPU with tensor parallelism (weights plus cache divided by N, plus 10%):
- 4 x 80 GB: 312.91 / 4 = 78.23, x 1.1 = 86.05 GB per GPU. Over 72: does not fit.
- 8 x 80 GB: 312.91 / 8 = 39.11, x 1.1 = 43.03 GB per GPU. Fits.
- 4 x H200: 86.05 GB per GPU against 126.9 usable. Fits.
- 2 x MI300X: 156.46 x 1.1 = 172.1 GB per GPU against 172.8 usable. Too tight to plan on.
Worked example E: how many sequences does an 80 GB GPU hold for 8B FP16?
Usable 72 GB, minus 16.06 GB weights, minus 2 GB activations = 53.94 GB for cache. 53,940,000,000 / 131,072 = about 411,500 tokens. That is 411,500 / 32,768 = 12.6 sequences at full 32k context, or 411,500 / 8,192 = 50 sequences at 8k.
Tensor parallelism across GPUs
Tensor parallelism splits each layer's weight matrices across N GPUs in one server, so each GPU holds about 1/N of the weights and 1/N of the KV heads. Points that change the arithmetic:
- Divisibility. Serving engines generally require the number of attention heads to be divisible by N, so N is usually 2, 4 or 8.
- KV heads. With 8 KV heads, N up to 8 divides the cache evenly. Beyond 8, KV heads are replicated, and the cache stops shrinking per GPU.
- Overhead does not divide. Each GPU has its own runtime context and buffers, so budget overhead per GPU.
- Interconnect. Each layer needs collective communication between the GPUs for every token. NVLink or Infinity Fabric links keep this fast; over PCIe alone, scaling beyond 2 GPUs often disappoints. Confirm the topology in the quote.
- Across servers, pipeline parallelism (splitting layers between nodes) is more common than tensor parallelism, because network links are slower than in-server GPU links.
In vLLM the setting is tensor_parallel_size. Test the exact layout before buying: a configuration that fits on paper can still miss latency targets.
Memory bandwidth sets the speed ceiling
During decoding, every new token requires reading the weights and that sequence's KV cache from GPU memory. That gives a theoretical upper bound for one sequence: tokens per second at most bandwidth divided by bytes read per token. This is a ceiling, not a benchmark; real figures are lower.
Worked example: single-sequence ceilings
- 8B FP16 with an 8k sequence reads about 17.13 GB per token. L4: 300 / 17.13 = about 17.5 tokens/s. H100 SXM: 3,350 / 17.13 = about 196 tokens/s.
- 70B FP8 with an 8k sequence reads 70.55 + 2.68 = 73.23 GB per token. H200: 4,800 / 73.23 = about 66 tokens/s.
Batching raises total throughput because the weights are read once per step for all sequences in the batch. That is why the KV cache budget, which caps the batch, matters as much as raw speed. Turn throughput into cost per million tokens with model-serving economics.
Checklist before you request GPU capacity
- Exact model and revision, with
config.jsonvalues for layers, KV heads and head dimension. - Weight precision and the checkpoint's real file size.
- Maximum context length you will allow, not the model maximum.
- Peak concurrent sequences, from expected users and request duration.
- KV cache precision (16-bit or FP8) and an accuracy check if FP8.
- Total memory from the formula, compared with 90% of nameplate.
- If more than one GPU: tensor parallel size, head divisibility and interconnect.
- Throughput and latency targets, and a test plan to check them.
- Numbers entered in the GPU memory calculator and attached to the quote request.
Common mistakes
- Counting only the weights. At 32k context and 16 users, the 8B cache is 4.3x the FP16 weights.
- Using attention heads instead of KV heads. For Llama 3.1 that overstates the cache by 4x (8B) or 8x (70B).
- Leaving the context at the model maximum. Llama 3.1 allows 131,072 tokens. If you only need 8k, cap it; otherwise the engine may reserve for the maximum or reject the configuration.
- Treating INT4 size as exact. Embedding and output layers at 16-bit and quantization scales add gigabytes.
- Planning at 100% of nameplate. Runtime context, fragmentation and engine margins take real memory.
- Splitting across GPUs without fast links. Tensor parallelism over slow links can fit the model and still miss latency.
- Mixing GB and GiB. 80 GB is about 74.5 GiB. Pick one unit and keep it.
Frequently asked questions
How much GPU memory does Llama 3.1 8B need?
About 16 GB for FP16 weights alone. With one 8k-token sequence and overhead, about 19 GB, which fits a 24 GB GPU. With 16 sequences at 32k context it needs about 93 GB because of the KV cache.
Can Llama 3.1 70B run on one GPU?
At FP16 the weights alone are 141 GB, so only GPUs with more memory than that, such as a 192 GB MI300X, can hold it, and only with short context. At FP8 (70.6 GB) it needs more than an 80 GB card once cache and overhead are added (about 80.6 GB at 8k x 1), so a 141 GB H200 is the comfortable single-GPU option. At INT4 (35.3 GB plus extras) it fits one 80 GB GPU at modest context.
Why does concurrency change memory so much?
Every active sequence keeps its own KV cache for every token it holds. Sixteen sequences need sixteen times the cache of one, while the weights are shared.
Does FP8 KV cache hurt quality?
It can, slightly, depending on model and task. It halves cache memory, so test it on your own prompts and compare outputs with a 16-bit cache before relying on it.
Is the 10% overhead figure exact?
No. It is a planning assumption for this guide. Measure the real figure by loading the model with your engine, batch size and context settings and reading GPU memory in use.
Which GPUs can BroadNet Cloud quote?
GPU classes are quoted subject to supplier availability, and the exact GPU model, count, interconnect and region are confirmed in the written quote. Send the numbers from the checklist with your request.
Sources
- The Llama 3 Herd of Models (Table 3: model hyperparameters), Meta AI
- Llama 3.1 model card, Meta
- meta-llama/Llama-3.1-8B model page and config.json, Meta on Hugging Face
- meta-llama/Llama-3.1-70B model page and config.json, Meta on Hugging Face
- Mastering LLM Techniques: Inference Optimization (KV cache size), NVIDIA
- vLLM engine arguments, vLLM project
- vLLM: conserving memory (tensor parallelism, max_model_len, max_num_seqs), vLLM project
- NVIDIA L4 Tensor Core GPU, NVIDIA
- NVIDIA L40S GPU, NVIDIA
- NVIDIA A100 Tensor Core GPU datasheet, NVIDIA
- NVIDIA H100 Tensor Core GPU, NVIDIA
- NVIDIA H200 Tensor Core GPU, NVIDIA
- NVIDIA DGX B200, NVIDIA
- AMD Instinct MI300X accelerator data sheet, AMD

