Skip to content

How-ToGPU

How to Keep Ollama Models Loaded (or Unload Them to Free VRAM)

Ollama unloads models five minutes after your last request. Use ollama ps to see what's loaded, ollama stop to free VRAM straight away, the keep_alive API parameter per request, and OLLAMA_KEEP_ALIVE or OLLAMA_MAX_LOADED_MODELS to change the defaults.

By , Editorial team

3 min read

How to Keep Ollama Models Loaded (or Unload Them to Free VRAM)

By default, Ollama keeps a model in memory for five minutes after your last request, then unloads it. That's a sensible middle ground, but it's wrong for two common setups: an always-on assistant where you don't want to wait for the model to reload, and a gaming PC where you want your VRAM back the moment you finish chatting. This guide follows Ollama's own documentation; Forge PC hasn't measured load times on any particular system, because they depend on the model size, your drive and your GPU.

Step 1: See what's loaded

Open a terminal (Command Prompt, PowerShell or Terminal) and run:

ollama ps

Ollama lists every loaded model with its size, a PROCESSOR column and an UNTIL column. According to Ollama's FAQ, "100% GPU" means the model is entirely in VRAM, "100% CPU" means it's entirely in system RAM, and a split such as "48%/52% CPU/GPU" means it's spread across both. UNTIL shows when it will be unloaded.

If a model you expected on the GPU shows a CPU share, it doesn't fit in VRAM. Our guides to checking VRAM usage in Windows and setting Ollama's context length help you work out why.

Step 2: Unload a model straight away

To free memory immediately, for example before launching a game:

ollama stop llama3.2

Replace llama3.2 with the model name shown by ollama ps. If you use the API instead, Ollama's FAQ says you can send a request with keep_alive set to 0:

curl http://localhost:11434/api/generate -d '{"model": "llama3.2", "keep_alive": 0}'

Step 3: Keep a model loaded for longer (or forever)

The keep_alive parameter on the /api/generate and /api/chat endpoints accepts:

Value

Effect

A duration such as "10m" or "24h"

Keep the model loaded for that long after the request

A number of seconds, such as 3600

Same, in seconds

Any negative number, such as -1

Keep the model loaded indefinitely

0

Unload as soon as the response is finished

To preload a model and keep it in memory:

curl http://localhost:11434/api/generate -d '{"model": "llama3.2", "keep_alive": -1}'

The FAQ also shows a CLI way to preload a model: ollama run llama3.2 "".

Step 4: Change the default for every model

To change the five-minute default for all models, set the OLLAMA_KEEP_ALIVE environment variable. It takes the same values as keep_alive. On Windows, Ollama's instructions are:

  1. Quit Ollama from its icon in the taskbar.

  2. Open Settings (Windows 11) and search for environment variables.

  3. Select Edit environment variables for your account.

  4. Create a new variable called OLLAMA_KEEP_ALIVE with a value such as 30m or -1.

  5. Click OK, then start Ollama again from the Start menu.

On Linux, where Ollama runs as a systemd service, use systemctl edit ollama.service to add the variable, then reload and restart the service. Note that a keep_alive value sent with an API request overrides OLLAMA_KEEP_ALIVE, so apps that send their own value (Home Assistant's Ollama integration has its own Keep alive setting, for example) will ignore your default.

Step 5: Control how many models stay loaded

If you switch between models, Ollama can keep several in memory if they fit. The FAQ says OLLAMA_MAX_LOADED_MODELS sets the maximum number loaded at once, defaulting to three per GPU (or three for CPU inference). When there isn't enough memory for a new model, Ollama queues the request and unloads idle models to make room. On a single 8GB to 16GB card, setting OLLAMA_MAX_LOADED_MODELS=1 keeps behaviour predictable.

Which setting should you use?

  • Gaming PC that also runs Ollama: leave the default, or set OLLAMA_KEEP_ALIVE=0, and run ollama stop before you play.

  • Dedicated AI box or home server: set OLLAMA_KEEP_ALIVE=-1 so your assistant always answers quickly. If other devices use it, see how to share Ollama on your local network and how to use Ollama with Home Assistant.

  • Several models in rotation: use a longer duration like 30m and cap OLLAMA_MAX_LOADED_MODELS.

For more tuning, see how to speed up a local LLM in Ollama and how to manage Ollama models.

Our verdict

Use ollama ps to see what's in memory, ollama stop to free VRAM instantly, and OLLAMA_KEEP_ALIVE to change the five-minute default: -1 for an always-ready assistant, 0 or the default for a PC you also game on.

The bottom line

Use `ollama ps` to see what's in memory, `ollama stop` to free VRAM instantly, and `OLLAMA_KEEP_ALIVE` to change the five-minute default: `-1` for an always-ready assistant, `0` or the default for a PC you also game on.

Sources

  1. 01Ollama, FAQ
  2. 02Ollama, API reference: Generate a response
  3. 03Ollama, CLI reference

About the author

Forge PC Staff

Editorial team

The shared byline for articles researched, written and edited by the Forge PC editorial team. How we source, check and correct our work is set out in our editorial policy.

More from Forge PC Staff

Read next

Best Free Keyboard and Mouse Remapping Software for Windows

Best Picks

Best Free Keyboard and Mouse Remapping Software for Windows in 2026

PowerToys Keyboard Manager is the best free remapping tool for most people. SharpKeys makes permanent key swaps with nothing running in the background, X-Mouse Button Control handles mouse buttons and per-app profiles, and AutoHotkey covers macros.

Forge PC Staff4 min

How to Set Up OBS Microphone Filters for Clearer Streams

How-To

How to Set Up OBS Microphone Filters for Clearer Streams

OBS Studio's built-in audio filters can clean up your mic: Noise Suppression for fan hiss, a Noise Gate for silence between sentences, a Compressor near the start of the chain for loud moments and a Limiter last to stop clipping. Start from OBS's defaults.

Forge PC Staff3 min

How to Use Ollama With Home Assistant for a Local AI Voice Assistant

How-To

How to Use Ollama With Home Assistant for a Local AI Voice Assistant

Home Assistant's Ollama integration lets a model on your own PC power Assist. Expose Ollama on your network with OLLAMA_HOST, add the integration with your server's URL, pick a tool-capable model and expose only the entities you want it to control.

Forge PC Staff3 min

RTX 5070 vs RTX 5070 Ti for Local AI: Is 16GB Worth the Step Up?

Versus

RTX 5070 vs RTX 5070 Ti for Local AI: Is 16GB Worth the Step Up?

For local AI, the RTX 5070 Ti's 16GB of GDDR7 on a 256-bit bus matters more than its extra CUDA cores. NVIDIA lists the RTX 5070 with 12GB on a 192-bit bus, 988 AI TOPS and 250W, against 1,406 AI TOPS and 300W for the Ti.

Forge PC Staff2 min