# Why won't it load?

> It ran out of memory. Try a smaller quantization, then a smaller context, then a smaller model, in that order.

A model that will not load almost always ran out of memory. The weights plus the context did not fit in your VRAM, or in your Mac's usable memory. The fix is to make one of them smaller.

## Read the error

The wording differs by runtime, but most memory errors say "allocate", "out of memory" or "requires more memory". Here is what the common ones mean.

| Runtime | What you see | What it means |
| --- | --- | --- |
| Ollama | `model requires more system memory (...) than is available (...)` | The model plus its context does not fit in free RAM. Close apps or pick a smaller build |
| Ollama | `llama runner process has terminated` followed by a reason | The engine underneath crashed while loading. The reason after it is the real error, often a memory allocation |
| llama.cpp | `cudaMalloc failed: out of memory` | The layers you asked to put on the NVIDIA GPU do not fit in its VRAM |
| vLLM, PyTorch | `CUDA out of memory. Tried to allocate ...` | The GPU filled up, either at load time or while reserving the KV cache |
| vLLM | `... is larger than the maximum number of tokens that can be stored in KV cache` | The weights fit, but there is no room left for the context length you set |
| LM Studio | A "failed to load model" message, sometimes with a warning that the model may exceed your system resources | Same cause. LM Studio estimates the fit before loading and can block a model it thinks is too big |
| MLX | A Metal error about an allocation larger than the allowed buffer size | The model, or one tensor in it, is bigger than the GPU share macOS allows |

Ollama keeps a log with the full message when the app only shows a short error. On a Mac it is at `~/.ollama/logs/server.log`. On Linux, read it with `journalctl -u ollama`.

Some failures that look like memory are not. An "unknown model architecture" error means your runtime is too old for the model, and the fix is an update. A failed download gives a file that will not open, and [Why is the output nonsense?](https://localagi.co/nonsense-output) covers broken files.

## The order of fixes

Try these in order. Each one costs you a little more than the one before.

1. Use a smaller quantization. Go from Q8 to Q6, or from Q6 to Q4. Quality barely moves down to Q4, and the file shrinks a lot. Budget about 0.6 GB at 4-bit against about 1.1 GB at 8-bit. [Which quantization should I download?](https://localagi.co/choosing-a-quantization) has the ladder.
2. Use a smaller context. Halve the context length setting. The KV cache grows with every token of context, and at 128K it can be as large as a small model. [How much can the model keep in mind?](https://localagi.co/context-window) shows the sums.
3. Use a smaller model. Drop one class, for example from a 27B to an 8B. This is the fix that always works and the one that costs the most. [Which size of model do I need?](https://localagi.co/model-classes) lists the steps.

**Rule of thumb.** 
Leave a few GB free after the model loads. A model that only just fits will fail the moment the chat gets long.

Two things help before you shrink anything. Close browsers and other heavy apps, which can hold several GB. And make sure only one model is loaded, because Ollama and LM Studio can keep a previous one in memory.

```bash
ollama ps
ollama stop qwen3:8b
```

`ollama ps` lists loaded models and their size. `ollama stop` unloads one by name.

**The catch.** 
On a PC with a separate GPU, some runtimes do not fail when the model is too big. They put the extra layers in system memory and run very slowly instead. If it loads but crawls, that is the same problem, see [Why is it slow?](https://localagi.co/it-is-slow).

## Check before you download

The cheapest fix is to never download a model that cannot fit. [Will it fit?](https://localagi.co/will-it-fit) does the sum for your memory, model and context. [What can I run on what I have?](https://localagi.co/what-can-i-run) goes the other way and lists what fits on your machine.

**Try it.** 

```bash
ollama show qwen3:8b
```

This prints the model's parameter count, quantization and context length before you load it. Multiply the parameters by the rule of thumb above to see if it fits.

## Go deeper

### What actually takes the memory

Three things share the space. The weights are fixed by the model and its quantization. The KV cache grows with context length and with the number of parallel requests.

A few hundred MB to a few GB goes to the runtime's working buffers, and [Will the model fit in my memory?](https://localagi.co/memory) breaks this down.

### Why a Mac cannot use all of its memory

macOS lets the GPU use only part of the unified memory, and keeps the rest for the system and your apps. The share is larger on machines with more memory. A model close to your total memory will not load even if nothing else is open.

Advanced users can raise the limit with `sudo sysctl iogpu.wired_limit_mb=`, at the risk of starving macOS itself.

### vLLM reserves memory on purpose

vLLM claims a fixed share of the GPU at start-up and fills it with KV cache. That is how it serves many users fast. If it fails, lower `--max-model-len` to shrink the context, or adjust `--gpu-memory-utilization`. [When do I need vLLM or SGLang?](https://localagi.co/vllm-and-sglang) covers both.

### Multiple GPUs

Two GPUs add their memory together, if the runtime splits the model across them. llama.cpp and vLLM both do this. [How do several GPUs in one box work together?](https://localagi.co/multi-gpu) explains the options and their costs.
