Why Ollama Is Slow Even When It Runs on the GPU
Slow Ollama replies on a GPU come from loading, reading the prompt or writing the answer. How to measure each with Ollama's own timings, and what to change.
By Cogniq Labs ResearchEvidence policy

If ollama ps shows 100% GPU and replies are still slow, the problem is not the GPU being unused. "Slow" is really three different things: loading the model, reading your prompt, and writing the answer. Ollama measures all three separately. Find which one is slow, then fix that one. Changing settings without measuring is how people spend an afternoon and see no difference.
If ollama ps shows a CPU or a CPU/GPU split instead, start with why Ollama is using the CPU. A model that does not fit is the most common cause of slowness, and it has different fixes.
Measure before changing anything
The quickest way is the verbose flag:
ollama run llama3.2 --verbose
After each reply, Ollama prints timing statistics, including how long loading took and the speed of prompt reading and generation.
The API gives the same numbers in more detail. The API reference lists these fields in each response:
| Field | What it measures |
|---|---|
load_duration |
Time spent loading the model |
prompt_eval_count |
Tokens in the prompt |
prompt_eval_cached_count |
Prompt tokens reused from the cache |
prompt_eval_duration |
Time reading the uncached prompt tokens |
eval_count |
Tokens written in the reply |
eval_duration |
Time writing the reply |
All durations are in nanoseconds. For generation speed in tokens per second, the reference gives the formula: eval_count / eval_duration * 10^9.
Now read the three numbers:
| What is large | The stage that is slow | Go to |
|---|---|---|
load_duration |
Loading | Section 1 |
prompt_eval_duration |
Reading the prompt | Section 2 |
eval_duration relative to eval_count |
Writing | Section 3 |
As illustrative arithmetic: a reply with eval_count of 200 and eval_duration of 4,000,000,000 nanoseconds ran at 50 tokens per second. If the same request spent 20 seconds in load_duration, generation speed is not your problem.
An example of reading the numbers
These figures are invented, to show the method:
| Field | Request A | Request B |
|---|---|---|
load_duration |
18 s | 0.02 s |
prompt_eval_count |
300 | 12,000 |
prompt_eval_duration |
0.3 s | 14 s |
eval_count |
250 | 250 |
eval_duration |
5 s | 5 s |
Both write at 50 tokens per second, so the GPU generates at the same speed in each. Request A is slow because the model was loaded from disk, which is fixed by keeping it loaded. Request B is slow because it reads twelve thousand tokens before writing anything, which is fixed by sending less or reusing the cached start. A faster GPU would help neither of them much.
1. Slow loading
Loading copies the weights from disk into GPU memory. It is slow for large models and slow disks, and it happens more often than people expect.
The model keeps being unloaded. The FAQ says models stay in memory for 5 minutes by default. After a pause longer than that, the next request loads it again. Keep it loaded with the keep_alive parameter on a request, or set it for the server:
OLLAMA_KEEP_ALIVE=30m ollama serve
A negative value such as -1 keeps the model loaded indefinitely. This holds GPU memory, so use it only if you want the model always ready.
Several models are taking turns. If your tools use two or three models and they do not all fit, Ollama unloads one to load another. Check ollama ps during use. Using one model, or fewer large ones, avoids the swapping.
Preload before you need it. The FAQ shows that sending an empty request loads a model:
curl http://localhost:11434/api/generate -d '{"model": "llama3.2"}'
The disk is slow. Weights stored on a network drive or an old hard disk load slowly. OLLAMA_MODELS moves the model folder, so put it on the fastest local drive.
2. Slow prompt reading
Reading the prompt grows with its length. A long chat history, a large document or a long system prompt all add to it, on every request.
Send less. Trim old messages, retrieve only the relevant parts of documents, and keep system prompts short. A shorter prompt is the most reliable speed-up there is.
Reuse the start. prompt_eval_cached_count shows how many tokens were reused. If it stays near zero between requests in the same conversation, something near the start of the prompt is changing, such as a timestamp or a random ID. Keep the beginning identical and put what changes at the end, the same rule as in prompt caching.
Watch the context window. A window that is too small cuts off the prompt. One that is much larger than needed reserves memory that can push the model off the GPU. Ollama's context length page says the default now depends on your GPU memory. Set the length you need, as covered in Ollama context length.
3. Slow writing
Generation produces one token at a time, and each token requires reading the model's weights from memory. That makes the speed depend mostly on how much data has to be read per token, and how fast your GPU memory is.
Use a smaller or more compressed model. Fewer bytes per token means faster generation. A lower quantization of the same model, or a smaller model, is the most direct way to go faster. Quantization has a quality cost, so test on your own tasks.
Check the number of GPUs. The FAQ explains that if a model fits on one GPU, Ollama loads it there, which usually performs best because it moves less data over the PCI bus. If it does not fit on one, it is spread across all of them. A model split across two cards can be slower than a smaller one on one card.
Count parallel requests. If several requests run at once, they share the GPU, so each one is slower. OLLAMA_NUM_PARALLEL controls how many run together, and each extra slot also reserves context memory. For a single user, one request at a time is usually fastest per reply.
Reasoning models write more than you see. A model that thinks before answering produces many tokens before the visible reply. The tokens per second may be fine while the wait is long. Compare eval_count with the length of the answer you actually see.
Long conversations slow down. As the history grows, every new token has more earlier context to attend to, and the prompt gets longer on each turn. Starting a new chat for a new topic helps.
Settings worth testing
| Setting | What it does | Test it when |
|---|---|---|
OLLAMA_FLASH_ATTENTION=1 |
Forces Flash Attention, which Ollama otherwise enables where supported | Long contexts |
OLLAMA_KV_CACHE_TYPE=q8_0 |
Stores the context cache at about half the memory | Context is pushing the model off the GPU |
OLLAMA_NUM_PARALLEL=1 |
One request at a time | Single user, replies feel slow under load |
Shorter num_ctx |
Less reserved memory | The window is far larger than your prompts |
Change one thing at a time and compare the same prompt before and after. Several changes at once leave you not knowing which one worked, or whether one made things worse.
A fair way to compare
- Pick one prompt that looks like your real work, long enough to matter.
- Run it three times and ignore the first, which may include loading.
- Record
load_duration,prompt_eval_durationand tokens per second. - Change one setting and restart Ollama.
- Run the same prompt three times again.
- Keep the change only if the numbers improve and the answers are still good.
Also close other programs using the GPU, because a browser or a game taking memory changes the results.
If it was fast yesterday
A sudden slowdown usually means something changed. Check these before tuning:
- An Ollama update, which can change default settings such as the context length.
- A different model or tag. Pulling a model again can fetch a newer or larger file.
- A tool sending new settings. An app may now ask for a longer context or run requests in parallel.
- Another program on the GPU that was not running before.
- A laptop on battery, or a machine that is overheating and slowing itself down.
Compare ollama ps with what you expect: the size, the context and the processor. A changed number there usually points straight at the cause.
Downloads are a different problem
If "slow" means pulling a model, none of this applies, since it is your network. The FAQ describes a specific cause on Windows 10 with WSL2, where disabling Large Send Offload on the WSL network adapter improves speed. If the app cannot reach Ollama at all, see Ollama connection refused.
What we do not know
We have not benchmarked these settings. How much each one helps depends on the GPU, the model, the driver and the Ollama version, and some change little on some hardware. The timing fields are the only reliable guide for your setup, so measure, change one thing and measure again.
Sources
- Ollama API reference — GitHub
- Ollama FAQ — Ollama
- Context length — Ollama
- Modelfile reference — Ollama
Frequently asked questions
Why is Ollama slow even with a GPU?
Because "slow" can be three different things: loading the model, reading a long prompt, or writing the answer. Ollama reports each separately. Measure first, then fix the stage that takes the time, since the fixes are different.
How do I measure Ollama tokens per second?
Run ollama run with the --verbose flag, or call the API and divide eval_count by eval_duration and multiply by 1,000,000,000. Ollama's API reference gives that formula. eval_duration is in nanoseconds.
Why is the first reply from Ollama slow?
The model has to be loaded into memory. By default Ollama unloads it after 5 minutes of no use, so a request after a pause pays the load time again. Set OLLAMA_KEEP_ALIVE or the keep_alive parameter to keep it loaded.
Does a longer context make Ollama slower?
A longer prompt takes longer to read, and a larger context window reserves more memory. If that memory pushes part of the model onto the CPU, generation slows sharply, so check ollama ps after changing the context length.
Does Flash Attention speed up Ollama?
It mainly reduces memory use as the context grows, and Ollama enables it automatically where supported. You can force it with OLLAMA_FLASH_ATTENTION=1. Its effect on speed depends on your hardware and model, so measure before and after.
Related reading
Ollama 'Model Requires More System Memory': The Fix
What Ollama's two memory numbers actually measure, why Docker and WSL report less than you have, which versions show this error, and how to fix it.
llama.cpp 'Failed to Fit Params': What It Means
The failed to fit params line in llama.cpp is a warning, not the crash. What the fit step adjusts, what each reason means, and which flags to change.
Why Ollama Is Using the CPU Instead of Your GPU
When Ollama runs on the CPU, the cause is a driver, a container, a card Ollama does not support, or a model too big for the GPU. How to tell which, and fix it.