Local AI model too slow for coding (Ollama, LM Studio): why, and what you can change
Updated
On this page (4)
Symptom
Your local model in Ollama or LM Studio takes a long time to start answering or writes very slowly, and a coding agent or extension like OpenCode, Continue or Claude Code feels much slower with it than a simple chat does.
Cause
This page is for you if you run an AI model on your own computer with Ollama or LM Studio, and it’s too slow when you use it for coding, especially with an agent like OpenCode, Continue or Claude Code. Before you buy anything or give up, find out where the model is actually running.
The facts below come from Ollama’s docs on context length, the FAQ, macOS, Cloud and its OpenCode and Claude Code guides, from LM Studio’s docs, from Continue’s Ollama guide, and from Anthropic’s page on how Claude Code works, all checked on October 26, 2026. None of these pages gives a speed you should expect from a local model, so this page doesn’t give one either.
Why it happens
A coding agent asks a lot more of the model than a chat. In a chat, you send one message and get one answer. An agent works in a loop. Anthropic’s Claude Code docs describe it as three phases, gather context, take action and verify results, “chaining dozens of actions together”. Each step goes back to the model. And the agent’s context, the text the model keeps in mind at once, fills up with your conversation, the files it reads and the output of the commands it runs.
The model needs room for that context. Ollama’s docs say that agents and coding tools “should be set to at least 64000 tokens”, and that a larger context “will increase the amount of memory required to run a model”. Ollama’s guide for OpenCode goes further: OpenCode “requires a context length of 64k or higher”.
If it doesn’t fit on the graphics card, part of it goes to the CPU. The model and its context have to fit in your graphics card’s memory (VRAM) to run fully on it. If they don’t, Ollama loads part of the model into normal system memory and runs it there. For best performance, Ollama’s docs say to “avoid offloading the model to CPU”.
So a model that feels fine in a short chat can slow down a lot once an agent gives it a long context and many steps.
Step 1: check where the model runs
In Ollama, start your coding tool, send it a request, and while the model is loaded, run this in a terminal:
ollama ps
Look at the PROCESSOR column. Ollama’s FAQ explains it:
100% GPU: the whole model is on the graphics card.100% CPU: the whole model is in system memory.48%/52% CPU/GPU: the model is split between the two. This is the case Ollama says to avoid.
The CONTEXT column shows the context the model was loaded with. If it shows a much smaller number than your tool needs, see Step 3.
On a Mac, Ollama’s docs say Apple M series chips have CPU and GPU support, while Intel Macs run on the CPU only. On Apple Silicon, the graphics part shares the Mac’s memory with everything else. LM Studio on a Mac explains what that means for which models fit.
In LM Studio, lms ps lists the models loaded in memory. How much of a model goes to the GPU is the GPU offload setting. LM Studio’s docs say that if you don’t set it, LM Studio decides on its own. You can also load a model with all of it on the GPU:
lms load <model_key> --gpu max
Step 2: pick a model that fits, with its context
If part of the model is on the CPU, the most reliable fix is a model that uses less memory.
- A smaller model. Continue’s Ollama guide gives rough memory needs: about 4 GB of RAM for 1.5B to 3B models, 8 GB for 7B, 16 GB for 13B and 32 GB for 32B. For its own performance tips, it says “Use smaller models (7B instead of 32B)” when RAM is short.
- A lower quantization. The same model often comes in several versions, with names like
Q4_K_MorQ8_0. LM Studio’s docs explain that the Q means quantization, which “roughly means compressing model files in size, while giving up some degree of quality”. Its advice is to choose a 4-bit option or higher if your machine can run it.
Remember that the context takes memory too, so check the model with the context your tool needs, not at the smallest setting. The local LLM calculator shows which models fit your Mac or graphics card at 4k, 32k and 64k of context, and gives the download command for each.
For autocomplete in Continue, Continue’s docs also say that thinking models aren’t recommended, because they “generate more slowly”. Code with a local AI model: Ollama + Continue shows the small model Continue suggests for autocomplete.
Step 3: set the context on purpose
The context is a trade-off. Too small, and your coding tool runs out of room. LM Studio’s docs say that going past a model’s context length makes it behave erratically. Too large, and the model may no longer fit on your graphics card.
In Ollama, the default context depends on your graphics memory: 4k below 24 GiB of VRAM, 32k from 24 to 48 GiB, and 256k from 48 GiB. To change it, move the context slider in the Ollama app settings, or start Ollama from a terminal with:
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
Then run ollama ps again. Check the CONTEXT column, and check that PROCESSOR still says 100% GPU. If raising the context pushed part of the model to the CPU, pick a smaller model rather than cutting the context below what your tool needs. The Ollama + Continue guide goes through this step by step.
In LM Studio, you can set the context when you load a model:
lms load <model_key> --context-length 4096
Or set it once for each model: open the My Models tab and click the gear icon next to the model. LM Studio’s docs list a model’s GPU offload and its context size as the main reasons to set these defaults.
In Continue, its docs say Continue “may use a higher default context length than other tools”. If Continue says the model needs more memory, its fix is to lower contextLength in the model’s settings, for example to 2048, or to try a smaller model.
Step 4: free up memory
Models you aren’t using still take memory. Ollama’s docs say it keeps a model loaded for 5 minutes after you use it, so the next request is quicker. If ollama ps lists a model you don’t need right now, unload it:
ollama stop <model name>
Ollama also says that when there isn’t enough memory to load a new model, new requests wait until it can be loaded.
When to use a cloud model instead
Sometimes no model that fits your computer, with the context your tool needs, is good enough for agent work. That’s not a setting you missed. It’s the limit of your hardware.
At that point, a cloud model is the honest fix. Ollama’s docs say its cloud models let you “use larger models without downloading them”, and its guides for OpenCode and Claude Code list cloud models next to local ones. You can also keep the local model for small jobs, like autocomplete or quick questions, and use a cloud model for the long agent tasks.
A cloud model sends your prompts to a server. For its own cloud, Ollama says it processes your prompts to provide the service but doesn’t store or log that content. If you use another provider’s API key instead, set a spending limit before you paste it: Set an API spending limit before you paste your key.
If you went local because you hit your Claude Code usage limit, waiting for the reset costs nothing, and Claude Code usage limit draining fast? shows what is using that limit.
If you use OpenCode’s free cloud models and those are slow, the problem is different: see OpenCode slow or failing on a free model?.
What we don’t know
- How fast a given model should be on your computer. Ollama, LM Studio and Continue don’t publish expected speeds, so we don’t guess.
- Whether Ollama or LM Studio is faster on the same computer. We found no official comparison.
- The exact memory a model needs on your machine. Continue’s numbers are rough, and the calculator gives estimates.
ollama psshows what really happened.
Prompt to paste
Copy the text below, replace what’s in brackets and send it in the chat of the tool you’re using.
Let's work in small steps, because I'm using a local model.
Before you change anything, tell me in plain English:
1. Which files you need to read for this task, and why. Read only those.
2. The one next step you would take.
Then do only that step, and stop. Tell me what you changed and wait for me before going on.How not to burn credits
- A local model doesn't charge per message, so here you pay in time and memory. Run ollama ps before you download a bigger model hoping it will be faster.
- Ask for one small step per message, like the prompt on this page. The agent then reads fewer files, so it fills less of its context.
- Close models you aren't using with ollama stop and the model's name. Ollama keeps a model in memory for 5 minutes by default, and models that are loaded share the same memory.
- If you switch to a cloud model for agent work, set a spending limit at the provider before you paste an API key. Our guide on API spending limits shows how.
How Lovable counts credits, and what the free plan includes: Lovable credits explained.
Questions people ask
Why is Ollama so slow with a coding agent but fine in chat?
An agent does much more per task. Anthropic's Claude Code docs describe it as a loop: gather context, take action, verify results, chaining dozens of actions together, and its context fills up with your conversation, file contents and command outputs. Ollama says agents and coding tools need a context of at least 64,000 tokens, and that a larger context needs more memory. If the model and that context no longer fit on your graphics card, part of the model goes to the CPU, which Ollama says to avoid for best performance.
How do I know if my model is running on the GPU?
In Ollama, run ollama ps while the model is loaded. The PROCESSOR column says 100% GPU when the whole model is on the graphics card, 100% CPU when it's all in system memory, and something like 48%/52% CPU/GPU when it's split between the two. On a Mac, Ollama's docs say Apple M series chips have CPU and GPU support, and Intel Macs run on the CPU only. In LM Studio, lms ps lists the models loaded in memory, and the GPU offload setting controls how much of the model goes to the GPU.
Should I make the context shorter to make it faster?
It's a trade-off. A shorter context needs less memory, which can help the model fit on your graphics card. But Ollama says coding tools need at least 64,000 tokens, its OpenCode guide says OpenCode requires 64k or more, and LM Studio's docs say going past a model's context length makes it behave erratically. Continue's docs suggest lowering contextLength, for example to 2048, when Continue reports that a model needs more memory. If you have to cut the context far below what your tool needs, a smaller model is usually the better change.
What is Ollama's default context length?
Ollama's context length page says it depends on your graphics memory (VRAM): 4k below 24 GiB, 32k from 24 to 48 GiB, and 256k from 48 GiB. So on most home computers, the default is far below the 64,000 tokens Ollama recommends for coding tools. You can raise it with the slider in the Ollama app settings, or by starting Ollama with OLLAMA_CONTEXT_LENGTH=64000 ollama serve, if your memory allows it.
How big a model can my computer run?
It depends on your memory and the context you need. Continue's Ollama guide gives rough numbers: about 4 GB of RAM for 1.5B to 3B models, 8 GB for 7B, 16 GB for 13B and 32 GB for 32B. LM Studio recommends 16 GB of RAM or more, and on 8 GB Macs it says to stick to smaller models and modest context sizes. Our local LLM calculator shows which models fit your Mac or graphics card at 4k, 32k and 64k of context.
When should I use a cloud model instead?
When no model that fits your computer, with the context your tool needs, does the work well enough. Ollama's docs say its cloud models let you use larger models without downloading them, and its OpenCode and Claude Code guides list cloud models next to local ones. A cloud model sends your prompts to a server. Ollama says it processes them to provide the service but doesn't store or log that content. If you use a paid provider's API key instead, set a spending limit first.
New guides by email. An email when we publish a new guide, error fix or chapter, in plain English. Subscribe