Local AI
LLM VRAM calculator
Does a local LLM fit on your graphics card? Estimate the GPU memory for the model weights, the KV cache for your context length, and runtime overhead — for llama.cpp/Ollama-style quantisations or full FP16.
- Weights
- 4.49 GiB
- KV cache
- 1.00 GiB
- Overhead
- 0.80 GiB
- Total VRAM needed
- 6.29 GiB
Fits in 12 GiB with 5.71 GiB to spare.
How to use it
- Choose a model preset (architecture from its published config.json) or enter parameters, layers, KV heads and head dimension yourself.
- Pick the quantisation. The bits per weight are approximate averages; your model file size ÷ parameters × 8 gives the exact value.
- Set the context length you plan to use and your GPU memory.
- If it does not fit, try a smaller quantisation, a shorter context, an 8-bit KV cache, or partial CPU offload.
Formula and method
weights = parameters × bits per weight ÷ 8 KV cache = 2 × layers × context tokens × KV heads × head dimension × bytes per element total = weights + KV cache + runtime overhead (1 GiB = 2³⁰ bytes)
- GGUF k-quants mix block types, so their effective bits per weight are averages (e.g. Q4_K_M ≈ 4.8).
- Runtime overhead (CUDA context, compute buffers) depends on the engine, batch size and GPU; 0.5–1.5 GiB is typical for single-user inference. Desktop sessions on the same GPU also use memory.
- This is an estimate for inference; fine-tuning needs much more memory.
Worked example
Llama 3.1 8B (8.03 B parameters, 32 layers, 8 KV heads, head dimension 128) at ~4.8 bits: 8.03 × 10⁹ × 4.8 ÷ 8 = 4.82 × 10⁹ bytes = 4.49 GiB. An 8,192-token FP16 KV cache: 2 × 32 × 8192 × 8 × 128 × 2 bytes = 2³⁰ bytes = 1.00 GiB. With 0.8 GiB overhead the total is 6.29 GiB — it fits an 8 GiB card.
FAQ
Why does context length matter so much?
The KV cache grows linearly with the number of tokens in the context. Long contexts on large models can need as much memory as the weights themselves.
What happens if the model does not fit?
Engines like llama.cpp and Ollama can keep some layers on the CPU. It still works, but tokens per second drop sharply, so a smaller quantisation that fits fully is often faster.
How exact is this?
Weights and KV cache follow directly from the model shape; overhead varies by engine and settings. Treat the result as a planning estimate and leave some margin.
Related tools
- Power consumption & electricity cost calculator — Turn a server’s idle and load watts into kWh and electricity cost per day, month and year, with official prices per country and US state.
- Docker Compose generator — Build a clean compose.yaml service — image, ports, volumes, environment, restart policy — with correct YAML quoting.
Formulas reviewed November 27, 2026 by Novian · runs entirely in your browser · methodology