Will it fit? VRAM and GPU layers calculator

Choose a model (or paste a Hugging Face GGUF link), your GPU memory and context size: the calculator shows how much VRAM the weights, KV cache and buffers need, how many layers fit, and the KoboldCpp settings to use.

Checked against KoboldCpp 1.124.2 · updated 13 Nov 2026
  • lab-lnx: Linux test VM · 4 vCPU · 15 GB · no GPU
  • sw-vulkan: Software Vulkan (Mesa lavapipe) · reports exact VRAM allocations, speeds meaningless
How we test

VRAM and model fit calculator

Layers, memory breakdown and launch values for your model, card and context.

Runs in your browser. Nothing is uploaded.

1. Model

Layers, KV heads and tensor sizes were read from the real file headers on Hugging Face. File size shown is the download size.

2. Your hardware
Reserve and safety margin

Defaults: 512 MB for the desktop on Windows and Linux (0 if the card drives no display), and KoboldCpp's autofit padding of 1024 MB. What this assumes

3. Context and cache
Extras: side models, --lowvram, --moecpu

Llama 3.1 8B Instruct Q4_K_M · 16K context · KV f16

Fits completely

All 32 layers fit on the GPU, with the context and buffers.

calculated from the model's tensor sizes; compute buffers are estimates calibrated on two measured models (F36, F42).

GPU memory 6.06 GB of 10.5 GB usable of 12 GB
010.5 GB usable of 12 GB
  • Model weights 3.90 GB
  • KV cache 2.03 GB
  • Compute buffer 132 MB
  • Free 4.44 GB
System RAM 959 MB of 29.0 GB usable of 32 GB
029.0 GB usable of 32 GB
  • Weights on CPU 693 MB
  • Host compute buffer 267 MB
  • Free 28.1 GB

Launch values

  • --gpulayers 33
  • --contextsize 16384

KoboldCpp counts one extra layer for the output layer, so --gpulayers 33 puts all 32 repeating layers on the GPU (F65). Leaving --gpulayers on auto (-1) lets autofit choose; it keeps a 1 GB padding and may offload fewer layers than this calculation. GPU layers guide

koboldcpp --model Meta-Llama-3.1-8B-Instruct-Q4_K_M.gguf --gpulayers 33 --contextsize 16384

Weights 4.58 GB · 32 layers · 8 KV heads × 128 · KV cache 2.03 GB

How this works

Each layer of the model costs its weights plus its slice of the KV cache. The calculator fills your GPU memory, after the desktop reserve and a safety margin, with the compute buffer, any side models and as many layers as fit. The rest go to system RAM, which is checked too. The sizes come from the model’s own tensor table, read from the file header, so they are exact for the file you pick. Compute buffers are estimates calibrated on two measured models. Every assumption is listed below.

Data: KoboldCpp 1.124.2 · 13 Nov 2026 · methodology

How to read the result

The big line is one of four states.

  • Fits completely. Every layer, the context and the buffers fit on the GPU. This is the fastest way to run a model.
  • Fits with N of M layers on the GPU. The first N layers run on the GPU and the other layers run on the CPU from system RAM. It works, and it is slower, because the CPU layers set the pace. More layers on the GPU means faster output. See GPU layers.
  • Runs on the CPU only. Nothing fits on the GPU with this context, or there is no GPU.
  • Doesn’t fit in GPU and RAM. The model needs more memory than the GPU and system RAM together offer. The list under the result shows what to change and how much each change saves.

Below the line, the bar shows where the memory goes. This is a measured example (F36): Llama 3.1 8B Q4_K_M with 8K of context on a 12 GB card, using the allocation sizes KoboldCpp logged.

GPU memory, measured allocations (F36) 5.1 GB of 10.5 GB usable of 12 GB
010.5 GB usable of 12 GB
  • Model weights 3.9 GB
  • KV cache 1.0 GB
  • Compute buffer 124 MB
  • Free 5.4 GB
  • Model weights are the layers on the card. They are the biggest block and depend on the quantisation.
  • KV cache is the memory for the conversation so far. It grows with the context you ask for. See the formula below.
  • Compute buffer is working space for each batch of tokens. It is small next to the other two.
  • Other models are a vision projector, Whisper or an image model, if you turned them on.
  • A hatched block means memory that does not fit anywhere.

The launch values are what to give KoboldCpp: for the layers, for the context and when you chose a smaller cache. Leaving at its default of -1 is often fine: autofit picks a number for you. The calculator is for the cases where you want to know in advance, want the largest context a card can hold, or want to check a model before you download it.

How much VRAM does context use? The KV cache formula

The KV cache stores the keys and values the model has already computed, so it does not redo them for every new token. Its size follows one formula, in words:

2 (keys and values) × layers × context tokens × KV heads × head size × bytes per value

KoboldCpp allocates the context you ask for plus 256 tokens F06, and the default context is 16384 F05. For Qwen2.5-0.5B (24 layers, 2 KV heads of 64 values) at 16384 that is 16640 cells, 2 × 24 × 16640 × 2 × 64 × 2 bytes = 195 MiB at f16, and KoboldCpp’s log says KV buffer size = 195.00 MiB F10. The table is computed by the same code the calculator runs, and the build stops if it ever stops matching the logged sizes.

Qwen2.5-0.5B KV cache at three context sizes: logged by KoboldCpp and calculated
Context you ask forCells allocated (+256)Logged KV buffer sizeCalculated
4,0964,35251.00 MiB51.00 MiB
16,38416,640195.00 MiB195.00 MiB
131,072131,3281539.00 MiB1539.00 MiB
32,768, KV q4_033,024108.84 MiB108.84 MiB

A bytes-per-value of 2 is f16. The quantised caches use less: q8_0 is 1.0625 bytes, q5_1 is 0.75 and q4_0 is 0.5625. In the same test, peak memory at 32K of context fell from 976 MB to 794 MB with q8_0 and to 698 MB with q4_0 F10. A quantised cache needs flash attention, which is on by default F09; with it off, only the K cache is quantised.

Two kinds of models change the arithmetic. A sliding-window model such as Gemma 2 keeps the full context in only some layers; the rest keep a window of tokens, so its cache is much smaller at long context. A mixture-of-experts model has its own attention sizes, and its weights split into attention and expert parts, which is what moves to system RAM. The calculator handles both when it can read the layout from the file header, and tells you when it cannot.

Is 8 GB, 12 GB, 16 GB or 24 GB of VRAM enough?

It depends on the model and the context. These tables are calculated by the calculator with the defaults (Windows desktop reserve of 512 MB, safety margin of 1024 MB, KV cache f16, 32 GB of RAM). They show the largest quantisation that fits completely. “Tight” means less than 5% of the usable memory is left. These are calculated values: we have not yet measured these cards, so treat them as a guide and use the calculator for your exact case.

At 8K of context

Largest quantisation that fits completely, by GPU memory, at 8,192 tokens of context
Model8 GB12 GB16 GB24 GB
Qwen2.5 0.5B Instruct
0.6B
fits
Q8_0
fits
Q8_0
fits
Q8_0
fits
Q8_0
Llama 3.2 3B Instruct
3.2B
fits
Q8_0
fits
Q8_0
fits
Q8_0
fits
Q8_0
Qwen2.5 7B Instruct
7.6B
fits
Q6_K
fits
Q8_0
fits
Q8_0
fits
Q8_0
Llama 3.1 8B Instruct
8.0B
tight
Q6_K
fits
Q8_0
fits
Q8_0
fits
Q8_0
Qwen3 8B
8.2B
fits
Q5_K_M
fits
Q8_0
fits
Q8_0
fits
Q8_0
Gemma 2 9B It
9.2B
tight
IQ4_XS
tight
Q8_0
fits
Q8_0
fits
Q8_0
Mistral Nemo Instruct 12B
12.3B
doesn't fit
IQ4_XS: 37/40 layers
fits
Q6_K
fits
Q8_0
fits
Q8_0
Qwen2.5 14B Instruct
14.8B
doesn't fit
IQ4_XS: 37/48 layers
tight
Q5_K_M
fits
Q6_K
fits
Q8_0
Qwen3 30B-A3B (MoE)
30.5B, MoE
doesn't fit
IQ4_XS: 18/48 layers
doesn't fit
IQ4_XS: 31/48 layers
doesn't fit
IQ4_XS: 43/48 layers
fits
Q5_K_M
Qwen2.5 32B Instruct
32.8B
doesn't fit
IQ4_XS: 22/64 layers
doesn't fit
IQ4_XS: 36/64 layers
doesn't fit
IQ4_XS: 51/64 layers
fits
Q4_K_M
Llama 3.3 70B Instruct
70.5B
doesn't fit
IQ4_XS: 12/80 layers
doesn't fit
IQ4_XS: 21/80 layers
doesn't fit
IQ4_XS: 30/80 layers
doesn't fit
IQ4_XS: 47/80 layers

At 16K of context

Largest quantisation that fits completely, by GPU memory, at 16,384 tokens of context
Model8 GB12 GB16 GB24 GB
Qwen2.5 0.5B Instruct
0.6B
fits
Q8_0
fits
Q8_0
fits
Q8_0
fits
Q8_0
Llama 3.2 3B Instruct
3.2B
fits
Q8_0
fits
Q8_0
fits
Q8_0
fits
Q8_0
Qwen2.5 7B Instruct
7.6B
fits
Q6_K
fits
Q8_0
fits
Q8_0
fits
Q8_0
Llama 3.1 8B Instruct
8.0B
fits
Q4_K_M
fits
Q8_0
fits
Q8_0
fits
Q8_0
Qwen3 8B
8.2B
tight
Q4_K_M
fits
Q8_0
fits
Q8_0
fits
Q8_0
Gemma 2 9B It
9.2B
doesn't fit
IQ4_XS: 35/42 layers
fits
Q6_K
fits
Q8_0
fits
Q8_0
Mistral Nemo Instruct 12B
12.3B
doesn't fit
IQ4_XS: 31/40 layers
fits
Q5_K_M
fits
Q8_0
fits
Q8_0
Qwen2.5 14B Instruct
14.8B
doesn't fit
IQ4_XS: 31/48 layers
fits
IQ4_XS
fits
Q6_K
fits
Q8_0
Qwen3 30B-A3B (MoE)
30.5B, MoE
doesn't fit
IQ4_XS: 17/48 layers
doesn't fit
IQ4_XS: 29/48 layers
doesn't fit
IQ4_XS: 41/48 layers
tight
Q5_K_M
Qwen2.5 32B Instruct
32.8B
doesn't fit
IQ4_XS: 20/64 layers
doesn't fit
IQ4_XS: 33/64 layers
doesn't fit
IQ4_XS: 46/64 layers
tight
Q4_K_M
Llama 3.3 70B Instruct
70.5B
doesn't fit
IQ4_XS: 11/80 layers
doesn't fit
IQ4_XS: 19/80 layers
doesn't fit
IQ4_XS: 28/80 layers
doesn't fit
IQ4_XS: 44/80 layers

Two rules of thumb fall out of the tables. A 7B to 9B model at a 4-bit quantisation fits an 8 GB card with room for a normal context. The step to 12 GB buys a 12B to 14B model or a longer context; 16 GB and 24 GB make 30B-class models practical. For what to run, see Which model should I use? and quantisation.

What GPU layers are

A language model is a stack of identical layers, 32 in a typical 8B model. Every layer you put on the GPU runs fast; every layer you leave behind runs on the CPU, from system RAM, and sets the speed of the whole answer. “N of M layers on the GPU” is the split.

sets the number. -1, the default, asks KoboldCpp to work it out with autofit, and 0 keeps everything on the CPU. KoboldCpp also accepts -ngl and --n-gpu-layers as other names for the same flag. The GPU layers guide covers how to choose the number by hand and how to check it worked.

What this LLM VRAM calculator assumes

Each assumption is labelled with how we know it: measured in our own runs, upstream (from KoboldCpp’s own help or source), or estimate.

AssumptionValueBasis
Weights per layer, output and embedding sizesSummed from the file’s tensor tableExact, read from the header
KV cacheThe formula above, context + 256 cellsMeasured, matches logged sizes (F10, F36)
Compute buffer on the cardA base that grows with model size, plus 2 bytes × batch per cellEstimate, calibrated on two measured models (F36, F42)
Output matrixIn system RAM unless you tick “count it on the GPU”Measured on a software Vulkan device (F36, F42). A real card may place it on the GPU: tick the box to be cautious
Token embedding tableAlways in system RAMMeasured (F36)
Desktop reserve512 MB per card on Windows and Linux, 0 on macOSEstimate, editable
Safety margin1024 MB per cardUpstream: --autofitpadding default (visible in our logs)
Quantised KV cacheNeeds flash attention (on by default); with it off only K is quantisedUpstream help text, F09
Apple SiliconOne memory pool; the GPU may use about two thirds of RAM up to 36 GB and three quarters aboveEstimate until we measure it on a Mac
Several GPUsLayers split in proportion to memory; each card holds its own compute bufferEstimate
System RAM checkCPU-side weights, KV and host buffers against RAM minus 3 GB for the systemEstimate
Side modelsWhisper from the whisper.cpp memory table; image models are rough preset sizes; vision projector and others by file sizeEstimate, you can type your own sizes

Accuracy and our tests

We tested the calculator in the following ways.

  • KV cache sizes. The formula reproduces the sizes KoboldCpp logged for Qwen2.5-0.5B exactly: 51.00, 195.00 and 1539.00 MiB at 4096, 16384 and 131072 tokens, and 108.84 MiB at 32768 with q4_0 F10.
  • Predicted against measured memory. The table compares the calculator’s prediction with the allocations logged in five of our runs. All are within 10%. These runs used a software Vulkan device in our lab, so they check the arithmetic and not real-card behaviour.
Predicted and measured device memory for five measured runs
CaseModelContextLayers on GPUPredictedMeasuredErrorResult
F36-8b-8kLlama 3.1 8B Instruct Q4_K_M8,19232/325173.0 MiB5172.8 MiB+0.0%F36 l8b-ctx8192.log
F36-8b-32kLlama 3.1 8B Instruct Q4_K_M32,76832/328269.0 MiB8268.8 MiB+0.0%F36 l8b-ctx32768.log
F42-05b-4kQwen2.5 0.5B Instruct Q4_K_M4,09624/24328.1 MiB326.6 MiB+0.4%F42 u24-vk-alloc
F42-05b-8kQwen2.5 0.5B Instruct Q4_K_M8,19224/24380.1 MiB378.6 MiB+0.4%F42 u24-vk-alloc
F42-05b-32kQwen2.5 0.5B Instruct Q4_K_M32,76824/24692.1 MiB690.6 MiB+0.2%F42 u24-vk-alloc
  • Header reading. The reader parses 13 test headers: four quantisations of one real model, a real vision-model text part, a real vision projector, a real embedding model, and synthetic headers built from public model configs for a dense 8B, a sliding-window 9B, a mixture-of-experts 30B, a tied-embedding model and a two-part split. Sizes from the real files add up to the real file sizes within 1.5%, the difference being the vocabulary stored in the full header.
  • Network. In the browser test, local-file reading made no request at all, and a pasted link made requests only to huggingface.co.
  • Local file speed. A 20 GB file reads in well under a second, because only the header is read.

Known limits. We do not have a real GPU, so the “predicted layers within ±2 of the maximum measured” check on real cards (T-MEM-01) has not been run, and the tool says “calculated” rather than “calibrated on a card”. Brand-new architectures with unknown keys may be sized wrongly, and the tool says so when it falls back to a guess. Image model sizes are presets.

Your files stay on your computer

Local file. When you pick a .gguf file, your browser reads only its first few megabytes with the File API, enough for the header and tensor list. The file is not uploaded and the page makes no network request while reading it. Hugging Face link. Your browser asks huggingface.co for the first few megabytes with an HTTP range request; the model weights are not downloaded and no other site is contacted. The page’s security policy allows these requests on this page only. See the privacy page.

Frequently asked questions

How many GPU layers should I use in KoboldCpp?

As many as fit in your GPU memory after the context and buffers are counted. The calculator above gives the number for your exact model, context and card. You can also leave --gpulayers at -1, the default, and KoboldCpp's autofit picks a value for you; it keeps 1024 MB free by default, so it can choose fewer layers than the calculator.

How much VRAM does a 16K context need?

It depends on the model, because the cache grows with layers, KV heads and head size. For Llama 3.1 8B, 8K of context needs a 1,056 MiB KV cache and 32K needs 4,128 MiB, so 16K needs about 2,080 MiB at f16. Quantising the cache to q8_0 roughly halves that. Pick your model in the calculator to see the figure for it.

Is 8 GB of VRAM enough for a local LLM?

Yes for 7B to 9B models at a 4-bit quantisation with a normal context, and no for anything much bigger without moving layers to the CPU. The tables on this page show which listed models fit completely on 8, 12, 16 and 24 GB at 8K and 16K of context.

Why does KoboldCpp's autofit choose fewer layers than this calculator?

Autofit leaves a padding of free VRAM (1024 MB by default, set with --autofitpadding) and the calculator's default safety margin matches it. If you see a bigger gap, the padding you use differs, a side model such as a vision projector or image model is loaded, or the real compute buffer is larger than our estimate. Compare the offloaded layers line in your log with the result here.

Does this calculator work for Ollama or LM Studio?

The weights and KV cache arithmetic apply to any GGUF runner, because it comes from the model file. The flags, the 256-token context padding and the 1024 MB padding are KoboldCpp's, so the layer count can differ in other programs.

Is my model file uploaded?

No. When you drop a file, your browser reads only the first few megabytes (the header) with the File API and nothing is sent anywhere. When you paste a Hugging Face link, your browser asks huggingface.co for the same few megabytes directly.