Local and Private AI
How to Run an LLM Locally in 2026: Tools, Hardware and Models
By Amjid Ali · · 9 min read

In this article
To run an LLM locally, install a runner such as Ollama or LM Studio, download an open-weight model that fits in your memory, and chat with it or call it through a local API. On macOS or Linux the whole thing is two commands: curl -fsSL https://ollama.com/install.sh | sh, then ollama run gemma4. The real decision is the model: a 4-bit model needs a little over half a gigabyte of RAM or VRAM per billion parameters, plus room for context.
Quick answer: which tool to use
| Tool | Best for | Interface | License | Local API |
|---|---|---|---|---|
| Ollama | Most people, developers, agents | CLI, desktop app, REST API | MIT | localhost:11434 (native and OpenAI-compatible) |
| LM Studio | Browsing and testing models visually, Mac MLX | Desktop GUI, lms CLI, headless llmster |
Free for home and work (its lms CLI and MLX engine are MIT open source) |
OpenAI- and Anthropic-compatible endpoints |
| llama.cpp | Maximum control, any hardware, the engine under many tools | CLI and llama serve with web UI |
MIT | OpenAI-compatible server |
| vLLM | Serving many users on NVIDIA or AMD GPUs | Python, vllm serve |
Apache-2.0 | OpenAI-compatible, localhost:8000 |
| Jan | An offline ChatGPT-style app | Desktop GUI | Apache-2.0 | localhost:1337 |
If you are not sure, start with Ollama. If you prefer clicking to typing, start with LM Studio. We compare those two in detail in Ollama vs LM Studio.
Why run an LLM locally?
- Privacy. Prompts, documents and code never leave your machine. Ollama's FAQ says local use isn't visible to Ollama at all.
- No per-token bill. Once you own the hardware, heavy use costs electricity.
- Offline and stable. It works on a plane, and the model only changes when you change it.
- Control. You pick the exact model, quantization, context length and system prompt.
The trade-off is honest: the best closed models still lead on the hardest tasks, and a laptop will not match a data center's speed. Local models are excellent for private drafting, summarizing, coding help, classification and agents that work on your own files. For a sense of where open models sit against the frontier, see our roundup of the best LLMs.
The five main options
Ollama
Ollama is the most widely used runner. It downloads models from its library, manages GPU offload, and exposes a REST API on 127.0.0.1:11434, plus an OpenAI-compatible API at /v1. Its README lists llama.cpp as the supported backend. Recent versions also have ollama launch, which wires local models into coding agents such as Claude Code, Codex and OpenCode.
LM Studio
LM Studio is a desktop app for finding, downloading and chatting with models, with a local server for other apps. It runs GGUF models through llama.cpp on every platform and MLX models on Apple Silicon. It also acts as an MCP client, so local models can use MCP servers. Since 8 July 2025, LM Studio says it is "free to use both at home and at work".
llama.cpp
llama.cpp is the C/C++ engine that made local LLMs practical, and it is what Ollama and LM Studio build on. It supports Apple Silicon ("a first-class citizen"), CUDA, AMD via HIP, Vulkan, SYCL and CPU+GPU hybrid inference for models bigger than your VRAM. The current quick start uses one llama command:
curl -LsSf https://llama.app/install.sh | sh
llama cli -hf ggml-org/Qwen3.5-0.8B-GGUF # chat in the terminal
llama serve -hf ggml-org/Qwen3.5-0.8B-GGUF # OpenAI-compatible server and web UI
vLLM
vLLM is a high-throughput serving engine for production. Its quickstart targets Linux with Python 3.11 to 3.14, installs with uv pip install vllm --torch-backend=auto, and serves an OpenAI-compatible API on port 8000. It shines when several users or agents hit one GPU server. For a single person on a laptop, it is more than you need.
Jan
Jan is an Apache-2.0 desktop app that "runs 100% offline", downloads models from Hugging Face, supports MCP, and offers an OpenAI-compatible server at localhost:1337. It can also connect to cloud providers if you want one app for both.
What hardware do you need?
Memory is the constraint that matters. The model's weights must fit in GPU memory (VRAM) for good speed, or in unified memory on a Mac, with room left for the KV cache that holds your conversation.
The arithmetic
Weights (GB) ≈ parameters (billions) × bits per weight ÷ 8.
llama.cpp publishes the effective bits per weight of its formats: about 4.89 for Q4_K_M, 5.70 for Q5_K_M, 6.56 for Q6_K, 8.50 for Q8_0 and 16 for F16. So a 27B model at Q4_K_M is about 27 × 4.89 ÷ 8 ≈ 16.5 GB. Ollama lists its qwen3.8:27b download at 18 GB, which matches once you add the vision encoder and metadata.
Google's Gemma 4 docs give official weights-only figures:
| Gemma 4 model | BF16 | 8-bit | 4-bit |
|---|---|---|---|
| E2B | 11.4 GB | 5.7 GB | 2.9 GB |
| E4B | 17.9 GB | 8.9 GB | 4.5 GB |
| 12B | 26.7 GB | 13.4 GB | 6.7 GB |
| 26B A4B (MoE) | 57.7 GB | 28.8 GB | 14.4 GB |
| 31B | 69.9 GB | 34.9 GB | 17.5 GB |
Two things to notice. First, 4-bit cuts memory to about a quarter of 16-bit, which is why almost everyone runs 4-bit locally. Second, a mixture-of-experts model like the 26B A4B only computes about 4B parameters per token, but you still have to load all 26B.
Then add the KV cache, which grows with context length. Long contexts for agents and coding can add several gigabytes. Our local LLM hardware guide works through the KV cache formula and a full sizing table.
Rough tiers
| Memory available to the model | What fits comfortably at 4-bit |
|---|---|
| 8 GB | Small models: Gemma 4 E2B or E4B, Qwen3.5 at 4B or smaller |
| 16 GB | Gemma 4 12B, gpt-oss 20B (Ollama says it runs in as little as 16 GB), 8B to 14B dense models |
| 24 to 32 GB | 24B to 31B models: Qwen3.8 27B, Gemma 4 26B or 31B, Devstral Small 2 |
| 48 to 64 GB | Larger MoE models with longer context; Qwen3-Coder-Next at 52 GB needs 64 GB |
| 96 GB and up | gpt-oss 120B (65 GB on Ollama), large MoE models at 4-bit |
GPU or Mac?
NVIDIA GPUs are the default on Windows and Linux. Ollama supports cards with compute capability 5.0 or higher. Consumer cards top out at 32 GB (RTX 5090) and many popular ones have 16 GB, so VRAM, not speed, decides what you can run.
Apple Silicon Macs share one pool of unified memory between CPU and GPU, so a Mac with 64 GB can give a model far more memory than most single consumer GPUs. Apple's current Mac Studio offers up to 128 GB with M5 Max and up to 512 GB with M5 Ultra. LM Studio requires Apple Silicon and macOS 14 or newer and recommends 16 GB or more.
AMD GPUs work through ROCm on Linux and on selected cards on Windows, and Vulkan covers more hardware in Ollama and llama.cpp.
Do you need a GPU?
No. Small models run on a CPU, and llama.cpp is heavily optimized for it. But generation slows as models grow, so a CPU-only machine is best kept to models of a few billion parameters. Check what Ollama is actually using with ollama ps: the Processor column shows 100% GPU, 100% CPU or a split. A split means part of the model spilled into system RAM and will be much slower.
Step by step: run an LLM locally with Ollama
1. Install Ollama
# macOS and Linux
curl -fsSL https://ollama.com/install.sh | sh
# Windows (PowerShell)
irm https://ollama.com/install.ps1 | iex
There are also manual installers (Ollama.dmg, OllamaSetup.exe) on ollama.com/download, and an official ollama/ollama Docker image.
2. Run your first model
ollama run gemma4
The first run downloads the default tag (gemma4:latest, the E4B model, 6.6 to 9.5 GB depending on variant) and opens a chat. Pick a size explicitly with a tag, for example ollama run gemma4:12b or ollama run qwen3.8:27b. Running plain ollama opens a menu that can also connect Ollama to agents and apps.
3. Check it is on the GPU
ollama ps
If you see a CPU/GPU split, choose a smaller model or a smaller quantization.
4. Set a sensible context length
Ollama's default context depends on VRAM: 4k tokens below 24 GiB, 32k from 24 to 48 GiB, and 256k at 48 GiB or more. Its docs say agents, web search and coding tools "should be set to at least 64000 tokens". Set it when starting the server:
OLLAMA_CONTEXT_LENGTH=64000 ollama serve
Bigger context costs memory. To save some, Ollama can quantize the KV cache with OLLAMA_KV_CACHE_TYPE=q8_0 (about half the memory of the default f16) when flash attention is on.
5. Call it from code
Native API:
curl http://localhost:11434/api/chat -d '{
"model": "gemma4",
"messages": [{"role": "user", "content": "Summarize RAG in one sentence."}],
"stream": false
}'
Or point any OpenAI SDK at Ollama:
from openai import OpenAI
client = OpenAI(base_url="http://localhost:11434/v1/", api_key="ollama")
reply = client.chat.completions.create(
model="gemma4",
messages=[{"role": "user", "content": "Write a haiku about VRAM."}],
)
print(reply.choices[0].message.content)
The API key is required by the SDK but ignored locally. There are also official ollama packages for Python and JavaScript.
6. Know where things live
Models are stored in ~/.ollama/models on macOS, /usr/share/ollama/.ollama/models on Linux and C:\Users\%username%\.ollama\models on Windows. Set OLLAMA_MODELS to move them to a bigger disk. Models unload after 5 minutes idle by default.
Keep the server bound to 127.0.0.1 unless you mean to share it. If you expose it on your network with OLLAMA_HOST, put authentication or a firewall in front of it.
Which models to start with
The Ollama library's most-pulled models are still older families (Llama 3.1, DeepSeek-R1, Qwen2.5) because of years of downloads. For new setups in October 2026, start with current models that fit your memory:
| Model | Ollama tag | Size on Ollama | Why start here |
|---|---|---|---|
| Gemma 4 E4B | gemma4 |
6.6 to 9.5 GB | Default pick for 8 to 16 GB machines; vision, tools, thinking, 128K context |
| Gemma 4 12B | gemma4:12b |
8.0 GB (Q4_K_M) | A clear step up that still fits 16 GB |
| gpt-oss 20B | gpt-oss:20b |
14 GB | OpenAI's open-weight model, Apache 2.0, tools and reasoning |
| Qwen3.8 27B | qwen3.8:27b |
18 GB | Dense, Apache-2.0, 256K context, strong at coding and agents per its model card |
| Gemma 4 31B | gemma4:31b |
19 to 20 GB | Google's largest dense Gemma 4 |
| Qwen3.6 35B-A3B | qwen3.6:35b |
23 to 24 GB | MoE (35B total, 3B active), Apache-2.0: big-model memory, small-model compute |
| Qwen3-Coder-Next | qwen3-coder-next |
52 GB | 80B total, 3B active coding model for 64 GB+ machines |
For coding specifically, see best local LLM for coding. For embeddings in a local RAG pipeline, the library's top embedding models include nomic-embed-text, mxbai-embed-large and bge-m3.
Do your own evaluation: pick three real tasks from your work, run each candidate, and compare quality and speed on your hardware. That beats any leaderboard.
Can you run Claude or ChatGPT locally?
Claude: no. Claude is a closed-weight model; Anthropic serves it through its apps, API and cloud partners and does not publish the weights. What you can do is use Anthropic's Claude Code tool with a local model. Ollama documents ollama launch claude, or setting ANTHROPIC_BASE_URL=http://localhost:11434 with a tool-capable model and at least 64k context. The interface is Claude Code; the model is whatever open model you run. The same goes for ChatGPT, although OpenAI does publish the separate open-weight gpt-oss models, which you can run.
Troubleshooting
- Very slow replies: run
ollama ps. If part of the model is on the CPU, use a smaller model or quantization, or a shorter context. - Out of memory on load: the model plus context does not fit. Drop to a 4-bit tag or reduce
OLLAMA_CONTEXT_LENGTH. - Agent forgets instructions halfway: the context is probably at the 4k default. Raise it.
- Tool calls fail: use a model the library marks with the
toolscapability. - GPU not detected on Linux after sleep: Ollama's docs suggest reloading the
nvidia_uvmmodule.
Once a model runs, the next step is usually connecting it to your files and tools. Read what is MCP to see how local models can use the same tool servers as cloud ones.
Frequently asked questions
What's the best LLM I can run locally?+
It depends on your memory. With about 16 GB, gpt-oss 20B or Gemma 4 12B are strong starting points; with 24 to 32 GB, Qwen3.8 27B, Gemma 4 26B or 31B fit at 4-bit; with 64 GB or more you can run larger mixture-of-experts models such as Qwen3-Coder-Next. Test two or three on your own tasks before settling.
Do I need a GPU to run an LLM locally?+
No, but it helps a lot. Small models run on a CPU, and Apple Silicon Macs use their unified memory as GPU memory. For anything above roughly 8B parameters at a comfortable speed, you want either a GPU with enough VRAM or a Mac with plenty of unified memory.
Why do people run LLMs locally?+
Privacy, cost and control. Prompts and files stay on your machine, there is no per-token bill, it works offline, and you choose the exact model version so nothing changes under you.
Is it possible to run Claude locally?+
No. Claude is a closed-weight model that Anthropic serves through its apps, API and cloud partners, and its weights are not published. You can, however, point the Claude Code tool at a local open model through Ollama's Anthropic-compatible API.
How much RAM do I need to run an LLM locally?+
Roughly the model's parameter count times the bytes per weight, plus room for context. A 4-bit quantized model needs a little over half a gigabyte per billion parameters, so an 8B model needs about 5 GB and a 27B model about 17 to 18 GB before context.
Is Ollama free?+
Yes. Ollama is open source under the MIT license and free to run locally. It also offers optional cloud-hosted models, which are a separate service.
Sources
- Ollama (README), Ollama
- Download Ollama, Ollama
- Ollama FAQ, Ollama
- Context length, Ollama
- Hardware support, Ollama
- OpenAI compatibility, Ollama
- Claude Code with Ollama, Ollama
- Ollama model library, Ollama
- LM Studio docs, LM Studio
- LM Studio system requirements, LM Studio
- LM Studio is free for use at work, LM Studio
- llama.cpp, ggml-org
- llama.cpp quantize: bits per weight, ggml-org
- vLLM Quickstart, vLLM
- Jan, Menlo Research
- Gemma 4 model overview, Google
- Qwen3.8-27B model card, Qwen (Hugging Face)
- gpt-oss on Ollama, Ollama
- Qwen3.6-35B-A3B model card, Qwen (Hugging Face)
- Gemma 4 tags on Ollama, Ollama
- Mac Studio technical specifications, Apple
- Compare GeForce graphics cards, NVIDIA
The weekly AI briefing
Get the guides like this one, once a week
Keep reading
Local and Private AIOllama vs LM Studio: Which Local LLM Tool Should You Use?Ollama is the open-source, CLI-first runner for developers; LM Studio is the polished desktop app. Compare engines, APIs, platforms and licensing, and pick one. · 7 min read
Local and Private AIBest Local LLM for Coding in 2026 (Picked by Your Hardware)The best local coding models for 16, 24-32 and 64 GB+ machines, with sizes, licenses and vendor benchmarks, plus how to plug them into Claude Code or your IDE. · 7 min read
AI ModelsMuse Spark Open: Meta's Open-Weight Model, Licence and How to Run ItMuse Spark Open is Meta's 816B open-weight MoE model. What it is, how it relates to Muse Wonder, the licence terms, hardware needs and how to run or access it. · 5 min read