Skip to main content
FLAGSHIP · FREEVRAM Calculator, which GPU runs which model? →
Featured AI Models & Fashion Pack →
Vantaige

Fix Local LLM Out-of-Memory Errors and Slow Generation

This post contains affiliate links. If you buy through them we may earn a small commission at no extra cost to you. It never affects our editorial opinions or which tools we recommend.
A
Aymen B
10 min read
Fix Local LLM Out-of-Memory Errors and Slow Generation

When a local model fails or slows down, first identify where the problem occurs: loading, processing the prompt, generating output, or handling concurrent work. Record the actual model and settings, inspect a small relevant log excerpt, and change one variable at a time.

Do not begin by changing drivers, context, quantization, and thread settings together. A successful next run would tell you little about which change helped. The goal is a configuration that handles your required task reliably, with latency and output quality you can accept.

This guide uses documented Ollama diagnostics and LM Studio's saved-load-settings workflow. Its walkthrough provides an investigation methodology to diagnose your specific hardware and workload.

Identify the phase before choosing a fix

A phase narrows the investigation; it does not prove the cause.

What you observe What to investigate first Evidence to preserve
Model cannot load Model identity, load settings, available resources, backend support Actual allocation or load error
Model loads but a request fails Effective context, input length, working buffers, other requests Request-phase error and configuration
Long wait before visible output Cold loading, prompt processing, queueing, reasoning, client buffering Runtime metrics and client event times
Output starts but is slow Device placement, shared workload, runtime settings Generation metrics and actual placement
Failure appears only with concurrent work Admission, parallel contexts, queueing, memory pressure Simultaneous workload and errors

For example, silence before an answer is not automatically an out-of-memory error. A cold load, long input, or a client hiding intermediate model output can look similar from the chat interface.

Use the troubleshooting decision table as a set of hypotheses to check. Its suggested trials have not been run and do not guarantee a fix.

Read a relevant log excerpt and actual placement

Ollama's troubleshooting documentation identifies its logs by installation: a terminal for a manually started server, systemd logs on relevant Linux installations, container output for container deployments, and application log files on desktop systems.

For a systemd installation, a bounded inspection command is:

journalctl -u ollama --no-pager -n 50

On macOS, the documented server-log location can be inspected with:

tail -n 50 ~/.ollama/logs/server.log

Use the actual log location for your deployment. Share a small relevant excerpt with sensitive paths and data removed; do not dump your environment or complete prompt history.

The Ollama FAQ also documents:

ollama ps

Inspect its actual model identity and PROCESSOR column. Ollama describes GPU, CPU, and mixed placement categories. A placement reading is not a speed benchmark, an exact per-layer accounting, or proof that the next request cannot exhaust memory.

If placement differs from what you expected, compare the runtime's detection log with its current hardware-support documentation. Check the specific device, backend, operating system, and driver combination. Avoid treating a generic GPU name or an installed driver as proof of compatible acceleration.

Account for more than the downloaded weights

The model file on disk is one part of the resource picture. Active inference may also require context state, working buffers, backend resources, and memory for other loaded models or applications.

For many transformer-based workloads, a larger configured context and more parallel work can increase cache and working-memory requirements. That does not yield one universal bytes-per-token rule for every architecture and backend.

Check these separately:

  • Exact weight variant: record the model revision, format, and quantization.
  • Effective context: inspect the client request and saved runtime settings, not just the model card's maximum.
  • Input and output needs: determine what the task actually requires.
  • Concurrent work: record other requests, loaded models, and competing applications.
  • Memory topology: distinguish dedicated GPU VRAM, system RAM, and shared/unified memory.

Vantaige's AI VRAM Calculator helps explore estimates. The KV-cache guide explains the underlying considerations. Confirm estimates against the actual runtime; do not reserve a fixed amount of “safe headroom” and assume every task will fit.

Choose one controlled trial

Capture a baseline before changing a setting. Record the model, prompt fixture, context, output allowance, concurrency, device placement, and warm/cold/cache state. Keep the relevant inputs fixed for a comparison.

Evidence points toward One trial to consider What to check afterward
A larger context allocation Lower one supported context setting Required input still fits and useful output remains possible
Concurrent memory pressure Try one controlled request without the competing test workload Error, latency, and memory observations
Weight allocation too large Select a suitable smaller or more compressed variant Load behavior and task quality with that variant
Cold-loading delay Compare controlled cold and warm runs Actual load time and user-visible wait
Unexpected backend selection Correct one documented compatibility/configuration issue Detection, placement, and task behavior

These are choices based on evidence, not a mandatory global order. Reducing context below the task's required input is not a successful fix. A smaller model or different quantization also needs its output quality checked.

Keep the model, input and other conditions fixed while changing one setting
Keep the model, input and other conditions fixed while changing one setting. Compare useful output as well as resource use.

Record the old setting and the one chosen change in the diagnostic log. If you must change several things to restore a broken environment, record that limitation rather than attributing the result to one parameter.

Check saved defaults before changing the machine

LM Studio's per-model defaults documentation provides a concrete pattern: open My Models, use the model's gear icon, and inspect saved load parameters. Settings can also be adjusted before loading a model and saved as defaults.

A saved context or offload choice can explain why the same model behaves differently than expected. Inspect the current values before changing software or hardware. A saved preset is not automatically a verified-fit preset, and settings that worked earlier may meet a different workload or available-memory state now.

For unexpected CPU use, follow current backend-specific documentation. Do not begin with privileged driver resets, blanket permission changes, or legacy library overrides. If the runtime is shared, coordinate changes with its owner and avoid stopping other users' work.

Measure the first visible answer separately from generation speed

The Ollama chat API reference documents runtime durations in nanoseconds. Keep the units when copying raw values. Fields available in a particular runtime version should be recorded as returned; missing fields are unknown.

For a provided, valid token count and a positive generation duration:

generation seconds = eval_duration / 1,000,000,000
runtime decode tokens/second = eval_count / generation seconds

A worked arithmetic-only example uses 120 generated tokens and 6,000,000,000 nanoseconds:

6,000,000,000 / 1,000,000,000 = 6 seconds
120 / 6 = 20 tokens/second

Those inputs were invented to explain the units. They are not measurements from a model, device, or deployment. The calculation does not establish end-to-end throughput, first-token latency, or answer quality. A missing or non-positive duration cannot produce a meaningful rate.

Keep these observations distinct:

Observation What it helps describe What it does not establish
load_duration Runtime-reported loading duration Complete user-visible wait
prompt_eval_duration Reported uncached prompt-processing duration Client time to first token
eval_count / generation seconds Runtime decode rate Visible answer words/second or end-to-end latency
Client first-visible-content time Wait until the UI receives/displays the chosen content event Pure model processing time
Client complete-response time Wait until the response is complete at the chosen client boundary Which individual phase caused a delay

The current API reference also distinguishes cached prompt tokens and uncached evaluation duration. Do not divide all prompt tokens by an uncached-only duration when cache hits are present and call it an overall prompt-processing rate.

Define the client event you measure. A first byte, a reasoning event, and the first visible answer content can be different events. Some clients hide reasoning content; apparent silence can therefore coexist with generation activity. A final non-streaming response does not reconstruct when the first token was generated.

Compare repeated observations under known conditions before deciding a change helped. Record warm/cold and cache state: accidentally comparing a cold run with a warm cached run can obscure the effect of the setting you meant to test.

A fictional investigation plan

Imagine a local document assistant that loads but fails when processing a request. The developer suspects context and parallel work, but has not established the cause. No hardware size, model tag, error transcript, or measured improvement is assumed here.

Use a short synthetic document that fits both proposed context settings. Then prepare two separate comparisons:

Comparison Keep fixed Change only Observation status
Context trial Model variant, prompt, output allowance, concurrency, load/cache conditions One supported context setting not_run
Concurrency trial Model variant, context, each request's prompt/output, load/cache conditions Admitted simultaneous test requests not_run

Record the actual baseline and trial observations for each comparison. If the error disappears, confirm useful output and repeat under the intended workload. If input truncation made the task easier, record that and do not call it an equivalent successful run.

If neither comparison resolves the failure, return to the error and backend evidence. Consider a different model variant as a new choice, then test its task quality. Do not manufacture a story in which a guessed root cause becomes confirmed merely because several settings changed.

The diagnostic download contains blank observation fields and a separately labelled arithmetic example. It does not contain observed trial results or a benchmark progression.

Know when to change the model or deployment

Stop tuning when a stable configuration cannot meet the task's input, quality, latency, or concurrency requirements. Compare alternatives against those requirements rather than an arbitrary GPU-residency percentage.

A smaller model may be sufficient for a narrow extraction task but fail a required reasoning or coding task. A more compressed variant may save weight memory while changing output quality. CPU or hybrid placement can be acceptable when its actual latency meets your needs; full GPU placement is not a universal requirement.

Assumed arithmetic: 6,000,000,000 nanoseconds is 6 seconds, so 120 decoded tokens divided by 6 seconds is 20 tokens per second
Assumed arithmetic: 6,000,000,000 nanoseconds is 6 seconds, so 120 decoded tokens divided by 6 seconds is 20 tokens per second. Decode rate is different from first-answer latency.

A hosted service is another option when the chosen local setup cannot provide the required capacity or operating model. Evaluate data handling, access, availability, and total cost for that option. Choosing local or hosted inference does not itself establish privacy or compliance.

Renting capacity for one test can be cheaper than buying a GPU. RunPod and Vast.ai both publish current rates; their Vantaige listings (RunPod, Vast.ai) summarise the starting points.

Use the model-card reading guide to inspect a candidate's actual identity and limitations before replacing it. Keep the acceptance task stable enough to make a useful decision.

Prepare a reproducible support record

Use the support evidence template when you need help from a maintainer or your platform team. It asks for the runtime/model identity, failure phase, effective settings, a small relevant redacted excerpt, raw metric units, and the exact change attempted.

Distinguish unknown, unavailable because the run failed earlier, and not_run. None of those means zero. Share synthetic reproduction data where possible and review the material before submitting it anywhere.

Download the diagnostic log, record one baseline, and choose the next comparison from the decision table. Change one relevant variable and keep the result tied to the actual task you need to run.

Get the best new AI tools and guides, weekly

One short email a week. The tools worth trying, the guides worth reading, nothing else.

No spam. Unsubscribe anytime.

A

Aymen B

Contributing writer at Vantaige, covering the AI tools ecosystem.