All tools
Runtime & errors · free, no sign-up

How many layers can I offload to my GPU?

When a model does not fit, llama.cpp keeps what it can on the GPU and runs the rest on the CPU. Getting --n-gpu-layers right is the difference between usable and unusable.

4 inputs4 questions answeredUpdated for 2026 hardware
CPU vs GPU Offload Calculator — How many layers can I offload to my GPU?
Answer first

The short answer

Computed from this tool’s default settings — your hardware and the rest as most people start. Change them below for your own case.

Layers that fit on the GPUAll 33

Everything fits — use --n-gpu-layers 999 and keep the whole model on the card.

The calculator

CPU vs GPU Offload Calculator

The --n-gpu-layers value that fits, instead of guessing until it loads.

Your setup

Capacity follows total parameters, even for mixture-of-experts models.

8,192

The KV cache grows linearly with this. It is the biggest lever you have.

Layers that fit on the GPUAll 33

Everything fits — use --n-gpu-layers 999 and keep the whole model on the card.

Estimated layers33From parameter count
Per layer0.14 GB
Budget after cache19.7 GB
On GPU4.50 GB
llama-server -m model-Q4_K_M.gguf \
  --n-gpu-layers 999 \
  --ctx-size 8192

# 999 means "offload everything"
Inputs

What each setting changes

Every input moves the result for a reason. This is what each one does and where to find the value for your own machine.

SettingDefaultWhat it changes
Your hardwareRTX 4090 · 24 GBThe machine the model runs on. Usable memory decides what fits and memory bandwidth decides how fast it runs, so this moves every figure below.
Model size8B — Llama 3.1 8B classCapacity follows total parameters, even for mixture-of-experts models.
QuantisationQ4_K_M — 4.5 bits/weight5 options, from Q8_0 — 8.5 bits/weight to Q3_K_M — 3.5 bits/weight.
Context length8192 tokensThe KV cache grows linearly with this. It is the biggest lever you have.
Worked examples

Real answers across model size

The same calculation run at a range of settings, with everything else left at its default. These are computed by the tool itself, not written by hand.

Model sizeLayers that fit on the GPUEstimated layersPer layerBudget after cache
1B — Llama 3.2 1B classAll 17170.03 GB20.6 GB
7B — Mistral / Qwen 7B classAll 32320.12 GB19.8 GB
14B — Qwen 14B classAll 40400.20 GB19.2 GB
32B — Qwen 32B classAll 53530.34 GB18.3 GB
120B — gpt-oss 120B class19 of 83830.81 GB15.7 GB

Everything fits — use --n-gpu-layers 999 and keep the whole model on the card.

Method

How this is calculated

No lookup tables and no invented constants. Here is the arithmetic, so you can check it against your own numbers.

llama.cpp puts as many transformer layers on the GPU as you tell it to with --n-gpu-layers, and keeps the rest on the CPU. Too many and it fails at load time with a CUDA out-of-memory error; too few and you leave speed on the table.

Layer counts are not published per model, so the figure below is estimated from the parameter count using the shape transformer families actually use. Treat it as a starting point: if it fails to load, drop two or three and retry.

These are well-founded engineering estimates, not benchmark results. Your quantisation, runtime and context length all move the real number, and usable memory is an assumption rather than a specification. See the full methodology for every assumption behind these figures.

Use cases

Who this is for

The three situations that bring people to this calculation.

Use case 01

Model slightly too big

Find the layer count that loads without crashing.

Use case 02

Tuning by hand

Skip the trial-and-error loop of stepping the number down.

Use case 03

Deciding

See whether offloading beats dropping a quantisation rung.

Walkthrough

How to use this calculator

Four steps, no account, nothing leaves your browser.

  1. Set your hardware

    Start at the top of the panel. Every figure recalculates as you change it — there is no submit button, because watching the number move is the point.

  2. Adjust the rest to match your setup

    3 further settings: model size, quantisation, context length. Defaults are the common case, so change only what differs for you.

  3. Read the headline, then the table

    The large figure answers the question. The table underneath shows how the answer changes across nearby settings, which is usually where the decision actually gets made.

  4. Check it against the method

    The arithmetic is written out above. If a number looks wrong for your hardware, the assumptions are the first place to look — usable memory and quantisation are the two that vary most.

Questions

How many layers can I offload to my GPU: common questions

The questions people ask about this, answered without hedging.

What is --n-gpu-layers?

How many transformer layers to place on the GPU; the rest run on the CPU. Setting it high enough to hold the whole model is always fastest, and 999 is the usual shorthand for "all of them".

How many layers should I offload?

As many as fit after the KV cache. If loading fails, drop by two or three and retry — layer counts vary between models, so the estimate is a starting point.

Is partial offload worth it?

Often not. Every token passes through every layer, so the slow side dominates: moving 20% of layers to RAM can cost more than half your throughput. A lower quantisation that fits entirely on the card is usually faster.

Does more system RAM help?

It lets a bigger model load, but does not make it fast. Speed follows the bandwidth of whichever memory holds the weights, and system RAM is roughly ten times slower than a modern card.

The rest of the set

All 50 run on the same arithmetic, so answers across them agree.

Coverage

Searches this page answers

Different ways of asking the same question, all resolved above.

n-gpu-layers calculatorllama.cpp gpu layershow many layers to offloadpartial gpu offload llmollama num_gpu layerscpu gpu split inferencellama cpp offload settingshow many layers can i offload to my gpucpu vs gpu offload calculatorcpu vs gpu offload calculator onlinefree cpu vs gpu offload calculator
Next step

Now find the models that fit

Sizing is only half the problem. Model Radar takes your hardware and shows which models actually run on it, ranked by what they are good at — the same arithmetic as this page, applied to every model worth running.