tools

LLM Memory / VRAM Estimator

Estimate GPU or device memory for running or fine-tuning an LLM, from weights, KV cache and optimizer state.

[loading tool…]

How it works

Inference needs the weights, the KV cache, and some working memory:

weights  = parameters × bytes per parameter
KV cache = 2 × layers × KV heads × head dim × tokens × sequences × bytes per value
total    = (weights + KV cache) × (1 + overhead)

The KV cache stores one key and one value vector per layer and per KV head for every token in the context. Models with grouped-query attention (most recent ones) have far fewer KV heads than attention heads. For Llama 3.1 8B that is 128 KiB per token at 16-bit, so an 8k context costs 1 GiB and 128k costs 16 GiB.

Full fine-tuning with mixed-precision Adam needs about 16 bytes per parameter: 16-bit weights and gradients (2 + 2), a 32-bit master copy of the weights (4) and two 32-bit Adam moments (4 + 4).

LoRA keeps the base weights frozen (at any precision; 4-bit is QLoRA) and trains small adapters, typically 0.1–2 % of the parameters, at 16 bytes each.

What the estimate leaves out

  • Training activations, which grow with batch × sequence length and are often the largest term; gradient checkpointing trades them for compute.
  • Framework-specific buffers. The inference overhead % stands in for activations, the CUDA context (~0.3–1 GB) and fragmentation; 10–20 % is a reasonable start.
  • Paged or offloaded KV caches (vLLM, llama.cpp) can use less than the full-context worst case.

Presets

Layer counts, KV heads and head dims come from each model’s published config.json. Treat results as a planning estimate; measure on the real runtime before buying hardware.

References

esc
All tools
ADC / DAC Resolution Calculator[embedded]
Base64 Encoder / Decoder[dev]
Battery Runtime Calculator[hardware]
Chmod Calculator[dev]
CRC Calculator[embedded]
Cron Expression Builder[dev]
CSV ⇄ JSON Converter[dev]
Duty-Cycle Battery Life[embedded]
Generator Wattage Calculator[hardware]
Hash Generator[dev]
HTML Entity Encoder[dev]
JSON Formatter & Validator[dev]
JSONPath Tester[dev]
JWT Decoder[dev]
LED Resistor Calculator[embedded]
LLM Memory / VRAM Estimator[ai]
Lorem Ipsum Generator[text]
Markdown Preview[text]
Markdown Table Generator[text]
Number & Float Inspector[embedded]
Number to Words[text]
Ohm's Law Calculator[embedded]
Password Generator[dev]
Quantization Size Calculator[ai]
RC / LC Filter Calculator[embedded]
Regex Tester[dev]
Register / Bitfield Viewer[embedded]
Resistor Color Code[embedded]
Roman Numeral Converter[text]
Solar Battery Bank Sizing[hardware]
Solar Panel Output[hardware]
SQL Formatter[dev]
Subnet / CIDR Calculator[dev]
Tensor Shape Calculator[ai]
Timer / PWM Calculator[embedded]
UART Baud Rate Error[embedded]
Unix Timestamp Converter[dev]
UPS Runtime Calculator[hardware]
URL Encoder & Parser[dev]
UUID Generator & Inspector[dev]
Voltage Divider Calculator[embedded]
Voltage Drop Calculator[hardware]
Wire Size Calculator[hardware]
XML Formatter[dev]
YAML Validator & Converter[dev]
Commands
Toggle theme (auto → light → dark)
Copy link to this page
Go to all tools
Lire en français
↑↓ move↵ open⌘↵ new tab