How much VRAM you need to run an LLM comes down to three numbers: the size of the weights, the size of the KV cache for the context you want, and a little room for the runtime. This guide shows each one with real numbers, gives a table for common model sizes, and works one example through from start to finish. It takes about 10 minutes to read, and afterwards you can size any model yourself or check it in seconds with the VRAM calculator.
What uses GPU memory when you run an LLM
| Part | What it is | What makes it grow |
|---|---|---|
| Weights | The model itself, loaded once | Parameter count and bits per parameter |
| KV cache | The model's working memory of the text it is reading | Context length and how many conversations run at once |
| Runtime overhead | Compute buffers and the GPU driver's own share | Mostly fixed, about 1 to 2 GB |
If the three together do not fit, the model does not load, or it loads with a much shorter context than you wanted.
How to estimate the size of the weights
The rule of thumb:
weights in GB = parameters in billions x bits per parameter / 8A model at 16 bits (FP16 or BF16, the original precision) needs about 2 GB per billion parameters. Quantization stores each number with fewer bits, so the file shrinks. Q4_K_M is about 4.5 to 5 bits per parameter in practice, because a few layers are kept at higher precision. Q8_0 is about 8.5. Our quantization page explains how to pick one.
Real file sizes from Hugging Face, for Qwen3 8B (8.2 billion parameters):
| File | Size | Bits per parameter (about) |
|---|---|---|
Qwen3-8B-Q4_K_M.gguf | 5.03 GB | 4.9 |
Qwen3-8B-Q8_0.gguf | 8.71 GB | 8.5 |
Qwen3-8B safetensors (BF16) | 16.38 GB | 16 |
Why context length and users grow the KV cache
Every token the model reads leaves a key and a value in every layer. That store is the KV cache. Its size per token is:
KV bytes per token = 2 x layers x kv_heads x head_dim x bytes per valueThe 2 is one key and one value. bytes per value is 2 for the usual 16-bit cache. kv_heads is the number of key and value heads, which is smaller than the number of attention heads in most new models because of grouped-query attention (several query heads share one key and value head, which cuts the cache several times over).
Multiply by the context length, then by how many conversations the GPU holds at once:
KV cache = KV bytes per token x context tokens x conversations at onceThis is why a model that fits easily with a short chat can run out of memory with a long document or a few users. The weights stay the same; the cache grows with every token.
A worked example: Qwen3 8B at Q4_K_M with 32k context
The numbers come from the model's config.json on Hugging Face: 36 layers, 8 key and value heads (against 32 attention heads), and a head dimension of 128. The model was trained for up to 40,960 tokens.
- Weights. The
Q4_K_Mfile is 5.03 GB. - KV cache per token. 2 x 36 x 8 x 128 x 2 bytes = 147,456 bytes, about 144 KB.
- KV cache for 32k tokens. 147,456 x 32,768 = 4.83 GB.
- Runtime overhead. BitsRun reserves 1,200 MiB (1.26 GB) per GPU for llama.cpp's buffers.
- Total. 5.03 + 4.83 + 1.26 = about 11.1 GB.
One NVIDIA L4 has 23,034 MiB (24.15 GB) usable, so one 32k conversation fits with room to spare. Now add users. Each extra 32k conversation adds another 4.83 GB. After the weights and overhead, about 17.6 GB is left for the cache: three 32k conversations (14.5 GB) fit, four (19.3 GB) do not. With shorter conversations, more fit.
Grouped-query attention matters here. If every one of the 32 attention heads kept its own key and value, the cache would be four times larger: 19.3 GB for a single 32k conversation.
Which GPU fits common model sizes
Approximate weight sizes from real Hugging Face files (Qwen3 for 8B to 32B, Llama 3.3 for 70B), and the BitsRun GPU each one gets:
| Model size | Q4_K_M | Q8_0 | FP16 / BF16 |
|---|---|---|---|
| 7B to 8B | 5.0 GB, L4 | 8.7 GB, L4 | 16.4 GB, L4 (vLLM, about 19,000 tokens of context) |
| 12B to 14B | 9.0 GB, L4 | 15.7 GB, L4 | 29.5 GB, L40S |
| 27B to 32B | 19.8 GB, L40S | 34.8 GB, L40S | 65.5 GB, 4x L4 |
| 70B | 42.5 GB, 4x L4 | about 75 GB, published split into parts, cannot be deployed yet | about 141 GB, too large |
Q4_K_M and Q8_0 files are GGUF and run on llama.cpp. The FP16 column is the original safetensors weights on vLLM. Other models of the same size land close to these numbers, but always check the real file.
How BitsRun decides what fits
The model sizer reads the real file size and applies the same rule every time. Usable memory per GPU:
| GPU | Usable memory | Per hour |
|---|---|---|
| NVIDIA L4, 24 GB | 23,034 MiB | $0.95 |
| NVIDIA L40S, 48 GB | 46,068 MiB | $3.20 |
| 4x NVIDIA L4, 96 GB | 92,136 MiB (4 x 23,034) | $8.52 |
What a model needs:
- llama.cpp (GGUF): weights x 1.2 + 1,536 MiB.
- vLLM (safetensors): (weights x 1.05 + 2,048 MiB + the KV cache for 8,192 tokens) / 0.92. vLLM uses 92% of GPU memory and leaves the rest for the driver.
It picks the cheapest GPU where that fits. Two examples:
- Qwen3 32B at
Q4_K_Mis 19.76 GB, which is 18,847 MiB. 18,847 x 1.2 + 1,536 = 24,152 MiB. That is more than an L4's 23,034, so it goes on an L40S. - Qwen3 8B in BF16 on vLLM: 15,623 MiB of weights, plus 1,152 MiB of KV cache for 8,192 tokens. (15,623 x 1.05 + 2,048 + 1,152) / 0.92 = 21,309 MiB, which fits an L4. What is left of the L4 gives about 19,000 tokens of context.
Once the GPU is chosen, the context you get is whatever cache fits in the memory left over, capped at the model's own limit and at 65,536 tokens. You can trade context for more requests at once under Performance.
How Macs and gaming GPUs compare
- RTX 3090 and RTX 4090: both have 24 GB, the same as one L4, so the L4 column above is a fair guide. Your desktop and other apps use part of that memory, so leave a little more room.
- Apple Silicon Macs: the CPU and GPU share one pool of unified memory. A MacBook Pro with an M5 Max can have up to 128 GB, enough to load a 70B model at
Q4_K_M(42.5 GB) that no 24 GB card can hold. The same pool also holds macOS and your apps, so you cannot give all of it to the model.
A local machine is the right choice when you want to experiment for free. A hosted endpoint is the right choice when other people or your app need to reach the model at any hour, and you would rather pay by the second than keep a computer on.
If something goes wrong
| Message or code | What to do |
|---|---|
model_too_large | The model is bigger than 4x L4. Pick a lower quant, such as Q4_K_M. |
gpu_too_small | You chose a GPU below what the model needs. Pick a larger one or leave GPU empty. |
context_too_long | The request is longer than the endpoint's memory length. Shorten it or raise memory length. |
| "Not enough room on this GPU" | Lower memory length or requests at once, or pick a bigger GPU. |
Every code is explained in Error codes.
Size your model now
Type a model into the VRAM calculator to see the weights, the cache and the GPU, or check the hourly bill with the cost calculator. When you are ready, deploy it: Create your account. Related guides: Run a Hugging Face model as a private API and Host a GGUF model as an OpenAI-compatible API.
Frequently asked questions
How much VRAM does a 7B or 8B model need?
At Q4_K_M the weights are about 5 GB, and with a 32k context for one conversation the total is about 11 GB. That fits a 24 GB GPU such as an NVIDIA L4, with room for a few conversations at once.
How much VRAM does a 70B model need?
A 70B model at Q4_K_M has about 42.5 GB of weights, so it needs more than one 48 GB GPU once you add the cache and overhead. On BitsRun it runs on 4x NVIDIA L4 (96 GB); the 16-bit original, about 141 GB, does not fit.
Why does a longer context need more memory?
Every token in the context keeps a key and a value in every layer of the model, called the KV cache. For Qwen3 8B that is 147,456 bytes per token, so 32,768 tokens take 4.83 GB on top of the weights.
Does a 4-bit quant hurt quality?
A little. Q4_K_M is close to the original for most chat and support use, and a larger model at Q4_K_M usually beats a smaller one at Q8_0 on the same GPU. If answers get careless with facts or code, try Q6_K or Q8_0.
Can I run a model that needs more memory than one GPU?
Yes. BitsRun offers 4x NVIDIA L4 with 96 GB in total, which holds 70B models at 4-bit and 32B models at full precision. The model sizer picks it for you when nothing smaller fits.