Skip to content

LLM VRAM Calculator & GPU Sizing Guide

Calculate precise VRAM requirements, KV cache overhead, and distributed cluster topologies for hosting large language models like Llama 3.1, DeepSeek, and Qwen across NVIDIA A100, H100, and H200 accelerators.

Free LLM VRAM Calculator

Calculate precise GPU memory requirements for inference, full fine-tuning, and LoRA training. Plan your cluster architecture accurately for Llama 3.1, DeepSeek, Qwen, and custom models across modern NVIDIA accelerators.

Model and Workload Parameters

8,192 tokens
4,09632,76865,536131,072
1
1163264

VRAM Breakdown

Model Weights140 GB
KV Cache20 GB
Activation Overhead1 GB
CUDA Runtime2 GB
Total VRAM Required163 GB

Denpex Developer Tools

Install the Denpex VS Code and Open VSX extension with over 2,000 active installs for real-time diagnostics. Decode offline browser logs instantly with our GPU log analyzer.

Hardware Cluster Sizing and GPU Recommendations

Estimated minimum GPU count required to host 163 GB VRAM safely with headroom for concurrency.

GPU AcceleratorVRAM per GPURequired CountEstimated Utilization
NVIDIA H10080 GB3 GPUs68%
NVIDIA H200141 GB2 GPUs58%
NVIDIA A10080 GB3 GPUs68%
NVIDIA B200192 GB1 GPU85%
NVIDIA L40S48 GB4 GPUs85%
NVIDIA RTX 409024 GB7 GPUs97%

Under the Hood: LLM Memory Calculation Formulas

Accurate GPU memory planning requires accounting for three distinct consumption vectors: static model parameter weights, dynamic KV cache allocation during inference, and temporary activation workspace memory.

1. Weight Memory

Model weights consume memory directly proportional to active parameter count and quantization precision.

Memory (GB) = (Parameters in Billions) * Bytes per Parameter
  • FP16 / BF16: 2 bytes
  • FP8 (E4M3 / E5M2): 1 byte
  • INT4 / GPTQ: 0.5 bytes

2. KV Cache Memory

Key-value cache scales dynamically based on concurrent request batch size and sequence length.

KV (GB) = 2 * Layers * KV_Heads * Head_Dim * Batch * Seq_Len * Bytes

High context windows like 128k tokens can easily consume hundreds of gigabytes under heavy concurrent load.

3. Overhead & Headroom

Framework buffers, CUDA graphs, and workspace allocations require safety margins.

Total VRAM = (Weights + KV Cache) * 1.20 headroom factor

Allocating a 20 percent buffer prevents out-of-memory errors during peak inference spikes.

Cluster Topologies: Tensor Parallelism vs Pipeline Parallelism

When a single GPU lacks sufficient VRAM to hold model weights or KV cache, model parallelism distributes the workload across multiple accelerators. Choosing the right parallel strategy is critical for maximizing tokens per second while minimizing inter-GPU communication bottlenecks.

Tensor Parallelism (TP)

Tensor parallelism splits individual weight matrices across multiple GPUs within the same high-speed NVLink domain. Because synchronization occurs frequently during matrix multiplications, TP is typically restricted to 4 or 8 GPUs per node.

  • Best for: Low latency generation on single nodes.
  • Hardware requirement: NVLink interconnect (900 GB/s on H100).
  • Common configurations: TP 2, TP 4, TP 8.

Pipeline Parallelism (PP)

Pipeline parallelism divides sequential model layers across multiple nodes. Stage 1 processes early layers and passes intermediate activations to stage 2 on the next node, accommodating massive models that exceed single-node memory limits.

  • Best for: Extremely large models like 405B or MoE variants.
  • Hardware requirement: InfiniBand or high speed Ethernet clusters.
  • Common configurations: PP 2, PP 4, PP 8.

Recommended Hardware Configurations for 70B and 405B Models

Deploying frontier models requires balancing memory capacity against memory bandwidth. Below are validated production deployment topologies for popular open weight architectures.

Model ScalePrecisionMinimum VRAMRecommended Cluster
Llama 3.1 70BFP16160 GB2x H100 (80GB) or 1x H200 (141GB with quantization buffer)
Llama 3.1 70BFP885 GB1x H100 (80GB) with strict context limits or 1x H200 (141GB)
Llama 3.1 405BFP8450 GB8x H100 (80GB) with TP 8
Llama 3.1 405BFP16850 GB32x A100 / H100 with TP 8 and PP 4

Frequently Asked Questions

How does KV cache memory scale with batch size and context window?

KV cache memory scales linearly with context length and batch size, calculated as 2 multiplied by the number of layers, number of key-value heads, head dimension, batch size, context length, and bytes per parameter precision. For long context windows like 128k tokens, the KV cache frequently exceeds model parameter memory during high concurrency inference.

What is activation memory and how does it impact training versus inference?

Activation memory stores intermediate tensor outputs during the forward pass so gradients can be computed during backpropagation. During inference, activation memory is minimal and bounded by batch size and maximum sequence length, whereas during training it dominates peak VRAM consumption, often requiring activation checkpointing or recomputation.

What are the trade-offs between FP16, FP8, and INT4 precision?

FP16 offers full baseline precision requiring 2 bytes per parameter with zero quantization loss. FP8 cuts weight memory in half using 1 byte per parameter with negligible perplexity degradation when using scales like E4M3 or E5M2. INT4 quantizes weights to 0.5 bytes per parameter, yielding massive memory savings for serving large models on smaller GPU counts, though it requires specialized kernel support and careful calibration.

How do you determine tensor parallel and pipeline parallel splits for 70B and 405B models?

Tensor parallelism splits individual weight matrices across GPUs within a single high speed NVLink node (typically TP 4 or TP 8) to minimize communication latency. Pipeline parallelism divides model layers across multiple nodes when a single node cannot fit the weights or KV cache. For a 405B model in FP16 requiring over 800GB of VRAM, a combination of tensor parallel 8 and pipeline parallel 4 across a 32 GPU cluster is standard.