How many GPU layers should you use in KoboldCpp?

Leave GPU Layers on -1 (auto). KoboldCpp then measures your free VRAM and puts as many layers on the GPU as fit, after reserving room for the context, other loaded models and a 1024 MB safety margin. After loading, check the log for CUDA0, Vulkan0 or MTL0 buffer lines: the line that says offloaded N/N layers alone does not prove the GPU is used. If VRAM is left free, lower the autofit margin or raise layers by hand; if you run out of memory, lower the context first.

Checked against KoboldCpp 1.124.2 · updated 13 Nov 2026
  • lab-lnx: Linux test VM · 4 vCPU · 15 GB · no GPU
  • gha-w25: Windows Server 2025 test machine · 4 vCPU · 16 GB · no GPU
  • sw-vulkan: Software Vulkan (Mesa lavapipe) · reports exact VRAM allocations, speeds meaningless
How we test
On this page
  1. How many KoboldCpp GPU layers fit?
  2. What a GPU layer is
  3. What the layer number means
  4. Step 1: Choose a GPU backend
  5. Step 2: Leave layers on auto and launch
  6. Step 3: Check where the model really runs
  7. Step 4 (optional): Tune by hand
  8. Layers versus speed
  9. The Windows shared GPU memory trap
  10. Fit more on the GPU
  11. MoE models: keep experts in RAM
  12. Laptops, integrated GPUs and “Unable to detect VRAM”
  13. Several GPUs

How many KoboldCpp GPU layers fit?

Pick your model, card and context. The result says whether everything fits, how many layers go on the GPU, and what to type in KoboldCpp.

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

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

For any other model, a Hugging Face link, a local file, or the extra options, use the full calculator. All sizes come from the model’s own file header, so they are exact for the file you pick. The compute buffers are estimates.

What a GPU layer is

A language model is a stack of identical blocks, called layers. An 8B model has 32 of them. Each layer’s weights live either in video memory (VRAM) or in system RAM. A layer on the GPU is computed by the GPU, a layer in RAM is computed by the CPU, and the slowest part sets the pace for every word.

VRAM holds more than layers. It also holds the KV cache (the memory of the conversation, which grows with the context you ask for), a compute buffer for working space, and any other model you loaded, such as a vision projector or an image model. The layers get what is left.

GPU memory, Llama 3.1 8B Q4_K_M at 8K context (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

The model’s weights are the biggest block, the KV cache is the one you control with the context size, and the free space is what autofit keeps as margin and what you could use for more context. Two things stay in system RAM even when every layer is on the GPU: the token-embedding table and, in our runs, the output matrix F63.

What the layer number means

KoboldCpp counts one more layer than the model has. In a sweep of a 24-layer model, --gpulayers 12 moved 11 repeating layers to the device, and only --gpulayers 25 (24 + 1) or more, or -1, moved all 24 F65. The table shows the sizes KoboldCpp logged. These runs used a software Vulkan device in our lab, so they show where memory goes, not how fast it is.

Layer sweep: Qwen2.5-0.5B Q4_K_M, 4096 context, software Vulkan device
000051.00R-lab2-3-u24-vk-gl0-alloc-q4-ctx4096
6548.5610.6240.38R-lab2-3-u24-vk-gl6-alloc-q4-ctx4096
1211106.3923.3827.62R-lab2-3-u24-vk-gl12-alloc-q4-ctx4096
1817166.4436.1214.88R-lab2-3-u24-vk-gl18-alloc-q4-ctx4096
99 (or 25, or -1)24235.7651.000R-lab2-3-u24-vk-gl99-alloc-q4-ctx4096

The calculator knows this: it prints layers + 1 in the launch command and the readout counts repeating layers. If you only want everything on the GPU, -1 or any number above the layer count does the same.

Step 1: Choose a GPU backend

The backend decides which engine KoboldCpp uses. In the launcher, open Quick Launch and set Backend:

  • NVIDIA: Use CUDA. Command line: .
  • AMD, Intel, or NVIDIA with the smaller file: Use Vulkan. Command line: .
  • Mac: Metal is automatic.
  • Use CPU puts nothing on the GPU, whatever the layer number says.
The KoboldCpp launcher on first open: Quick Launch tab with Backend, the default checkboxes and the 16384 context slider.lab-w25-launcher-quick-01 · lab-w25 · KoboldCpp 1.124.2 · 13 Nov 2026
KoboldCpp launcher Quick Launch tab with Use CPU backend, ContextShift and FlashAttention ticked, context 16384

The shot is from a test PC without a GPU, which is why Backend reads “Use CPU” F30. On a PC with a supported GPU the list also offers CUDA or Vulkan. The Hardware tab holds the GPU layers box and the autofit fields used below:

The Hardware tab of the KoboldCpp launcher with its default values, on Windows (no GPU, so the backend shows "Use CPU").gha-w25-launcher-hardware-01 · gha-w25 · KoboldCpp 1.124.2 · 13 Nov 2026
KoboldCpp launcher, Hardware tab, default settings

Step 2: Leave layers on auto and launch

Leave GPU Layers at -1, which is the default . With -1 KoboldCpp runs autofit: it measures free VRAM, counts the context you asked for plus 256 tokens F06, counts any other model you loaded, keeps 1024 MB free, and chooses the layers. On Quick Launch and Hardware the launcher shows this as Force AutoFit, and Autofit Padding (MB) sets the margin (, ).

Automatic layer choice has changed over the years, so older guides disagree with the current program:

  • 1.71: --gpulayers -1 first estimates the layers.
  • 1.72: the launcher defaults GPU layers to -1, and the estimate counts image and Whisper models.
  • 1.75: the default is -1. Before that it was 0, which is why old guides tell you to type a number.
  • 1.104: --autofit appears.
  • 1.108: -1 turns on autofit by itself, the layer box is hidden, and --autofitpadding is added.

In our log, a run with -1 printed the reserve and the result F65:

Autofit with -1R-lab2-3-u24-vk-gl-1-alloc-q4-ctx4096 · u24-vk-gl-1 · KoboldCpp 1.124.2 (software GPU)
Unable to detect VRAM, but autofit may still be used if applicable.1Autofit Reserve Space: 1024 MB2Autofit Success: 1, Autofit Result: -c 4224 -ngl -13load_tensors: offloaded 25/25 layers to GPU4
  1. Unable to detect VRAM, but autofit may still be used if applicable.: The VRAM reading did not work on this software device. Autofit still ran.
  2. Autofit Reserve Space: 1024 MB: The padding kept free.
  3. Autofit Success: 1, Autofit Result: -c 4224 -ngl -1: What autofit chose.
  4. load_tensors: offloaded 25/25 layers to GPU: All layers fit on this small model.

We have not yet measured autofit against the largest layer count that works by hand on a physical card, so we cannot say how conservative it is on a real GPU. People on forums report that it can leave VRAM unused (one report: 7 of 41 layers on a card that could hold more). The next steps explain how to find out whether yours does.

Step 3: Check where the model really runs

This is the step that matters. The console prints a line such as offloaded 25/25 layers to GPU. That line counts the layers assigned to the GPU path. It does not prove that the GPU holds them. In our test with no GPU at all, with --gpulayers 99, KoboldCpp printed offloaded 25/25 layers to GPU and kept everything on the CPU F17. The lines that tell you where memory really is end in buffer size.

CPU: --gpulayers 99 with no GPUR-run1-lnx-nocuda-fail-gpulayers-no-gpu · lab-lnx · KoboldCpp 1.124.2 (F17)
load_tensors: offloaded 25/25 layers to GPU1llama_kv_cache:        CPU KV buffer size =    51.00 MiB2
  1. load_tensors: offloaded 25/25 layers to GPU: This line does not prove the GPU is used. Here nothing is on a GPU.
  2. llama_kv_cache: CPU KV buffer size = 51.00 MiB: The cache is in system RAM.
GPU device: the same model with a Vulkan deviceR-lab2-3-u24-vk-gl99-alloc-q4-ctx4096 · u24-vk · KoboldCpp 1.124.2 (software GPU, F35, F65)
load_tensors: offloaded 25/25 layers to GPUload_tensors:      Vulkan0 model buffer size =   235.76 MiB1llama_kv_cache:    Vulkan0 KV buffer size =    51.00 MiB2sched_reserve:    Vulkan0 compute buffer size =    39.77 MiB3
  1. load_tensors: Vulkan0 model buffer size = 235.76 MiB: Weights on the device.
  2. llama_kv_cache: Vulkan0 KV buffer size = 51.00 MiB: Context memory on the device.
  3. sched_reserve: Vulkan0 compute buffer size = 39.77 MiB: Working space on the device.

The second log comes from a software Vulkan device, not a physical card, because we do not yet have a real GPU in the lab. The line format is the same on real GPUs, but we have no real CUDA log yet.

NVIDIA, CUDA
Lines start with CUDA0 (users report; we have no CUDA log yet)
Vulkan
Lines start with Vulkan0 (tested, F35)
Apple Metal
Lines start with MTL0 (users report)
In system RAM
Lines start with CPU, or CPU_Mapped

If KoboldCpp prints No GPU or CPU backend was selected…, Unable to detect VRAM. and Auto Selected Default Backend (flag=0), it chose the CPU for you F18. Go to Not using the GPU.

Open Task Manager, Performance, then your GPU, and watch Dedicated GPU memory. Do not rely on the “3D” graph, which can look idle while the GPU computes. Dedicated memory should rise by about the size of the model plus the cache.

Or paste your log and get a verdict:

The result appears here. Nothing you paste leaves this page.

Step 4 (optional): Tune by hand

Only bother if, after a long prompt, more VRAM is free than your margin. Check VRAM while the model reads a long prompt, because the compute buffer grows during prompt processing. Then, in this order:

  1. Lower the padding. Set Autofit Padding (MB), or , to a smaller number, for example half. This keeps the automatic behaviour.
  2. Set the layers. Type a number in from the calculator, then raise it a few layers at a time, each time loading the model and sending a long prompt.

We have not yet measured the step size and margin that are safe on a physical card, so there is no rule of thumb here. The calculator’s margin is the same 1024 MB autofit uses. Remember the extra layer in KoboldCpp’s count (above).

Layers versus speed

Every layer left on the CPU slows the whole answer, so the last layers you add matter most. We have not measured the curve on a physical GPU yet, so we do not publish one: our software Vulkan device is not a GPU and its speeds mean nothing. What we did measure is the CPU end: Llama 3.1 8B on four CPU cores generated 5.3 tokens per second F37, which is reading speed. A card that holds all layers is much faster, and partial offload sits between the two. When we have a real card, this section gets the layers-versus-speed chart.

The Windows shared GPU memory trap

On Windows, NVIDIA’s driver can spill video memory that does not fit into system RAM (“Shared GPU memory”) instead of failing. A model that is slightly too big then loads and becomes very slow. Users report this often, and the same on AMD (issue #1413). We have not measured it. To see whether it is happening, watch Shared GPU memory next to Dedicated GPU memory in Task Manager while the model generates.

Users report that the setting is in the NVIDIA Control Panel, Manage 3D settings, CUDA - Sysmem Fallback Policy, and that choosing “Prefer No Sysmem Fallback” turns the spill into an out-of-memory error. That is the point: you then lower the layers or the context. We have not seen the menu ourselves, so check the wording on your driver version. To undo, set the policy back to the driver default.

Fit more on the GPU

In rough order of how much they help. The calculator shows the saving for your own model.

  1. Lower the context. The KV cache is linear in context F10. See context size.
  2. Quantise the KV cache with q8_0 or q4_0. At 32K of context on our small model, peak RAM fell from 976 MB to 794 MB and 698 MB F10. Flash attention is on by default F09, which the quantised cache needs.
  3. Use a smaller quantisation of the same model.
  4. Keep the vision projector on the CPU with .
  5. Unload models you do not need: image, speech and text-to-speech models take VRAM.
  6. Lower the batch size with ; the compute buffer grows with it.
  7. Keep the KV cache in RAM with (the “No KV offload” box). More layers fit on the GPU, and generation slows down.
  8. Close other programs that use the GPU.

MoE models: keep experts in RAM

A mixture-of-experts model such as Qwen3-30B-A3B holds many expert networks but uses only a few for each word, so the experts can sit in system RAM while the attention layers stay on the GPU. keeps the expert weights of the first N layers in RAM (all layers if you give no number). does the same for dense feed-forward weights, keeps a VRAM cache for experts that otherwise live on the CPU, and gives full control. The launcher fields are “MoE CPU Layers”, “FFN CPU Layers” and “MoE Cache MiB”. Autofit can also set MoE placement by itself.

For a 30B-A3B model at Q4_K_M on a 12 GB card, the calculator shows a partial fit without --moecpu and a full fit of the attention layers with it. We have not measured MoE speed yet.

Laptops, integrated GPUs and “Unable to detect VRAM”

On a laptop with two GPUs, choose the NVIDIA one by its GPU ID on the Hardware tab or in ; the built-in graphics chip is usually 1 or 0 depending on the machine, so check the list in the console.

Unable to detect VRAM, please set layers manually. means autofit could not measure the card, as with some AMD and Intel chips and with machines that lack the vendor tools (issue #1748). Set yourself from the calculator. No GPU backend found, or could not automatically determine GPU layers. means a CPU-only build or no backend. See Not using the GPU and the error list.

Several GPUs

Autofit splits the model across all selected GPUs. and the main GPU are covered on the multi-GPU page when it is published.

Frequently asked questions

How many GPU layers should I use in KoboldCpp?

Leave GPU Layers at -1, the default. KoboldCpp then picks the number itself. If you want to choose, use the calculator on this page: it gives the layer count for your model, quantisation, context size and card. Then check the log, because a layer number only matters if the buffer lines say CUDA0, Vulkan0 or MTL0.

What does GPU layers -1 mean?

It turns on autofit. Since 1.108 KoboldCpp measures free VRAM and chooses the layers (and other placement) automatically, keeping a safety margin of 1024 MB by default. 0 means everything on the CPU, and a positive number is a fixed count. Older guides say the default is 0; that was true until 1.74.

Why does autofit leave VRAM unused?

It keeps a safety margin (--autofitpadding, 1024 MB by default), counts the context you asked for plus 256 tokens, and also counts any image, Whisper or vision model you loaded. The compute buffer also grows during a long prompt. If a long prompt still leaves more than the margin free, lower the padding or raise the layers by hand and test with a long prompt.

How do I know KoboldCpp is using my GPU?

Look at the buffer lines, not at 'offloaded N/N layers'. In our tests that line printed 25/25 even when nothing was on a GPU. If the model and KV cache lines start with CUDA0, Vulkan0 or MTL0, the GPU holds them. If they start with CPU, it does not.

Can I run a model bigger than my VRAM?

Yes. The layers that do not fit run on the CPU from system RAM. It works, and it is slower, because the CPU layers set the pace. The calculator shows how many layers fit and whether the rest fit in your RAM.

What is low VRAM mode (No KV offload)?

It is the --lowvram flag, the 'No KV offload' box on the launcher's Hardware tab. It keeps the KV cache in system RAM instead of VRAM. More layers then fit on the GPU, and generation gets slower because the cache is read over the PC's memory bus.

Can KoboldCpp run on a 4 GB GPU?

Yes, with a small model or partial offload. A 3B model at a 4-bit quantisation and a modest context can fit, and larger models run with some layers on the CPU. Enter 4 GB and your model in the calculator to see the split; we have not measured a 4 GB card yet.