Quick fix: Ollama refused to load the model because the part that must sit in system RAM (the weights that do not fit on your GPU, plus the context cache) is bigger than the free RAM and swap it measured. Only v0.24 and earlier, on Linux and Windows, print this exact text; v0.30 and later (latest: v0.40.16) report the same problem as llama-server reported out-of-memory during startup, and the same fixes apply. The fastest fix is a smaller download of the same model, either fewer parameters or a lower-bit quantisation, and the second is a smaller context window. For example, Ollama's library lists llama3.2:3b-instruct-q4_K_M at 2.0GB against 6.4GB for fp16:
ollama run llama3.2:3b-instruct-q4_K_M
If the required number in your error is far larger than the model's size in ollama list, the context is the problem: jump to the context cause below.
The exact error
Up to v0.24, Ollama creates the message in llm/server.go with fmt.Errorf("model requires more system memory (%s) than is available (%s)", ...). The two numbers are binary gigabytes with one decimal (GiB). In the terminal, ollama run prints it after Error:, as in this report from issue #10920 on v0.9.0:
Error: model requires more system memory (164.8 GiB) than is available (13.4 GiB)
Reports from v0.17.7 (#14719) and v0.20.7 (#15650) show the HTTP status in front, because the CLI's streaming client adds it:
Error: 500 Internal Server Error: model requires more system memory (9.7 GiB) than is available (8.1 GiB)
Over the API the server returns HTTP 500 with the same text in JSON, as quoted in issue #7423:
{"error":"model requires more system memory (10.1 GiB) than is available (4.1 GiB)"}
Which versions print it, from the release tags' source:
- v0.2.2 (July 2024) to v0.24.0 (May 2026): yes. Early builds ran the check on Linux only; Windows was added in v0.3.5. It never runs on native macOS: the code comment says "Darwin has fully dynamic swap". On a Mac you will normally only meet it when Ollama runs inside Docker, which is a Linux VM.
- Later 0.x builds (we checked v0.20.0 and v0.24.0) also log
model requires more system memory than is currently available, evicting a model to make spaceat INFO level. That line is not an error: Ollama unloads another model and retries. - v0.30.0 and later: no. Ollama now runs models through llama.cpp's
llama-serverand the string is gone from the code, up to the current v0.40.16.
v0.30 and later print one of these instead (from llm/llama_server.go and mlxrunner/client.go at v0.40.16):
Error: 500 Internal Server Error: llama-server reported out-of-memory during startup: ...
Error: 500 Internal Server Error: model requires X but only Y are available (after Z overhead)
The first (llama.cpp engines) fires when loading fails; if you never set a context length, Ollama first retries once with a smaller one. The second is the MLX engine on Apple Silicon (it predates v0.30) when the model does not fit in GPU memory.
The server log shows the numbers behind it. Look for a model request too large for system warning with requested, available, total, free and swap fields. Logs are at ~/.ollama/logs/server.log on macOS, journalctl -u ollama --no-pager on Linux with systemd, docker logs <container-name> in Docker, and %LOCALAPPDATA%\Ollama\server.log on Windows.
Why it happens
Before loading, Ollama estimates how much memory each layer of the model needs, including the KV cache (the memory that holds your conversation, which grows with the context length). It puts as many layers as fit on the GPU and leaves the rest for system RAM. It then compares that RAM portion with what is free:
- Linux:
MemAvailablefrom/proc/meminfo, plus free swap. Inside a cgroup v2 container it usesmemory.maxminusmemory.currentinstead. - Windows: available physical memory plus available page file.
If the requirement is larger, it stops before loading anything rather than letting the system run out of memory.
Find your cause
| Cause | How to recognise it | Fix |
|---|---|---|
| Model too big for your RAM | Required number is close to or above the model size in ollama list | Fewer parameters or a lower quantisation tag |
| Context too large | Required number is much bigger than the model file; started after raising num_ctx, using a coding agent, or upgrading to v0.15.5+ | Lower num_ctx or OLLAMA_CONTEXT_LENGTH; quantise the KV cache |
| Parallel requests | OLLAMA_NUM_PARALLEL set above 1 | Set it back to 1 |
| RAM used by other models or apps | ollama ps lists busy models; another Ollama server or a heavy app is running | ollama stop, keep_alive: 0, close apps |
| GPU not used | A machine with a GPU, but ollama ps shows 100% CPU | Fix GPU detection so layers move off RAM |
| Container limit or page cache | Docker, LXC or a NAS; free -h shows plenty "available" but the error says little is | Raise the container memory limit; restart the container |
The model is too big
Every model on ollama.com comes in tags: parameter sizes (1b, 3b, 8b, 70b) and quantisations (q4_K_M, q8_0, fp16). Quantisation stores weights in fewer bits, so the file and RAM need shrink. Check what you have with ollama show MODEL (it prints a quantization row) and pick a smaller tag from the model's Tags page. For llama3.2 3B the library lists 2.0GB for q4_K_M, 3.4GB for q8_0 and 6.4GB for fp16. If even the smallest quantisation is larger than your free RAM, step down a parameter size.
The context window is too large
Ollama's context-length page says: "Setting a larger context length will increase the amount of memory required to run a model." Since v0.15.5 the default depends on VRAM (the source confirms it; the FAQ's flat 4096 is only the lowest tier): 4k below 24 GiB, 32k from 24 to 48 GiB, and 256k at 48 GiB or more. Apps can also ask for more per request. Lower it in the place that sets it:
# inside ollama run
/set parameter num_ctx 4096
# per API request
curl http://localhost:11434/api/generate -d '{
"model": "llama3.2",
"prompt": "Why is the sky blue?",
"options": { "num_ctx": 4096 }
}'
# server-wide default
OLLAMA_CONTEXT_LENGTH=4096 ollama serve
You can also shrink the cache itself. The FAQ says the K/V cache "can be quantized to significantly reduce memory usage when Flash Attention is enabled", and that q8_0 uses "approximately 1/2 the memory of f16":
OLLAMA_FLASH_ATTENTION=1 OLLAMA_KV_CACHE_TYPE=q8_0 ollama serve
Our tokens and context windows explainer covers why longer context costs memory.
Parallel requests multiply the context
The FAQ is explicit: "Parallel request processing for a given model results in increasing the context size by the number of parallel requests", and "Required RAM will scale by OLLAMA_NUM_PARALLEL * OLLAMA_CONTEXT_LENGTH." The default is 1. If you raised it for throughput, set it back:
OLLAMA_NUM_PARALLEL=1 ollama serve
Other models or apps are holding RAM
Ollama keeps models loaded for 5 minutes by default and, per its FAQ, unloads idle ones to make room for a new model. It cannot free memory used by a model that is still answering, by a second Ollama server (for example the desktop app and a Docker container at once), or by other programs. See what is loaded and free it:
ollama ps
ollama stop llama3.2
# unload right after a request
curl http://localhost:11434/api/generate -d '{"model": "llama3.2", "keep_alive": 0}'
To stop several models from sharing RAM at all, set OLLAMA_MAX_LOADED_MODELS=1 (default: 3 per GPU, or 3 for CPU inference) or a shorter OLLAMA_KEEP_ALIVE.
The GPU is not being used
Only layers that do not fit on the GPU count against system RAM. If Ollama does not detect your GPU, the whole model lands in RAM and a model that should fit fails. ollama ps shows the split in its PROCESSOR column (100% GPU, 100% CPU, or a mix), and the server log's inference compute line names the library it found; library=cpu means no GPU. Fix detection with Ollama's GPU docs (supported cards and driver versions), and in Docker start the container with --gpus=all, as Ollama's Docker page shows for NVIDIA cards.
Container limits and page cache
In a cgroup v2 container, the source computes free memory as memory.max minus memory.current, and the kernel's cgroup v2 docs list page cache among the memory a cgroup is charged for. That matches reports such as #11497 (Docker, "Ollama counts cached memory as used") and #15704 (Proxmox LXC, still open), where the error said 2.9 GiB or 12.6 GiB was available on machines with far more reclaimable memory. Fixes:
- Raise the container's limit. Docker's
-mor--memoryflag sets "The maximum amount of memory the container can use". On Docker Desktop (macOS, Windows), the VM itself is capped by the Memory limit setting under Resources, Advanced (newer docs label it VM resources), which "Defaults to 50% of your host's memory." - Restart the container, which the #15704 reporter found helps temporarily because the cache is cleared.
- On a Linux host you control, the kernel documents
sync; echo 3 > /proc/sys/vm/drop_caches(as root) to free clean page cache. It is safe ("non-destructive") but temporary.
Because the check adds free swap on Linux and Windows, a machine with no swap or a tiny page file has less headroom. Adding swap lets the check pass, but a model that runs from swap is very slow; a smaller model is the better fix.
Setting the environment variables for good
Running ollama serve by hand only applies to that terminal. Ollama's FAQ gives the permanent method per OS: launchctl setenv OLLAMA_CONTEXT_LENGTH 4096 then restart the app on macOS; systemctl edit ollama.service, add Environment="OLLAMA_CONTEXT_LENGTH=4096" under [Service], then systemctl daemon-reload and systemctl restart ollama on Linux; on Windows, quit Ollama, add the variable under "Edit environment variables for your account", and start it again. In Docker, pass -e OLLAMA_CONTEXT_LENGTH=4096 to docker run.
Check it is fixed
ollama run llama3.2:3b-instruct-q4_K_M "Say hello in five words"
ollama ps
The run should print a reply instead of Error:. Then ollama ps lists the model with its SIZE (memory used), PROCESSOR (GPU/CPU split) and CONTEXT. The docs' example looks like this; your numbers will differ:
NAME ID SIZE PROCESSOR CONTEXT UNTIL
gemma4:latest c6eb396dbd59 9.6 GB 100% GPU 131072 2 minutes from now
If SIZE is close to your free RAM, you are on the edge; leave some headroom for the operating system.
Related errors
ollama._types.ResponseError: model requires more system memory (39.4 GiB) than is available (30.0 GiB) (status code: 500): the same error raised by the Python client (ollamaon PyPI), quoted from #13556. Same fixes.model runner has unexpectedly stopped, this may be due to resource limitations or an internal error, check ollama server logs for details: the runner crashed mid-request, often from memory pressure. Check the server log.
What to do next
- Pick a model that fits your RAM: What is Ollama? Run a local LLM.
- Compare runners and tools: Best local LLM tools.
- Running Ollama in a container: Docker for beginners.
- Official docs: Ollama FAQ, Context length and Troubleshooting.
FAQ
How much RAM do I need to run an Ollama model?
At least the model's download size plus room for the context cache and your operating system. Compare the size on the model's Tags page with the free memory your system reports; a model whose size is close to your total RAM will not load.
Why does the error say so little memory is available when I have plenty?
In Docker, LXC and similar containers Ollama reads the container's own limit and usage, and page cache counts as used. Raise the container limit or restart it. On Docker Desktop, the VM's memory limit defaults to half your RAM.
Does lowering num_ctx really help?
Yes when the context is the large part, which is typical when the required number is far above the model's file size. Ollama's docs say a larger context "will increase the amount of memory required".
Can I turn the memory check off?
Ollama documents no setting that disables it. v0.30.0 and later drop this pre-load check, but a model that does not fit then fails while loading, so use the fixes above.
Why don't I see this error on my Mac?
The check skips macOS ("Darwin has fully dynamic swap"). On a Mac it appears only when Ollama runs in a Linux environment such as Docker.
How this fix was verified
Ollama was not installed or run for this article, so nothing was reproduced on the test Mac (macOS 26.5 on Apple M4). Everything was checked against Ollama's source and docs on 14 November 2026: llm/server.go at tags v0.2.1 (absent) and v0.2.2 to v0.24.0 (present, spot-checked across the range), the full v0.30.0 and v0.40.16 source trees (absent), the memory, scheduler, client and context-default code at v0.24.0 and v0.40.16, and the FAQ, context-length, troubleshooting and Docker docs. The v0.24 wordings are quoted from GitHub issues and match the format strings; the v0.30+ lines are built from the format strings, not captured. Tag sizes come from ollama.com, Docker limits from docs.docker.com.
Last verified: 14 November 2026.
We re-check this fix monthly and record any change in this page's changelog.
Comments 0
No comments yet. Be the first to share your thoughts.
Leave a comment