New Tool Radar

Local AI

How to Run Two Ollama Models at the Same Time

Let Ollama load two models at once and handle parallel requests, using OLLAMA_MAX_LOADED_MODELS and OLLAMA_NUM_PARALLEL.

Schematic diagram with three steps: set OLLAMA_NUM_PARALLEL and OLLAMA_MAX_LOADED_MODELS, start the server with ollama serve, then send two requests so both models stay loaded and answer.

By default, a second request can end up waiting while the first finishes, and a second model can push the first one out of memory. The Ollama FAQ describes two levels of concurrent processing: if the system has enough memory, “multiple models can be loaded at the same time”, and each loaded model can handle several requests in parallel. Three server settings control both levels, and you set them before starting the server.

The three settings that decide what runs together

The FAQ lists all three, with their defaults. The parallel-requests guide gives the same defaults: a queue of 512, and a loaded-model limit of 3 per GPU or 3 on CPU.

Setting What it controls Default
OLLAMA_MAX_LOADED_MODELS How many different models stay loaded at once 3 times the number of GPUs, or 3 for CPU inference
OLLAMA_NUM_PARALLEL How many requests each loaded model handles at the same time 1 on most backends; MLX on Metal picks a conservative default from memory
OLLAMA_MAX_QUEUE How many requests wait in line before the server refuses more 512

Try it: start the server with room for two models

Set the two settings, then start the server. The export lines below are the parallel-requests guide’s own example, with the loaded-models limit added the same way the guide shows it.

export OLLAMA_MAX_LOADED_MODELS=2
export OLLAMA_NUM_PARALLEL=2
ollama serve

Check What you should see
Send one request to each of two models Both requests are handled instead of the second one waiting
ollama ps while both are in use Both models listed as loaded at the same time
Send a third request to a third model If memory is short, an idle model is unloaded to make room and the request is queued until the new model can load

Expected result. We checked the Ollama FAQ and the parallel-requests guide. We did not run ollama serve or load two models on this machine.

Limits

More parallelism costs memory: the FAQ says parallel request processing “results in increasing the context size by the number of parallel requests”, so a 2K context with 4 parallel requests becomes an 8K context with extra memory allocated. When using GPU inference, a new model must be able to completely fit in VRAM before it can load alongside another. And if the queue fills up, the server answers new requests with a 503 overloaded error. We did not test any of this ourselves.

Sources

See all