# Will the model fit in my memory?

> A model either fits in memory or it does not, and that decides everything else. Budget for the weights, the context and room for the operating system.

Memory is the first question for any model. If the whole model fits in fast memory, it runs at your hardware's full speed. If it does not, it either crawls or refuses to load.

## It fits or it does not

A model is not like a game that runs at lower settings on a weaker machine. Every weight is needed for every token, so all of them have to sit in memory at once. There is no partial mode that keeps the quality and drops the size.

What you can change is which file you load. A smaller model, or the same model at a lower [What is quantization?](https://localagi.co/quantization), is the only real way to make something fit. [Will it fit?](https://localagi.co/will-it-fit) does the sums for your machine.

## RAM, VRAM and unified memory

Your memory budget depends on where the model runs. Each platform has one number that matters.

| Platform | Your budget | Why |
| --- | --- | --- |
| Mac with Apple silicon | Unified memory, minus what macOS keeps | CPU and GPU share one pool. RAM is the whole budget |
| PC with an NVIDIA or AMD graphics card | VRAM on the card | The GPU can only work fast on its own memory |
| Unified-memory PC, such as AMD Strix Halo | The share given to the GPU | Shared pool, often split in firmware or the driver |
| CPU only | System RAM | Works, but slowly |

On a PC with a graphics card, system RAM is a fallback, not part of the budget. A 16 GB card in a machine with 64 GB of RAM still has a 16 GB budget for full speed.

On a Mac, macOS will not hand all of memory to the GPU. It keeps a share for itself and your apps.

On a 16 GB machine, plan on about 11 GB for the model. On a 64 GB machine, plan on about 48 GB. [Is a Mac good for local AI?](https://localagi.co/apple-silicon) and [Which NVIDIA card should I get?](https://localagi.co/nvidia-gpus) cover each platform in detail.

## The rule of thumb

**Rule of thumb.** 
At 4-bit, a model needs about 0.6 GB. At 8-bit, it needs about 1.1 GB. Then add the context and leave room for everything else.

The weights are the big part, and the rule covers them. Two more items sit on top.

The context is the second item. The runtime stores every token of the conversation in the KV cache, and that grows as the chat gets longer.

For a small model with an 8K context it is about 1 GB. For an agent with a 64K context on a mid-size model it can be several GB. [How much can the model keep in mind?](https://localagi.co/context-window) shows how to estimate it.

Headroom is the third, because the operating system, your browser and the runtime itself all need memory. On a GPU, leave about 1 to 2 GB free. On a Mac or a CPU-only machine, everything you have open competes with the model.

### Worked examples

| Model | Weights at 4-bit | Plus 8K context | Fits on |
| --- | --- | --- | --- |
| 8B | about 5 GB | about 6 GB | A 16 GB laptop, with room |
| 27B | about 16 GB | about 18 GB | A 24 GB GPU, or a 32 GB Mac |
| 70B | about 42 GB | about 45 GB | A 64 GB Mac, just. Not one consumer GPU |

These are rough. The real file size is on the download page, and that number beats any rule.

**The catch.** 
"Fits" and "fits with a useful context" are different things. A 27B model on a 24 GB card loads fine, then runs out of room once an agent pushes the context past 32K. Size for the context you will actually use, not the one the runtime starts with.

## What happens when it does not fit

There are three outcomes, and each is worse than picking a smaller model.

### Swapping

On a Mac or a CPU-only machine, the operating system starts moving memory to disk. The model still loads, then every token waits on the SSD, and output drops to a word every few seconds. The whole computer gets sluggish with it.

### Partial offload

On a PC with a graphics card, runtimes such as [llama.cpp](https://localagi.co/llama-cpp), [Ollama](https://localagi.co/ollama) and [LM Studio](https://localagi.co/lm-studio) can put some layers on the GPU and the rest in system RAM. The model runs, but at the speed of the slowest part. With a third of the model on the CPU, expect most of the GPU's speed advantage to disappear.

### A crash

Sometimes the runtime just fails. It reports an out-of-memory error, the model unloads mid-answer, or the app closes. This often happens late, when the context grows past what the first load left room for. [Why won't it load?](https://localagi.co/out-of-memory) lists the fixes.

**Try it.** 
Load a model, then check how much memory it really takes. On a Mac, open Activity Monitor and look at the Memory tab. On a PC with an NVIDIA card, run this in a terminal.

```bash
nvidia-smi
```

The memory column shows what the model and its cache use on the card. Compare it with the file size you downloaded.

## Go deeper

### Why the rule says 0.6 and not 0.5

Four bits is half a byte, so a 4-bit model should be 0.5 GB per billion parameters. Real files are larger.

Each block of weights stores a scale alongside it, and a few sensitive layers are kept at higher precision. That adds up to about 4.5 to 5 bits per weight on average.

The 8-bit rule is over 1.0 for the same reason. [What is quantization?](https://localagi.co/quantization) explains the block scheme.

### Raising the Mac GPU limit

macOS caps how much unified memory the GPU can wire down. Advanced users raise it with a `sysctl` setting called `iogpu.wired_limit_mb`. The setting resets on reboot, and pushing it too high starves macOS and freezes the machine. 

### Mixture of experts and memory

A [mixture of experts](https://localagi.co/dense-vs-moe) model only runs part of itself per token, but it still needs all of itself in memory. Size it by total parameters, not active ones. Some runtimes can keep the rarely used experts in system RAM on a PC, which trades speed for fit more gently than ordinary partial offload.
