How to speed up slow Ollama models by lowering the context length

If Ollama runs a model partly on the CPU, it gets slow. Check the instructions for your exact model before choosing this setting or amount. It suits anyone running local models on a single GPU.

YouTube video: Ollama Running Slow? One Setting Made It 5x Faster (RTX 5090)

YouTube’s video details do not confirm captions. Check CC in the player for available tracks.

11 chapters. Tap a step to jump to it.Chapters from the creator
Choose a chapter (11)
Video length
3 min 43 s
Time to do it
10 minutes
Difficulty
Easy
Steps
8

What you need

Steps

  1. Check the instructions for your exact model before choosing this setting or amount.

  2. In a second terminal, run ollama ps and look at the PROCESSOR column. It should say 100% GPU.

  3. If it shows a CPU share, the context window is too large for your VRAM. Lower it.

  4. For a quick test, type /set parameter num_ctx 32768 inside the running ollama session.

  5. Run ollama ps again and confirm PROCESSOR now says 100% GPU.

  6. To keep the setting, run setx OLLAMA_CONTEXT_LENGTH 32768 on Windows.

  7. On Linux or macOS, run export OLLAMA_CONTEXT_LENGTH=32768 instead.

  8. Quit Ollama from the tray and start it again so the new value applies.

Tips and common mistakes

A smaller context window means the model forgets older chat text sooner, so raise it only if you have spare VRAM.

Your tokens per second will differ by GPU and model, so compare your own before and after numbers.

The 140 tok/s result came from the context fix alone, not from a different engine.

Questions

What does 100% GPU in ollama ps mean?

It means the whole model is loaded in VRAM and the CPU is not handling part of it. That is the fast state you want.

Does lowering num_ctx reduce model quality?

No, the weights stay the same. You only shorten how much conversation history the model can hold at once.

Do I need to set this every time?

No. The /set command lasts for the session, while the OLLAMA_CONTEXT_LENGTH variable keeps the value after a restart.

The notes are drafted automatically from video details and general task knowledge. How the guide was prepared

Report a correction

More in Computers & Phones

See all