Skip to content
runonprem

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.

B
tokens
GiB
GiB
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

  1. Choose a model preset (architecture from its published config.json) or enter parameters, layers, KV heads and head dimension yourself.
  2. Pick the quantisation. The bits per weight are approximate averages; your model file size ÷ parameters × 8 gives the exact value.
  3. Set the context length you plan to use and your GPU memory.
  4. 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)

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

Formulas reviewed November 27, 2026 by Novian · runs entirely in your browser · methodology