Home Work & Income LLM VRAM Calculator

LLM VRAM Calculator

Estimate the GPU memory a model needs at a given quantisation and context length, and see if it fits your card.

Advertisement

How it works

Weights are model size times bytes per weight. The KV cache keeps two tensors per layer per token: 2 x layers x KV heads x head dimension x 2 bytes for FP16. About 1 GB goes to the runtime. Adding the three gives the memory you need.

Advertisement

Formula

Weights (GB) = params x bits / 8.
KV (GB) = 2 x layers x kv_heads x head_dim x ctx x 2 / 1e9.
Total = weights + KV + 1.

Example

Model size (billion parameters): 7; Context length (tokens): 8,192; Layers: 32; KV heads: 8. VRAM needed: 5.57

Frequently asked questions

Why 2 bytes in the KV cache?

The cache is usually kept in FP16, so each value is 2 bytes. Halve it for an 8-bit cache.

Does this include the operating system?

No. It is GPU memory only, for one request at one context length.

Advertisement

Related calculators

Salary Calculator

Convert a salary between hourly, weekly, every two weeks, monthly and yearly pay.

Time Card Calculator

Add up your clock-in and clock-out times for the week, take off breaks, and get total hours and pay.

Prorated Salary Calculator

Pay for part of a month, for example when you start or leave in the middle of it.

IP Subnet Calculator

Network address, broadcast address, subnet mask and usable host range for any IPv4 address and prefix length.