Run a local LLM with Ollama

Ollama downloads a model and serves it with one command. It runs as a background service, loads models on demand and unloads them when idle. Under the hood it uses llama.cpp and GGUF files.

macOS, Linux, Windows · model sizes synced 2026-11-30

Pick Ollama when

  • You want the shortest path from nothing to a running model.
  • You switch between several models and want them loaded on demand.
  • Your tools already speak the Ollama or OpenAI API.

Look elsewhere when

  • You need a quantization Ollama does not publish for the model.
  • You serve many users at once: vLLM batches far better.

1. Install

Linux

The install script sets up the binary and a systemd service.

macOS and Windows

Download the app from ollama.com/download. It installs the ollama command and keeps itself updated.

Check that it worked

2. Run a model

Example: Qwen 3.8 27B as Q4_K_M on NVIDIA GeForce RTX 4090 (24 GB). With a 16K context it needs 19.0 GB of 22.8 GB usable memory and should generate about 38–52 tok/s.

Size your own model and hardware for Ollama

3. The settings that decide memory use

Set the context window

Ollama picks a default from your VRAM: 4K below 24 GB, 32K from 24 to 48 GB, 256K above. That default, not the model, decides how much memory the KV cache takes. Set it explicitly when you start the server, or with the slider in the app's settings.

Halve the KV cache

The KV cache can be stored in 8 bits instead of 16 when Flash Attention is active. The setting is global: it applies to every model the server loads.

Check what actually loaded

ollama ps shows the size in memory, the context length in use and the split between GPU and CPU. Anything other than 100% GPU means part of the model spilled into system memory and generation will be slow.

4. Connect your tools

Use it from other tools

The server listens on 127.0.0.1:11434. The native API lives under /api, an OpenAI-compatible one under /v1. Change the address with OLLAMA_HOST.

Or let your coding agent do it

Paste this into Claude Code, Codex or any agent with a shell. It carries the target, our estimates and the steps, and tells the agent to check the hardware first and to report measured memory and speed against the estimates. The calculator builds the same prompt for any model, hardware and runtime.

Set up a local LLM on this machine and verify that it works.

Target
- Model: Qwen 3.8 27B (Hugging Face: Qwen/Qwen3.8-27B)
- Runtime: Ollama
- Build: Q4_K_M, qwen3.8:27b
- Context window: 16,384 tokens (16K)
- Hardware this was sized for: NVIDIA GeForce RTX 4090 (24 GB)

Estimates from llmsizing.com
- Memory: 19.0 GB of 22.8 GB usable (weights 16.5 GB, KV cache 1.0 GB, approximate, overhead 1.5 GB)
- Fit: Fits comfortably. 3.8 GB headroom left for a longer context or other apps.
- Speed: 38–52 tok/s for one request. Scaled from 10 published llama.cpp measurements on this GPU.

Steps
1. Check the hardware before downloading anything (`nvidia-smi`, or the vendor's equivalent). If it is not NVIDIA GeForce RTX 4090 (24 GB), or less than 19.0 GB of memory is free, stop and tell me what you found.
2. Check whether Ollama is installed with `ollama --version`. If it is not, install it:
   - Linux: `curl -fsSL https://ollama.com/install.sh | sh`
   - macOS and Windows: Download the app from ollama.com/download. It installs the `ollama` command and keeps itself updated.
3. Ollama's default context depends on VRAM, not on this plan. Start the server with OLLAMA_CONTEXT_LENGTH=16384 set (on Linux via the systemd unit's environment, on macOS via `launchctl setenv` or the app's settings), then restart it.
4. Start the model: `ollama run qwen3.8:27b`
5. Send one short test prompt. Then report, next to the estimates above: memory actually used (`ollama ps`), tokens per second, and whether everything runs on the GPU.
6. Tell me the base URL and model name to use from other tools. Ollama API: http://localhost:11434/v1.

Rules
- Ask me before using sudo, changing system settings or installing system packages.
- Do not delete or replace models that are already on this machine.
- If the download is larger than the free disk space, stop and tell me.
- If the measured memory or speed is far from the estimates, say so plainly.

Sized with https://llmsizing.com/?m=qwen3-8-27b&hw=rtx-4090-24gb&q=q4_k_m&ctx=16384&rt=ollama
Setup guide: https://llmsizing.com/guides/ollama

How to read our numbers for Ollama

Weights are loaded once and the KV cache is allocated for the full context window up front, so memory use does not grow while you chat. Our numbers for Ollama use the file size of the exact tag from the Ollama registry.

  • A model that does not fit is not refused: Ollama moves layers to the CPU and gets several times slower. Check ollama ps.
  • Raising the context window after a model is loaded reloads it.

134 models with a ready Q4_K_M build for Ollama

Command
Qwen 3 0.6B0.5 GB
Llama 3.2 1B Instruct0.8 GB
Gemma 3 1B0.8 GB
SmolLM2 1.7B1.0 GB
LFM3 1.7B1.0 GB
DeepSeek R1 Distill Qwen 1.5B1.0 GB
Qwen 3 1.7B1.3 GB
Gemma 2 2B1.6 GB
Qwen 2.5 3B1.8 GB
Qwen 3.5 2B1.8 GB
Granite 4.0 H Micro 3B1.8 GB
Llama 3.2 3B Instruct1.9 GB
Granite 4.2 3B2.1 GB
Phi-3 Mini 3.8B2.2 GB
Phi-4 Mini 3.8B2.3 GB
Qwen 3 4B Instruct 25072.3 GB
Nemotron 3 Nano 4B2.6 GB
Ministral 3 3B2.8 GB
Phi-4 Mini Reasoning 3.8B2.9 GB
Qwen 3.5 4B3.1 GB
MedGemma 4B3.1 GB
Gemma 3 4B3.1 GB
Code Llama 7B Instruct3.8 GB
Granite 4.0 H Tiny 7B A1B (MoE)3.9 GB
Mistral 7B Instruct v0.34.1 GB
Olmo 3 7B Think4.2 GB
Olmo 3 7B Instruct4.2 GB
Falcon3 7B Instruct4.3 GB
Gemma 4 E2B4.3 GB
Qwen 2.5 Coder 7B4.4 GB
Qwen 2.5 7B4.4 GB
DeepSeek R1 Distill Qwen 7B4.4 GB
EXAONE 3.5 7.8B Instruct4.4 GB
EXAONE Deep 7.8B4.4 GB
Llama 3.1 8B Instruct4.6 GB
Llama 3 8B Instruct4.6 GB
Granite 3.3 8B4.6 GB
Aya Expanse 8B4.7 GB
LFM2.5 8B A1B (MoE)4.8 GB
Qwen 3 8B4.9 GB
DeepSeek R1 Distill Llama 8B4.9 GB
CodeGemma 7B5.0 GB
Granite 4.2 8B5.0 GB
Gemma 2 9B5.4 GB
Qwen 2.5 VL 7B5.6 GB
Ministral 3 8B5.6 GB
Qwen 3 VL 8B5.8 GB
GLM-4 9B Chat5.8 GB
Falcon3 10B Instruct5.9 GB
Qwen 3.5 9B6.1 GB
MiMo V2.6 Distill Qwen 9B6.1 GB
Gemma 4 E4B6.1 GB
Mistral Nemo 12B7.0 GB
Llama 3.2 11B Vision Instruct7.3 GB
Gemma 3n E2B7.3 GB
Code Llama 13B Instruct7.3 GB
Gemma 4 12B7.5 GB
Gemma 3 12B7.6 GB
Phi-3 Medium 14B8.0 GB
DeepSeek R1 Distill Qwen 14B8.4 GB
Qwen 2.5 14B8.4 GB
Qwen 2.5 Coder 14B8.4 GB
Phi-4 14B8.4 GB
Ministral 3 14B8.5 GB
Qwen 3 14B8.6 GB
Gemma 3n E4B9.1 GB
DeepSeek Coder V2 Lite (16B MoE)9.7 GB
Phi-4 Reasoning Plus 14B10.3 GB
Phi-4 Reasoning 14B10.3 GB
gpt-oss-20b (MoE)12.8 GB
Devstral Small 24B13.3 GB
Magistral Small 24B13.3 GB
LFM2.5 24B A2B (MoE)13.5 GB
Mistral Small 3.2 24B14.1 GB
Devstral Small 2 24B14.1 GB
Mistral Small 3.1 24B14.4 GB
Gemma 2 27B15.5 GB
MedGemma 27B16.2 GB
Gemma 3 27B16.2 GB
Qwen 3.5 27B16.3 GB
Granite 4.2 30B16.5 GB
Qwen 3.8 27B16.5 GB
Qwen 3.6 27B16.6 GB
Qwen 3 30B A3B (MoE)17.3 GB
Qwen 3 Coder 30B A3B17.3 GB
Gemma 4 26B A4B (MoE)17.4 GB
GLM-4.7 Flash (30B-A3B MoE)17.7 GB
EXAONE 3.5 32B Instruct18.0 GB
EXAONE Deep 32B18.0 GB
Granite 4.0 H Small 32B A9B (MoE)18.1 GB
Olmo 3.1 32B Instruct18.1 GB
Qwen 3 VL 30B A3B (MoE)18.3 GB
Command R 35B18.4 GB
Aya Expanse 32B18.4 GB
Qwen 2.5 Coder 32B18.5 GB
QwQ 32B18.5 GB
DeepSeek R1 Distill Qwen 32B18.5 GB
Qwen 2.5 32B18.5 GB
Qwen 3 32B18.8 GB
Code Llama 34B Instruct18.8 GB
Gemma 4 31B19.0 GB
Qwen 3.5 35B A3B (MoE)20.6 GB
Qwen 3.6 35B A3B (MoE)21.1 GB
Nemotron 3 Nano 30B A3B (MoE)22.6 GB
Nemotron Cascade 2 30B A3B (MoE)22.6 GB
Nemotron 3.5 Lightning 30B A3B23.7 GB
Qwen 4 35B A3B (MoE)34.4 GB
DeepSeek R1 Distill Llama 70B39.6 GB
Llama 3.3 70B Instruct39.6 GB
Llama 3 70B Instruct39.6 GB
Llama 3.1 70B Instruct39.6 GB
Llama 3.1 Nemotron 70B Instruct39.6 GB
Qwen 2.5 72B44.2 GB
Qwen 2.5 VL 72B45.4 GB
Qwen3 Next 80B A3B (MoE)46.9 GB
Qwen3 Coder Next 80B A3B (MoE)48.2 GB
Llama 3.2 90B Vision Instruct50.9 GB
Command R+ 104B58.4 GB
gpt-oss-120b (MoE)60.9 GB
Command A 111B62.5 GB
Llama 4 Scout (109B MoE)62.8 GB
Mistral Large 2 (123B)68.2 GB
Devstral 2 123B69.8 GB
Mistral Medium 3.5 (128B)74.7 GB
Qwen 3.5 122B A10B (MoE)75.8 GB
Nemotron 3 Super 120B A12B (MoE)80.9 GB
Nemotron 3.5 Super 120B A12B84.0 GB
Qwen 3 235B A22B (MoE)132 GB
Llama 3.1 405B Instruct226 GB
Llama 4 Maverick (400B MoE)228 GB
Qwen 3 Coder 480B A35B270 GB
DeepSeek R1 (671B MoE)377 GB
DeepSeek V3.2 (671B MoE)377 GB
DeepSeek V3.1 (671B MoE)377 GB