Running an LLM on your own computer means no API bill, no rate limits and no prompts leaving the building. The hard part is choosing. New open models arrive every few weeks, most "best local LLM" lists are a pile of names without memory figures, and the wrong pick means waiting for an 18 GB download that will not load or crawls at two words a second.
This guide fixes that. You get the current best local LLM models for each memory tier, with download sizes taken from the official Ollama library, the best local LLM for coding, a plain comparison of Ollama, LM Studio and llama.cpp, the commands to get running, and a short Python script we tested that estimates how much memory a model needs. Every model fact comes from the developer's own model card or announcement, and every download size from the official Ollama library.
The best local LLM models by memory size
There is no single best local LLM. There is a best model for your memory. The table below gives our picks for each tier, chosen on three criteria: the developer's published results, an open license that allows commercial use, and a download size that leaves room for a useful context window on that hardware.
| Your memory | Best pick | Download | Also good | Why |
|---|---|---|---|---|
| 8 GB RAM, no GPU | Phi-4-mini (3.8B) | 2.5 GB | Gemma 4 E2B (4.6 GB) | Small enough to leave room for your apps; MIT license |
| 16 GB RAM or 12 to 16 GB VRAM | Gemma 4 12B | 7.7 GB | gpt-oss-20b (14 GB) | Text, image and audio input, 256K context, Apache 2.0 |
| 24 GB VRAM or 32 GB Mac | Qwen3.8-27B | 18 GB | Gemma 4 26B A4B (16 to 19 GB) | Strongest all-rounder that fits one consumer GPU |
| 24 GB, coding agents | Devstral Small 2 (24B) | 15 GB | Qwen3-Coder 30B (19 GB) | Built for multi-file coding agents |
| 64 GB Mac or more | Qwen3-Coder-Next | 52 GB | Qwen3.8-27B at higher precision | Large coding model with few active parameters |
| 80 GB GPU or 96 GB+ Mac | gpt-oss-120b | 65 GB | Gemma 4 31B unquantized | OpenAI says it runs within 80 GB |
Qwen3.8-27B: the best all-rounder
The Qwen team's Qwen3.8-27B (opens in a new tab), released in August 2026, is a dense 27-billion-parameter model under the Apache 2.0 license. It reads images and video as well as text and has a native context window of 262,144 tokens, extendable to about a million. Qwen reports 61.7 on SWE-bench Pro and 89.2 on GPQA Diamond (both vendor-reported). The Ollama build (opens in a new tab) is an 18 GB download, which fits a 24 GB graphics card with room for context.
Gemma 4: the best family for small and mid-size machines
Google's Gemma 4 family, launched on April 2, 2026, covers almost every tier under one Apache 2.0 license. The Gemma 4 model card (opens in a new tab) lists E2B and E4B models for phones and laptops, a 12B model, a 26B mixture-of-experts model with 3.8B active parameters and a 31B dense model. The E2B, E4B and 12B versions accept audio as well as text and images. On Ollama (opens in a new tab), the 12B is a 7.7 GB download with a 256K context window, which makes it the best default for a 16 GB laptop.
gpt-oss-20b and gpt-oss-120b: OpenAI's open-weight models
OpenAI released gpt-oss (opens in a new tab) in August 2025 under Apache 2.0. They are text-only mixture-of-experts models: gpt-oss-20b has 21B total and 3.6B active parameters, and gpt-oss-120b has 117B total and 5.1B active. OpenAI says the 120b runs within 80 GB of memory and the 20b "only requires 16GB". Ollama lists them at 14 GB and 65 GB (opens in a new tab). They are older than the Qwen and Gemma picks, but still a sensible fit for a 16 GB machine or a single 80 GB GPU.
Phi-4-mini: the best tiny model
Microsoft's Phi-4-mini (opens in a new tab) is a 3.8B-parameter text model from February 2025 with a 128K context window and an MIT license. Microsoft reports 67.3 on MMLU and 88.6 on the GSM8K math test. At a 2.5 GB download (opens in a new tab) it runs on almost any recent laptop, including ones with no GPU. Expect it to handle summaries, rewrites and simple questions, not long reasoning.
Best local LLM for coding
Coding is where hardware limits bite hardest, because coding tools send long context: whole files, diffs and tool output. Here are the three models worth trying first, all available in Ollama.
| Model | Size | Download | Context | Best for |
|---|---|---|---|---|
| Qwen3.8-27B | 27B dense | 18 GB | 256K | Best overall: chat, review, agents, reading screenshots |
| Devstral Small 2 | 24B dense | 15 GB | 256K (Mistral); Ollama lists 384K | Agentic coding across a codebase |
| Qwen3-Coder 30B | 30B total, 3.3B active (MoE) | 19 GB | 256K | Fast responses on a 24 GB card |
Devstral Small 2 (opens in a new tab), released by Mistral in December 2025, is the specialist. It is a 24B Apache 2.0 model that accepts image input, and Mistral reports 68.0% on SWE-bench Verified, a benchmark built from real GitHub issues. Mistral also says it "runs on consumer-grade GPUs as well as CPU-only configurations". Ollama's devstral-small-2 (opens in a new tab) page notes that it needs Ollama 0.13.3 or later.
Qwen3-Coder 30B (opens in a new tab) is a mixture-of-experts model that, per its Ollama page, activates only 3.3B of its 30B parameters for each token. That makes it noticeably quicker than a dense model of the same size, which matters for autocomplete-style use. If you have a 64 GB Mac, Qwen3-Coder-Next (opens in a new tab) (a 52 GB download that Ollama lists at 80B total and 3B active parameters) is the step up.
To plug a local model into an editor or a coding agent, point the tool at your local server's OpenAI-compatible address, shown in the setup section below. For a tour of the editors and agents themselves, see our guide to vibe coding tools.
Local LLM hardware: how much memory you need
Two things take up memory when you run a model: the weights and the context. The weights are the model itself. Their size is the number of parameters times the bits used to store each one. Most local downloads are quantized to about 4 or 5 bits per weight instead of 16, which cuts memory by roughly three quarters at some cost in quality. The llama.cpp project (opens in a new tab) supports everything from 1.5-bit to 8-bit quantization.
The context is the conversation so far, stored as a key-value (KV) cache for every layer of the model. It grows with every token, so a 128K-token window can need as much memory as the model. This short script estimates both. We ran it with Python 3.13 and checked the weight estimates against the memory table Google publishes for Gemma 4.
# Rough memory estimate for running an LLM locally.
# weights: parameters x bits per weight / 8
# kv cache: 2 (keys and values) x layers x kv_heads x head_dim x tokens x bytes
def weights_gb(params_billion, bits_per_weight):
return params_billion * bits_per_weight / 8
def kv_cache_gb(layers, kv_heads, head_dim, context_tokens, bytes_per_value=2):
return 2 * layers * kv_heads * head_dim * context_tokens * bytes_per_value / 1e9
# Check against Google's published Gemma 4 Q4_0 memory figures.
# Q4_0 stores 4-bit weights plus one 16-bit scale per 32 weights = 4.5 bits.
gemma4 = {"E2B": (5.1, 2.9), "E4B": (8.0, 4.5), "12B": (11.95, 6.7),
"26B A4B": (25.2, 14.4), "31B": (30.7, 17.5)}
print("model estimate Google Q4_0")
for name, (params, google) in gemma4.items():
print(f"{name:<9} {weights_gb(params, 4.5):5.1f} GB {google:5.1f} GB")
# Context costs memory too. A made-up model with 48 layers,
# 8 KV heads and a head size of 128, with an f16 cache:
print()
for ctx in (4_096, 32_768, 131_072):
print(f"{ctx:>7} tokens of context: {kv_cache_gb(48, 8, 128, ctx):5.1f} GB of KV cache")Running python3 llm_memory.py printed:
model estimate Google Q4_0
E2B 2.9 GB 2.9 GB
E4B 4.5 GB 4.5 GB
12B 6.7 GB 6.7 GB
26B A4B 14.2 GB 14.4 GB
31B 17.3 GB 17.5 GB
4096 tokens of context: 0.8 GB of KV cache
32768 tokens of context: 6.4 GB of KV cache
131072 tokens of context: 25.8 GB of KV cacheThe weight estimates land within 0.2 GB of Google's figures (opens in a new tab) for every Gemma 4 size, so the simple formula is good enough for planning. The second half is the warning. For the illustrative 48-layer model, going from 4K to 128K tokens of context adds about 25 GB, more than the weights of most models on this list. Real models often use less, through tricks like sliding-window attention, and Ollama can store the cache at 8-bit or 4-bit with the OLLAMA_KV_CACHE_TYPE setting described in its FAQ (opens in a new tab).
all 26 billion parameters must be loaded into memory
That quote explains the most common surprise with mixture-of-experts (MoE) models. The active parameter count sets the speed, but the total count sets the memory. A 30B MoE model runs about as fast as a 3B model and needs about as much memory as a 30B one.
Best local LLM hardware: GPU, Mac or CPU
| Hardware | Strength | Limit | Best models |
|---|---|---|---|
| NVIDIA GPU (12 to 32 GB VRAM) | Fast, and supported by every tool here | VRAM caps model size | Gemma 4 12B up to Qwen3.8-27B |
| Apple Silicon Mac (32 to 128 GB) | Large unified memory runs big models on one machine | Usually slower than a high-end NVIDIA card | Qwen3.8-27B up to gpt-oss-120b |
| AMD GPU | Supported by Ollama through ROCm v7 and Vulkan | Check your card is on the supported list | Same as NVIDIA at equal VRAM |
| CPU only (16 to 32 GB RAM) | Works on any computer | Slow for anything over about 8B | Phi-4-mini, Gemma 4 E2B or E4B |
Support details come from the tools' own docs. Ollama's hardware page (opens in a new tab) lists NVIDIA cards with compute capability 5.0 or newer, AMD cards with ROCm v7 drivers, Vulkan on Windows and Linux, and Metal on Apple devices. LM Studio's requirements (opens in a new tab) ask for an Apple Silicon Mac on macOS 14 or newer, or an x64 PC with AVX2, and recommend 16 GB of RAM plus at least 4 GB of dedicated VRAM on Windows. LM Studio does not support Intel Macs.
On a Mac, the GPU shares memory with macOS and every open app, so a 32 GB Mac comfortably runs an 18 GB model but not a 30 GB one. If you are buying hardware for local AI, memory size matters more than raw speed: it decides which models you can load at all.
Ollama vs LM Studio vs llama.cpp: how to run an LLM locally
Three free tools cover almost every local setup. They run the same open models; the main difference is the interface. LM Studio, for example, says it runs on MLX and llama.cpp under the hood.
| Ollama | LM Studio | llama.cpp | |
|---|---|---|---|
| Interface | Command line, local API, desktop app | Desktop app, plus the lms command line | Command line and server |
| Best for | Developers, scripts and coding tools | Browsing and chatting with models | Maximum control and unusual hardware |
| Platforms | macOS, Windows, Linux | Apple Silicon Mac, Windows x64 and ARM, Linux | Almost anything, including phones |
| Local API | OpenAI-compatible at localhost:11434/v1 | OpenAI-compatible, port 1234 in its examples | OpenAI-compatible server (llama serve) |
| Cost and license | Free for local models; paid cloud models optional | Free plan runs local models | Free, MIT license |
Run an LLM locally with Ollama
Ollama is the quickest route from nothing to a working local LLM. Download it from ollama.com (or run the install script on Linux), then run a model. The first run downloads it.
# Linux install (macOS and Windows have installers on ollama.com)
curl -fsSL https://ollama.com/install.sh | sh
# Pick the model that fits your memory
ollama run qwen3.8:27b # 24 GB GPU or 32 GB Mac
ollama run gemma4:12b # 16 GB machine
ollama run phi4-mini # 8 GB laptop
# Give coding tools a bigger context window
OLLAMA_CONTEXT_LENGTH=64000 ollama serveOllama now offers cloud models too. In its CLI, any model name ending in :cloud runs on Ollama's servers rather than your machine. If privacy is why you are going local, stick to tags without that suffix, or set OLLAMA_NO_CLOUD=1 to switch cloud features off, as its FAQ (opens in a new tab) explains.
Any app that speaks the OpenAI API can then use your local model. This is the example from Ollama's OpenAI compatibility docs (opens in a new tab); the API key is required by the client library but ignored by Ollama.
from openai import OpenAI
client = OpenAI(
base_url='http://localhost:11434/v1/',
api_key='ollama', # required but ignored
)
chat_completion = client.chat.completions.create(
messages=[
{
'role': 'user',
'content': 'Say this is a test',
}
],
model='gpt-oss:20b',
)
print(chat_completion.choices[0].message.content)LM Studio: the easiest desktop app
LM Studio is a desktop app with a model browser, a chat window and a local server. Its free plan (opens in a new tab) runs local models; paid tiers add cloud inference. Start the server with lms server start, and its OpenAI-compatible examples (opens in a new tab) use http://localhost:1234/v1 as the base URL, so the Python code above works with just the URL and model name changed.
llama.cpp: maximum control
llama.cpp (opens in a new tab) is the open-source C/C++ engine that LM Studio and many other tools build on. It supports a very wide range of hardware, from CUDA, HIP and Vulkan GPUs to Apple Metal and Snapdragon chips, and exposes every setting. Install it with brew install llama.cpp on Mac or Linux or winget install llama.cpp on Windows, then use the commands from its README:
# Download and run a model directly from Hugging Face
llama cli -hf ggml-org/Qwen3.5-0.8B-GGUF
# Launch OpenAI-compatible API server
llama serve -hf ggml-org/Qwen3.5-0.8B-GGUFUse llama.cpp when you need a setting the friendlier tools hide, such as exact quantization files, multi-GPU splits or running on a phone. Otherwise, Ollama or LM Studio will get you the same models with less work.
Real test results: we ran six local models on one 16 GB GPU
Memory tables only tell you what should fit. To see what happens in practice, we downloaded six of the models discussed above, from a 2.5 GB download to a 17.7 GB one, and timed each on the same 16 GB GPU. Each model wrote the same 512-token answer three times; the speeds below average the second and third runs, so the one-off loading time is reported separately. We ran this test on 28 November 2026 in Google Colab on a free NVIDIA Tesla T4 GPU (16 GB of video memory), using Ollama 0.40.19 to serve the models. The screenshots are cropped from that notebook; the code is exactly what ran.


What the numbers show:
- Fitting in video memory matters more than anything else. Qwen3.8-27B is a 17.7 GB download, a little too big for a 16 GB card, so Ollama put 24% of it on the CPU. Generation fell to 1.4 tokens per second and reading the prompt fell to 16 tokens per second, against 27.6 and 283 for Gemma 4 12B, which fit entirely. That is why the table above pairs Qwen3.8-27B with 24 GB of VRAM.
- Mixture-of-experts models are faster than their size suggests. gpt-oss-20b is a bigger download than Gemma 4 12B (13.8 GB against 8.0 GB) but generated about 50% faster (41.3 against 27.6 tokens per second), because only a fraction of its weights are used for each token.
- Video memory use tracked the download size, loosely. With a 4,096-token context, the models that fit used between about 60% of their download size (the Gemma 4 E2B and E4B models) and about 120% (Phi-4-mini): 8.5 GB for Gemma 4 12B and 12.1 GB for gpt-oss-20b. Plan for longer contexts to need more.
- First loads are slow. Loading from disk took 36 to 123 seconds the first time on Colab. On a desktop with a fast NVMe drive it is usually quicker, and later loads come from cache.

# local LLM speed and memory test (best-local-llm post)
import subprocess, time, requests, pandas as pd
API = "http://localhost:11434/api"
MODELS = ["phi4-mini", "gemma4:e2b", "gemma4:e4b", "gemma4:12b", "gpt-oss:20b", "qwen3.8:27b"]
PROMPT = ("Explain in about 300 words how a hash table works, "
"including collisions and resizing.")
def vram_used_mb():
out = subprocess.run(["nvidia-smi", "--query-gpu=memory.used", "--format=csv,noheader,nounits"],
capture_output=True, text=True).stdout
return int(out.strip().splitlines()[0])
rows = []
for m in MODELS:
t0 = time.time()
pull = subprocess.run(["ollama", "pull", m], capture_output=True, text=True)
if pull.returncode != 0:
print(f"{m}: pull failed -> {pull.stderr.strip()[-200:]}"); continue
size_gb = [t["size"] for t in requests.get(f"{API}/tags").json()["models"] if t["name"].startswith(m)][0] / 1e9
runs = []
for i in range(3): # run 1 includes load time
r = requests.post(f"{API}/generate", json={
"model": m, "prompt": PROMPT, "stream": False, "keep_alive": "5m",
"options": {"temperature": 0, "num_predict": 512, "num_ctx": 4096}}).json()
runs.append(r)
if i == 0: vram = vram_used_mb()
ps = requests.get(f"{API}/ps").json()["models"][0]
on_gpu = ps["size_vram"] / ps["size"]
best = runs[1:]
gen_tps = sum(r["eval_count"] / (r["eval_duration"] / 1e9) for r in best) / len(best)
pp_tps = sum(r["prompt_eval_count"] / (r["prompt_eval_duration"] / 1e9) for r in best) / len(best)
rows.append({"model": m, "download_GB": round(size_gb, 1),
"load_s": round(runs[0]["load_duration"] / 1e9, 1),
"VRAM_used_GB": round(vram / 1024, 1), "on_GPU": f"{on_gpu:.0%}",
"prompt_tok_s": round(pp_tps), "gen_tok_s": round(gen_tps, 1)})
print(rows[-1])
requests.post(f"{API}/generate", json={"model": m, "keep_alive": 0}) # unload
time.sleep(3)
speed = pd.DataFrame(rows)
speed.to_csv("/content/speed.csv", index=False)
print(speed.to_string(index=False))How to choose your local LLM in five steps
- Check your memory. Note your GPU's VRAM (or your Mac's total memory) and system RAM. That number picks your row in the first table.
- Decide the job. General chat and writing, coding, or reading images and audio. Coding needs more context, so leave more headroom.
- Install one tool. Ollama if you want an API for scripts and coding tools, LM Studio if you want an app.
- Start one size smaller than you think. Run your own real tasks for a day. If answers are good and speed is fine, try the next size up.
- Set the context length. Raise it for coding or long documents, and watch memory use. If the model starts spilling into system RAM, drop the context or the model size.
Remember that a local model is a smaller version of what you get in the cloud. Our guide to small language models explains where small models match big ones and where they fall short. If you want a local model to answer from your own documents, pair it with retrieval, as described in our RAG explainer. And if any of the vocabulary here is new, start with what LLM stands for.
Local LLM updates: how to keep this current
Local models date faster than almost anything else in AI. Qwen's own model cards show Qwen3.5 arriving in February 2026 and Qwen3.8 in August, with Qwen3.6 in between. To stay current without chasing every launch, re-check two places every month or two: the Ollama library page for the model family you use, which shows new tags and sizes, and the developer's model card, which shows the license and benchmark results. Then rerun your own test tasks before switching. We will update this guide as the picks change.
The bottom line
The best local LLM is the best model that fits your memory. Today that means Qwen3.8-27B on a 24 GB GPU or 32 GB Mac, Gemma 4 12B or gpt-oss-20b on 16 GB, Phi-4-mini on 8 GB, and Devstral Small 2 or Qwen3-Coder for local coding. Install Ollama or LM Studio, size the model with the script above, and raise the context window before you judge the results. For more practical guides on models and tools, browse our AI guides.



