All tools
Context · free, no sign-up

What context length can Ollama fit on my GPU?

Ollama defaults to a short context and silently truncates anything longer, which is why long prompts appear to be ignored. Raising num_ctx fixes it — until the cache no longer fits.

3 inputs4 questions answeredUpdated for 2026 hardware
Ollama Context Length Calculator — What context length can Ollama fit on 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.

Largest context that fits97,280 tokens

RTX 4090 holds a 8B model at Q4_K_M with about 97,280 tokens of context. Ollama's default is far lower, so set it explicitly.

The calculator

Ollama Context Length Calculator

The largest num_ctx your card holds, with the command to set it.

Your setup

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

Largest context that fits97,280 tokens

RTX 4090 holds a 8B model at Q4_K_M with about 97,280 tokens of context. Ollama's default is far lower, so set it explicitly.

Usable memory22.1 GB
Weights4.50 GB
Left for cache16.6 GB
# per session
/set parameter num_ctx 97280

# or in a Modelfile
PARAMETER num_ctx 97280
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.
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 sizeLargest context that fitsUsable memoryWeightsLeft for cache
1B — Llama 3.2 1B class340,992 tokens22.1 GB0.56 GB20.5 GB
7B — Mistral / Qwen 7B class107,520 tokens22.1 GB3.94 GB17.1 GB
14B — Qwen 14B class58,368 tokens22.1 GB7.88 GB13.2 GB
32B — Qwen 32B class8,192 tokens22.1 GB18.0 GB3.08 GB
120B — gpt-oss 120B classWeights alone do not fit22.1 GB67.5 GB0.00 GB

RTX 4090 holds a 1B model at Q4_K_M with about 340,992 tokens of context. Ollama's default is far lower, so set it explicitly.

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.

Memory for a model is three things added together: the weights, which are parameters × bits-per-weight ÷ 8; the KV cache, which grows linearly with context length; and about a gigabyte of runtime overhead for the CUDA context, activations and framework.

Capacity follows a model’s total parameter count even for mixture-of-experts designs, because the router may select any expert on the next token and all of them must stay resident. Only throughput follows the active count.

Ollama defaults to a small context and silently truncates beyond it, which is why long prompts appear to lose information. Setting num_ctx explicitly is the fix, up to whatever your memory allows.

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

Long prompts truncated

Find the num_ctx that holds your whole input.

Use case 02

Modelfile tuning

Set a value that fits your card instead of guessing.

Use case 03

RAG pipelines

Size context around retrieved chunks.

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

    2 further settings: model size, quantisation. 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

What context length can Ollama fit on my GPU: common questions

The questions people ask about this, answered without hedging.

What is num_ctx in Ollama?

The context window in tokens — how much of the conversation the model can see. Ollama has historically defaulted to a small value, so long prompts are quietly cut from the front rather than raising an error.

How do I change num_ctx?

Either per session with /set parameter num_ctx 8192, or permanently in a Modelfile with a PARAMETER num_ctx line, then ollama create. The API accepts it in the options object on each request.

Why did raising num_ctx slow everything down?

A larger cache pushes total memory past what the card holds, so Ollama offloads layers to the CPU. The fix is a smaller context, not more layers.

What num_ctx should I use?

The smallest that holds your actual prompts. 8192 covers most chat and code work; go higher only when you genuinely feed long documents.

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.

ollama num_ctxollama context lengthollama context window sizeollama modelfile num_ctxollama truncating promptincrease ollama contextollama 128k contextwhat context length can ollama fit on my gpuollama context length calculatorollama context length calculator onlinefree ollama context length 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.