With the same settings, Ollama and llama.cpp use the same VRAM, because Ollama now runs llama.cpp underneath. On my RTX 4090 with Gemma 4 26B, a 128K context took 18.2GB in Ollama and 18.2GB in llama-server, 13 MB apart. At 32K the gap was 311 MB, from a batch size Ollama picked. The big differences come from the defaults. Ollama chooses a small context from your VRAM (4K under 24GB, 32K up to 48GB) and one conversation slot, so out of the box it used 16.5GB. llama-server on its own asks for the model’s full context, here 262K with four slots, and used 21.4GB. On a small card its --fit step cuts that back, all the way to 4K in my 12GB test.
Below I show the exact command Ollama gives llama-server, the defaults side by side, my measurements at 32K and 128K with 16-bit and 8-bit caches, where every gigabyte goes, what happens on a 12GB card, the speed, every setting in both tools that changes VRAM, and recipes to make each behave like the other. All figures are my own measurements on 6 December 2026, with Ollama 0.40.15.
Why this question has a new answer
For years the honest answer to “Ollama or llama.cpp?” was that they were related but different. Ollama started as a friendly wrapper around llama.cpp, then built its own engine in Go on top of llama.cpp’s low-level GGML library. Forum threads were full of people finding that the same model used more memory, or ran slower, in one than the other, and there were real reasons for it.
That changed in 2026. Ollama 0.30, released on 13 May, announced “improved compatibility and performance using llama.cpp”. Since then, on Windows and Linux, Ollama runs models by starting llama.cpp’s own llama-server program in the background. Ollama 0.40.2 went further: models downloaded with older versions are upgraded in the background the first time you run them, “for better performance and compatibility when running on llama.cpp”. On Apple Silicon, Ollama uses Apple’s MLX for the models MLX supports, which I cover in section 16.
So on a PC the question “which engine uses less VRAM?” has an unexpected answer: it is the same engine. What differs is everything around it: the context length each tool picks, how many conversations it prepares for, whether it loads the vision part of the model, and how it decides what fits. Those choices can easily add or remove several gigabytes, which is why people still see big differences. This article measures exactly where they come from.
The exact command Ollama gives llama-server
You do not have to guess what Ollama does. Its log file records the command it uses to start llama-server. This is the line from my PC when I ran ollama run gemma4:26b-a4b-it-qat with Ollama 0.40.15 on an RTX 4090 (I shortened the file paths):
llama-server.exe --model <gemma4 blob> --port 50922 --host 127.0.0.1 --no-webui --offline
-c 32768 -np 1 --log-verbosity 4 --no-log-prefix --no-log-timestamps
--no-jinja --chat-template chatml --mmproj <projector blob>
--load-mode none --flash-attn auto -b 1024 -ub 1024 --context-shift --keep 4
Here is what each part means for memory:
| Flag | What Ollama chose | Effect on VRAM |
|---|---|---|
-c 32768 | A 32K context, picked from my 24GB of VRAM | Sets the size of the KV cache. This is Ollama’s biggest memory decision. |
-np 1 | One conversation slot | Only one cache. llama-server alone would prepare four. |
--mmproj | The vision projector is always loaded | About 1.2GB for Gemma 4, even if you never send an image. |
--flash-attn auto | Flash attention where supported | Smaller buffers, and needed for a quantised cache. |
-b 1024 -ub 1024 | Batch size, which Ollama changes from load to load | A larger batch means a larger compute buffer, a few hundred MB. |
--load-mode none | No memory-mapping on Windows with CUDA | Changes system RAM use and load time, not VRAM. The log says reason=windows_cuda. |
--context-shift --keep 4 | Drop old tokens when the context is full | No memory cost. It lets long chats continue instead of failing. |
--no-jinja --chat-template chatml | Ollama formats the prompt itself | No memory cost. |
Ollama also starts this llama-server from its own folder (lib\ollama) with its own CUDA libraries. The llama.cpp build inside Ollama 0.40.15 reports itself as 0.9.0-dev; the 0.40.21 release moved it to llama.cpp build b12973. Ollama may carry small patches of its own, so I compared it with the very same llama-server.exe file, not a separate download, to keep the engine identical.
Ollama defaults vs llama.cpp defaults
Put the two sets of defaults side by side and the difference in memory use becomes predictable before you measure anything:
| Setting | Ollama 0.40 (Windows, NVIDIA) | llama-server on its own |
|---|---|---|
| Context length | From your VRAM: 4K below 24GB, 32K from 24 to 48GB, 256K at 48GB or more (Ollama docs) | The model’s full trained length (-c 0), cut down by --fit only if it does not fit |
| Conversation slots | 1 (OLLAMA_NUM_PARALLEL) | Automatic: 4 in my test, sharing one cache |
| Vision projector | Always loaded on the GPU | Only if you pass --mmproj or use -hf (then on by default) |
| KV cache type | f16, one global setting for all models | f16, set per launch with -ctk/-ctv |
| Flash attention | auto | auto |
| Batch sizes | 512 or 1024, chosen by Ollama | 2048 logical, 512 physical |
| Fitting into VRAM | Ollama’s scheduler, then llama.cpp’s --fit | --fit on, leaving 1,024 MiB free |
| Unloading | After 5 minutes idle | Never, unless you set --sleep-idle-seconds |
The first two rows decide most of the memory. On a 24GB card, Ollama gives Gemma 4 a 32K context and one slot. llama-server on its own gives it the full 262,144 tokens and four slots. Gemma 4 handles long contexts unusually cheaply, as you will see, but even so that gap is worth about 5GB.
How I tested
I wanted a fair test, so I removed every difference except the one I was measuring.
NVIDIA RTX 4090 with 24GB (24,564 MiB), 64GB of system RAM, Windows 11, NVIDIA driver 621.14.
Ollama 0.40.15. For llama.cpp, the llama-server.exe that ships inside that Ollama, with Ollama’s CUDA 13 backend.
gemma4:26b-a4b-it-qat from the Ollama library: Gemma 4 26B-A4B, a mixture-of-experts model, 4-bit QAT (Q4_0), a 14.4GB file plus its vision projector. Both tools loaded the very same files.
Eighteen runs, each from a cold start, covering both tools at 4K, 32K, 128K and 262K, 16-bit and 8-bit caches, and parts of the model moved to system RAM.
- Before each run I closed Ollama and llama-server completely, waited for the VRAM to settle and wrote down the starting figure from
nvidia-smi. Windows and my other apps were already using about 1.5GB, which I do not count. - I loaded the model, sent a prompt of about 4,850 tokens, then asked for 400 tokens of output. Thinking was turned off.
- After that I read the VRAM again. The difference is the “VRAM used” in this article. A second reader checked every 0.4 seconds for peaks; the peak was never more than a few MB above the final figure.
- Speeds are the prompt and generation speeds each tool reports for that request.
- I ran most setups once and repeated two. Memory use repeated to within 50MB; speeds can vary by a few per cent, so treat small speed differences as noise.
Units: I give GB as Windows Task Manager does, where 1GB is 1,024MB. Model download sizes on websites usually use 1GB = 1,000MB, so the same file can look about 7% bigger there.
One model on one card cannot cover everything, so in section 11 I also work out what the defaults would cost with models that need far more memory per token than Gemma 4.
Result 1: same settings, same VRAM
First I gave llama-server the same context and slot count that Ollama uses: -c 32768 -np 1. Then I repeated the test at a 128K context, and again at 128K with an 8-bit cache (num_ctx 131072 plus OLLAMA_KV_CACHE_TYPE=q8_0 in Ollama, -c 131072 -ctk q8_0 -ctv q8_0 in llama-server).
| Setup | Ollama | llama-server | Difference |
|---|---|---|---|
| 32K context, 16-bit cache | 16.5GB | 16.2GB | Ollama +311 MB |
| 128K context, 16-bit cache | 18.2GB | 18.2GB | Ollama +13 MB |
| 128K context, 8-bit cache | 17.3GB | 17.3GB | -4 MB |
At 128K the two were within 13 MB of each other, which is measurement noise. At 32K Ollama used about 311 MB more. Its log explains why: for that load it chose a batch size of 1,024 instead of 512, which makes the compute buffer and the sliding-window part of the cache a little bigger. That is a setting, not a difference in the engine.
So the first answer is simple. If you give them the same settings, Ollama and llama.cpp use the same VRAM. Ollama itself, the program you talk to, keeps nothing on the GPU that matters.
Result 2: each tool with its own defaults
Most people never change the defaults, so this is the comparison that matters in practice. I started Ollama with no settings at all, and llama-server with nothing but the model and projector files.
| Ollama default | llama-server default | |
|---|---|---|
| Context | 32,768 tokens | 262,144 tokens |
| Slots | 1 | 4 |
| VRAM used | 16.5GB | 21.4GB |
| Prompt speed | 8,448 tokens/s | 8,857 tokens/s |
| Generation speed | 203 tokens/s | 181 tokens/s |
llama-server used about 5GB more, all of it for the larger context and the extra slots. In return it can hold a conversation eight times longer, and serve four people at once. Ollama on the same card can only remember 32K tokens before old text starts falling out of the context.
Neither default is wrong. They are aimed at different people. Ollama assumes you want the model to load quickly and safely next to everything else on your PC. llama-server assumes you want the most the model can do and lets --fit trim it if needed. The surprise is that, with Gemma 4, llama-server’s “everything” still fits on a 24GB card. With most other models it would not, which is where --fit comes in (section 11).
The generation speed was about 10% lower with llama-server’s defaults in my run. I did not dig into why; the larger shared cache for four slots is the obvious difference. If you want the speed back, -np 1 costs nothing for a single user.
Where every gigabyte goes
llama.cpp prints a memory breakdown table when it loads a model, and Ollama copies it into its log. Together with nvidia-smi it shows exactly what fills the card:
| Part | Size here | What changes it |
|---|---|---|
| Model weights | 13.4GB | Only the model file and quantisation you choose. Identical in both tools. |
| KV cache | 0.4GB (4K) to 5.9GB (262K, 4 slots) | Context length, slots and cache type. The part Ollama’s defaults keep small. |
| Compute buffers | 0.3 to 0.7GB | Batch size and cache type. Grew from 0.27GB to 0.69GB when I switched to a q8_0 cache. |
| Vision projector | 1.2GB | Loaded by Ollama for every vision model, even for text-only chats. |
| CUDA runtime and other | About 0.4 to 0.5GB | The CUDA libraries and small work buffers. Roughly fixed. |
Three details here are worth knowing.
Gemma 4 has a cheap cache. Only 5 of its 30 layers keep the whole conversation. The other 25 use a sliding window of 1,024 tokens, so their part of the cache stays at 0.3 to 0.4GB per slot however long the context grows. The 5 full layers cost about 20KB per token: 0.6GB at 32K and 5GB at 262K. That is why llama-server’s 262K default still fitted on my card.
The 8-bit cache saved less than you might expect. Switching to q8_0 cut the cache at 128K from 2.8GB to 1.5GB, but the compute buffer grew by about 0.4GB, so the card only gained 0.9GB. With a model whose cache is bigger, the saving is much larger.
ollama ps shows less than the card uses. For the 128K run it reported 14.1GB on the GPU, while nvidia-smi saw 18.2GB more in use than before the model loaded. Use ollama ps to check the context and the GPU/CPU split, not to plan your free VRAM.
As a final check I started the standalone llama-server with Ollama’s exact flags from section 2. It used 16,877 MB against Ollama’s 16,874 MB, a difference of 3 MB. Same flags, same memory.
A surprise: OLLAMA_GPU_OVERHEAD did not stop a full load
Ollama has a setting to keep part of the card free: OLLAMA_GPU_OVERHEAD, in bytes. I set it to 12GiB, hoping to make my 24GB card behave like a 12GB one. Ollama’s log showed that it took the setting seriously: it listed available="10.0 GiB" and overhead="12.0 GiB", and it lowered the default context from 32K to 4K, the default for small cards.
But the model still loaded entirely on the GPU and used 15.6GB of VRAM, far more than the 10GiB Ollama said was available. The reason is in the same log. Ollama started llama-server without any --fit-target, so llama.cpp’s own fitting step saw 23GB free and reported “no changes needed”.
In Ollama 0.40.15 on my PC, OLLAMA_GPU_OVERHEAD changed the default context but did not limit where the model was placed. If you rely on it to keep VRAM free for a game or another app, check with nvidia-smi after the model loads. This may change in later versions.
So on a real 12GB card, how do the two tools decide what goes where? With llama-server it is fully visible, so I tested that directly in the next section.
What happens on a 12GB card
Gemma 4 26B needs about 16GB at a 32K context, so on a 12GB card part of it has to live in system RAM. I could not borrow a 12GB card, so I asked llama-server to leave 12GB of my card unused (--fit-target 12288) and watched its log to see what it decided. I also tried the manual settings in both tools at about the same VRAM.
llama-server with no context set did two things to fit. First it cut the context from 262,144 tokens all the way down to 4,096, the --fit-ctx minimum. Then, because even that was not enough, it moved part of the expert weights in 12 of the 30 layers into system RAM and kept everything else on the GPU. It used 11.9GB of VRAM. On a small card, then, llama-server’s “use everything” default ends up at the same 4K context that Ollama picks for cards under 24GB. It also kept its four slots, which share that small cache.
llama-server with -c 32768 kept the context I asked for (the log says context size set by user to 32768 -> no change) and moved the same expert weights. That is the part of a mixture-of-experts model that is used least per token, so it is the cheapest part to move.
Ollama has no documented setting for expert offload. Its num_gpu parameter still works and became -ngl in the llama-server command, which moves whole layers to the CPU. With num_gpu 23 it used 11.8GB, about the same as llama-server’s 11.9GB.
| Method, 32K context | VRAM | Generation | Prompt reading |
|---|---|---|---|
| Whole model on GPU (reference) | 16.2GB | 204 | 8,614 |
llama-server, --fit with a 12GB margin | 11.9GB | 96 | 1,737 |
llama-server, --n-cpu-moe 12 (all experts of 12 layers) | 11.7GB | 93 | 1,852 |
Ollama, num_gpu 23 | 11.8GB | 79 | 4,625 |
Ollama, num_gpu 15 | 8.1GB | 46 | 3,079 |
Speeds in tokens per second. At the same VRAM, moving experts generated about 21% faster than moving whole layers, which is what you feel in a chat. Moving whole layers read the long prompt about 2.7 times faster, which matters if you paste long documents. Both are far behind the 204 tokens per second with the whole model on the GPU, and that gap is the real cost of a small card.
What does Ollama do on its own when a model does not fit? In all my tests it never chose a layer count by itself: unless I set num_gpu, it started llama-server without -ngl, which leaves the placement to llama.cpp’s --fit with its default 1GB margin. So on a real 12GB card I would expect it to place the model much as llama-server does, at its 4K default context. I could not confirm that without a real 12GB card, so check ollama ps and the log on yours.
Is one of them faster?
Not when they use the same settings. Both send the same work to the same CUDA code, and the numbers show it:
| Setup | Prompt speed, Ollama | Prompt speed, llama-server | Generation, Ollama | Generation, llama-server |
|---|---|---|---|---|
| 32K, 16-bit cache | 8,448 | 8,614 | 203 | 204 |
| 128K, 16-bit cache | 8,730 | 8,626 | 203 | 204 |
| 128K, q8_0 cache | 8,132 | 8,029 | 192 | 192 |
| Each tool’s defaults | 8,448 (32K) | 8,857 (262K, 4 slots) | 203 | 181 |
All speeds are in tokens per second, for a prompt of about 4,850 tokens and 400 generated tokens, with the whole model on the GPU. The differences of 1 to 3% are within run-to-run noise. Two things did make a real difference:
- The q8_0 cache cost about 5 to 7% in both tools, for prompts and for generation. That is the price of the smaller cache, and it is usually worth paying when it lets the whole model stay on the GPU.
- llama-server’s default four slots generated about 10% slower than one slot in my run. For a single user,
-np 1is free speed.
What changes speed far more than either tool is whether the model fits on the GPU. As section 9 shows, pushing part of the model into system RAM cut the generation speed by more than half. That is why the VRAM question matters at all.
Load time is harder to compare fairly. Ollama took 41 seconds the first time because it read the 14GB file from disk without memory-mapping; later loads took about 4 seconds once Windows had the file in its cache. llama-server took about 18 seconds each time on the same PC. Your disk and your RAM will change these numbers more than the tool does.
Why the defaults matter more with other models
Gemma 4 is a gentle test, because its cache is small. Most models need far more memory per token of context, and then the two sets of defaults drift much further apart. These are the 16-bit cache sizes, worked out from each model’s official configuration in my KV cache guide:
| Model | Cache per token | Ollama default, card under 24GB (4K) | Ollama default, 24 to 48GB card (32K) | llama-server default (full trained length) |
|---|---|---|---|---|
| Gemma 4 26B-A4B (measured) | 20KB | 0.4GB* | 1.0GB* | 5.9GB* (4 slots) at 262K |
| Qwen4-35B-A3B | 20KB | 0.08GB | 0.6GB | 20GB at 1M |
| Qwen 3.6 27B | 64KB | 0.25GB | 2GB | 16GB at 262K |
| Qwen3-30B-A3B-2507 | 96KB | 0.4GB | 3GB | 24GB at 262K |
| Llama 3.1 8B | 128KB | 0.5GB | 4GB | 16GB at 128K |
* Gemma 4 rows are my measurements, including the sliding-window part. The others are my calculations for one slot, cache only.
Take Qwen3-30B-A3B on a 24GB card. Ollama gives it 32K tokens and a 3GB cache. llama-server on its own would ask for the full 262K, a 24GB cache that cannot fit next to the model. That is where --fit steps in: it shrinks the context until the model, the cache and the buffers fit with about 1GB to spare. So the practical rule is:
Uses a fixed, small amount of VRAM for the cache. Predictable, leaves room for other apps, but the model forgets long chats early.
Fills the card. It takes the longest context that fits, minus about 1GB. Long memory when the card is big enough, but nothing left for a game or a second model.
Neither is “more efficient”. One leaves VRAM unused by choice, the other uses it by choice. Once you set the context yourself, as the next sections show, the difference disappears.
Every Ollama setting that changes VRAM
Ollama hides llama.cpp’s flags, but most of them have an Ollama equivalent. Environment variables are read when the server starts, so quit the Ollama app from the tray (or stop ollama serve) and start it again after you change one. On Windows, set them in Settings → System → About → Advanced system settings → Environment Variables, or for one session in PowerShell with $env:OLLAMA_CONTEXT_LENGTH="65536"; ollama serve.
| Setting | Where | What it does to memory | llama.cpp equivalent |
|---|---|---|---|
num_ctx | Per request, Modelfile or /set parameter | The context length. The biggest lever: it sets the size of the KV cache. | -c |
OLLAMA_CONTEXT_LENGTH | Environment | The default context for every model. Overrides the VRAM-based default (4K, 32K or 256K). | -c |
| Context slider | Ollama app settings | The same setting as OLLAMA_CONTEXT_LENGTH, for the desktop app. | -c |
OLLAMA_KV_CACHE_TYPE | Environment | Cache precision: f16 (default), q8_0 or q4_0. Global, for all models. Needs flash attention. | -ctk -ctv |
OLLAMA_FLASH_ATTENTION | Environment | Ollama turns it on automatically where supported. 1 forces it on, 0 off. | -fa |
OLLAMA_NUM_PARALLEL | Environment | Requests served at once per model. Default 1 on PC GPUs. Each extra slot multiplies the context. | -np |
OLLAMA_MAX_LOADED_MODELS | Environment | How many models can stay loaded together. Default 3 per GPU, if they fit. | --models-max (router mode) |
OLLAMA_KEEP_ALIVE / keep_alive | Environment or per request | How long a model stays in VRAM after use. Default 5 minutes. 0 unloads at once, -1 keeps it forever. | --sleep-idle-seconds (roughly) |
OLLAMA_GPU_OVERHEAD | Environment | Meant to leave VRAM unused for other apps. In my test it lowered the default context but did not limit placement (section 8). | --fit-target |
num_gpu | Per request or Modelfile | Number of layers on the GPU. Lower it to push layers to system RAM. | -ngl |
OLLAMA_SCHED_SPREAD | Environment | Spread one model over all GPUs, even if it fits on one. | -sm layer |
There is no Ollama switch for the vision projector, the batch size or the slot layout. If you need those, run llama-server yourself.
Every llama.cpp setting that changes VRAM
With llama-server you set these yourself on the command line, or as LLAMA_ARG_ environment variables. Anything you leave unset is chosen by --fit, which is on by default. It starts from the model’s full trained context and shrinks things until the model fits with about 1GB to spare.
| Flag | Default | What it does to memory |
|---|---|---|
-c N | 0 = trained length | Context length. Set it, or --fit picks the biggest that fits, up to the model’s maximum. |
-np N | auto (4 in my test) | Conversation slots. With automatic slots the cache is shared (-kvu), but each slot can grow to the full context. Use -np 1 for one user. |
-ctk / -ctv | f16 | Cache precision. q8_0 roughly halves the cache with little quality loss. You can set keys and values separately. |
-fa | auto | Flash attention. Needed for a quantised value cache and smaller compute buffers. |
--fit / --fit-target N | on / 1024 MiB | Fit the model into free VRAM, leaving N MiB spare. Raise the target to leave room for a game or a second model. |
-ngl N | auto | Layers kept on the GPU. Fewer layers means less VRAM and much slower generation. |
--n-cpu-moe N / -cmoe | off | Keep the experts of the first N layers (or all layers) of a mixture-of-experts model in system RAM. The best way to squeeze a big MoE model onto a small card. |
-b / -ub | 2048 / 512 | Batch sizes. A smaller -ub shrinks the compute buffer but slows long prompts. |
--no-mmproj / --no-mmproj-offload | projector loaded and on GPU | Skip the vision projector, or keep it in system RAM. Saved 1.2GB on Gemma 4 in my test. |
-nkvo | off | Keep the KV cache in system RAM. Saves VRAM, but long prompts slow down a lot. |
--load-mode | auto (mmap) | How the file is read. Affects system RAM and load time, not VRAM. |
--cache-ram N | 8192 MiB | System RAM used to keep old prompts for reuse. Does not use VRAM. |
The defaults that cost the most VRAM are the first two. An unset -c with automatic slots is a good default for a server shared by several people, and a poor one for a single person on a gaming card.
Make them behave the same
Since the engine is shared, you can make either tool behave like the other. These recipes are for Windows PowerShell; on Linux or macOS use export NAME=value instead of $env:.
Use Ollama’s model files in llama-server
Ollama stores models as ordinary GGUF files with long hash names. Ask Ollama which ones belong to a model:
ollama show --modelfile gemma4:26b-a4b-it-qat
# FROM gemma4:26b-a4b-it-qat
FROM C:\Users\you\.ollama\models\blobs\sha256-4c85...d054c5 <- the model
FROM C:\Users\you\.ollama\models\blobs\sha256-d8e2...9239 <- the vision projector
The first FROM line with a path is the model, the second (if there is one) is the vision projector. The files live in %USERPROFILE%\.ollama\models\blobs unless you moved them with OLLAMA_MODELS. Use them in place; do not rename or delete them, or Ollama will lose the model.
llama-server with Ollama’s memory use
llama-server -m <model blob> --mmproj <projector blob> -c 32768 -np 1
This matches Ollama’s default on a 24GB card. Leave out --mmproj if you only chat in text, and you save the projector’s 1.2GB.
A lean llama-server for one user
llama-server -m <model blob> -c 32768 -np 1 -fa on -ctk q8_0 -ctv q8_0
One slot, a fixed 32K context, flash attention and an 8-bit cache, and no projector. For a 12GB card and a mixture-of-experts model, add expert offload and raise the number until the model fits:
llama-server -m <model blob> -c 32768 -np 1 -fa on -ctk q8_0 -ctv q8_0 --n-cpu-moe 12
A lean Ollama
$env:OLLAMA_CONTEXT_LENGTH="32768"
$env:OLLAMA_KV_CACHE_TYPE="q8_0"
$env:OLLAMA_MAX_LOADED_MODELS="1"
ollama serve
Quit the Ollama app from the tray first, or the new values will not be used. To keep these for good, set them as Windows user environment variables and restart the app. For one model only, put PARAMETER num_ctx 32768 in a Modelfile and create a copy with ollama create.
Ollama with llama-server’s long memory
Set OLLAMA_CONTEXT_LENGTH to the length you need, for example 131072, and keep OLLAMA_KV_CACHE_TYPE=q8_0. Check with ollama ps that the PROCESSOR column still says 100% GPU. If it does not, lower the context again: a model split between GPU and CPU loses far more speed than a shorter context costs.
How to see the real VRAM use on your own PC
Do not trust one number. Each tool counts something slightly different, and I used all of them for this article.
| Tool | What it shows | What it misses |
|---|---|---|
ollama ps | Size of the loaded model, the GPU and CPU split, the context and when it unloads. | Leaves out some buffers and the CUDA runtime, so it reads lower than Task Manager. |
nvidia-smi | Total VRAM used on the card by every program. | Cannot split the model from the cache. Subtract the number you see before loading. |
| Task Manager → Performance → GPU | Dedicated GPU memory, the same total as nvidia-smi. | Shared GPU memory there is system RAM, not VRAM. |
| llama-server log | The memory breakdown table: model, context and compute per device, plus KV buffer size lines. | Needs -lv 4 for the full table. Ollama writes this log to server.log. |
/props endpoint | The context per slot and the number of slots llama-server picked. | No memory figures. |
On Windows, Ollama’s logs are in %LOCALAPPDATA%\Ollama. Open server.log after loading a model and search for starting llama-server: the line shows the exact flags Ollama used. A few lines further down, the memory breakdown table shows where every megabyte went.
What about Macs?
Everything above is about Windows and Linux PCs with a graphics card. On Apple Silicon the picture is different in two ways.
- Ollama may not use llama.cpp at all. Since Ollama 0.40, models whose architecture the MLX runtime supports run on Apple’s MLX by default. Other models still run on llama.cpp with Metal. So on a Mac, “Ollama vs llama.cpp” can really be “MLX vs llama.cpp”, and the memory use can differ for real reasons, not just settings.
- There is no separate VRAM. The GPU shares the Mac’s unified memory, and macOS lets the GPU use only part of it by default. The model, the cache and every other app compete for the same pool.
- The context default still applies. Ollama picks the default context from the memory the GPU can use, so a Mac with lots of memory can get a much larger default context than a 16GB PC card.
I did not measure a Mac for this article, so I give no Mac numbers. The settings advice is the same: set the context yourself, use an 8-bit cache, and check ollama ps.
For a worked Mac example, my guide to running Qwen4 on a Mac compares the memory Ollama, llama.cpp, LM Studio and MLX need for the same model, and shows how to check and raise the GPU memory limit.
Which one should you use?
Since the engine is the same, choose by how you work, not by VRAM.
You want one command to download and run models, you switch between several models, you use apps that expect Ollama’s API (Open WebUI, coding tools, ollama launch), or you want models to unload by themselves when idle. Set OLLAMA_CONTEXT_LENGTH and OLLAMA_KV_CACHE_TYPE once and it will use VRAM as well as llama.cpp does.
You want every setting: per-model cache types, the vision projector off, exact batch sizes, expert offload with --n-cpu-moe, speculative decoding options, or the newest llama.cpp the day it comes out. It is also the better choice on a small card, where fine control decides whether a model fits.
Or use both. Ollama’s downloaded files are ordinary GGUF files. You can point llama-server at them (section 14) and keep Ollama for everyday use. Just do not run both with big models at once: each reserves its own VRAM.
For VRAM alone, there is one honest answer: the one you configure uses less. A tuned Ollama and a tuned llama-server land within a few hundred MB of each other.
Troubleshooting VRAM problems in both
| Symptom | Likely cause | Fix |
|---|---|---|
| The model runs much slower in Ollama than in llama-server | Ollama put some layers on the CPU (ollama ps shows something like 30%/70% CPU/GPU) | Lower num_ctx, set OLLAMA_KV_CACHE_TYPE=q8_0, or close other GPU apps |
| llama-server uses almost all my VRAM | No -c given, so --fit took the longest context that fits | Set -c yourself, for example -c 32768 |
| Ollama forgets the start of long chats | Default context of 4K or 32K | Raise num_ctx or OLLAMA_CONTEXT_LENGTH |
| Same model, 1 to 2GB more in Ollama | The vision projector, a bigger context, or a second model still loaded | Check ollama ps; use a text-only model or run llama-server without --mmproj |
| VRAM stays full after I stop chatting | Ollama keeps a model for 5 minutes; llama-server keeps it until closed | Set keep_alive to 0, run ollama stop <model>, or close llama-server |
| llama-server crashes with an out-of-memory error at load | --fit off, or another app took VRAM between the check and the load | Leave --fit on, raise --fit-target, or lower -c |
| Everything slows to a crawl when VRAM is full, with no error | On Windows the NVIDIA driver can spill GPU memory into system RAM instead of failing | Watch “Shared GPU memory” in Task Manager; free VRAM until it stays near zero |
OLLAMA_KV_CACHE_TYPE changes nothing | Flash attention not active, or the server was not restarted | Restart Ollama fully from the tray; set OLLAMA_FLASH_ATTENTION=1 |
| Two models fight for VRAM | Ollama keeps up to 3 models per GPU loaded | Set OLLAMA_MAX_LOADED_MODELS=1 |
Frequently asked questions
Does Ollama use more VRAM than llama.cpp?
Not with the same settings. In my tests the gap was 13 MB at 128K and 311 MB at 32K. With default settings Ollama usually uses less, because it picks a small context.
Is Ollama just llama.cpp now?
On Windows and Linux it runs models with llama.cpp’s llama-server, since version 0.30. Ollama adds the model library, the scheduler, the API and the app. On Apple Silicon it uses MLX for supported models.
Why does llama-server fill my whole GPU?
Because without -c it asks for the model’s full trained context and lets --fit shrink it until about 1GB is left. Set -c to the length you need.
Why does Ollama give me only 4K or 32K of context?
Its default depends on VRAM: 4K under 24GB, 32K from 24 to 48GB, 256K at 48GB or more. Raise num_ctx or OLLAMA_CONTEXT_LENGTH.
Is llama.cpp faster than Ollama?
With the same settings, no: within 1 to 3% in my tests, which is noise. Differences come from settings such as slots, cache type and how much of the model is on the GPU.
Does Ollama load the vision part of a model even for text?
Yes, for models that include a projector. With Gemma 4 that cost me 1.2GB. llama-server loads it only if you pass --mmproj.
Does an 8-bit KV cache hurt quality?
Ollama’s FAQ says q8_0 usually has no noticeable impact. It cost me 5 to 7% speed and saved 0.9GB at 128K with Gemma 4; with models that have a bigger cache it saves much more.
Can I set the KV cache type per model in Ollama?
No. OLLAMA_KV_CACHE_TYPE is global. llama-server lets you set it per launch, even separately for keys and values.
Can Ollama offload only the experts of a MoE model?
Not with a documented setting. num_gpu moves whole layers. llama-server has --n-cpu-moe and -cmoe, and its --fit does it automatically.
Why does ollama ps show less memory than Task Manager?
It reports the model’s size estimate, not every buffer and the CUDA runtime. In my 128K test it showed 14.1GB while the card had 18.2GB more in use.
Can I run Ollama and llama-server at the same time?
Yes, on different ports (11434 and 8080 by default), but each loads its own copy of a model and its own cache. Two copies of a 14GB model will not fit on a 24GB card.
Should I switch from Ollama to llama.cpp to save VRAM?
Only if you need settings Ollama does not have, such as expert offload or a per-model cache type. Otherwise set the context and cache type in Ollama and you get the same memory use.
Does OLLAMA_GPU_OVERHEAD keep VRAM free for games?
Not reliably in my test with Ollama 0.40.15: with 12GiB set, it lowered the default context to 4K but still put the whole model on the GPU. Check with nvidia-smi after loading, or limit the context and layers directly.
Does LM Studio behave the same way?
LM Studio also uses llama.cpp for GGUF models and has its own defaults and settings. I did not measure it here; the same rule applies: compare at the same context and cache type.
Your next step
Open Ollama’s server.log after you load your favourite model and find the starting llama-server line. It tells you the context, slots and batch Ollama chose, and the memory breakdown table below it shows the cost. Then decide what you actually need: for most chats and coding, 32K with an 8-bit cache is plenty. If you need much longer contexts, read my guide to KV cache memory first, and if your card is small, my Qwen4 guide for 8GB to 16GB cards shows expert offload in practice. For faster generation on any card, see the llama.cpp MTP guide.
Sources: Ollama 0.30 release notes, Ollama 0.40.2 release notes, Ollama 0.15.5 release notes (VRAM-based context), Ollama context length docs, Ollama FAQ, llama.cpp server README, Gemma 4 on Ollama. All VRAM and speed figures are my own measurements on 6 December 2026; the per-token cache sizes for other models are my calculations from their official configuration files.