How Do You Run an LLM Locally?
You run an LLM locally by installing a runtime (Ollama, LM Studio, or llama.cpp), downloading a quantized open-weight model that fits your memory, and then running that model directly on your CPU or GPU — with no cloud, no API key, and no internet after the initial download. The entire workflow is free and open source, and a capable laptop is enough to start.
The reason interest has exploded is simple: privacy plus capability. Self-hosting AI is now a mainstream choice rather than a niche one — in Stack Overflow's 2024 developer survey, 76% of developers reported using or planning to use AI tools, and a fast-growing share run models locally to avoid sending code and data to third-party APIs (Stack Overflow Developer Survey, 2024). Open-weight models have closed much of the quality gap with proprietary cloud models, so a 7B–14B model on your own machine is genuinely useful for chat, coding help, summarization, and document Q&A.
This is the individual / small-team how-to for running a model on one machine. If you need a production deployment serving many users across an organization — GPU servers, vLLM, autoscaling, and security review — follow How to Deploy an LLM On-Premise instead. For the broader concept and trade-offs, see the Local LLM guide and Private LLM for Enterprises.
Offline AI for Education Therapy Services
- 75% reduction in documentation time
- 2,800+ Quick Start Workflows
- 100% FERPA and HIPAA compliant
Instant download. We'll also email you a copy. No spam.
What Do You Need to Run an LLM Locally? (Hardware Checklist)
You need three things: a local LLM tool, a quantized model file, and enough RAM or VRAM to hold it. Memory is the single most important constraint. A practical rule of thumb is that a 4-bit quantized model uses roughly 0.6–0.7 GB of memory per billion parameters, so a 7B model fits in about 5–6 GB and a 13B in about 9–10 GB, with a few gigabytes of headroom for the operating system and the context window.
- RAM / VRAM: 16 GB total handles 7B–13B models well. 8 GB is enough for small (3B–7B) models. 24 GB+ of GPU VRAM or 32 GB+ of system RAM opens up 30B–70B models.
- GPU (optional but faster): an NVIDIA card with 8–24 GB VRAM gives the best speed; Apple Silicon (M-series) Macs are excellent because the GPU shares unified memory.
- CPU: any modern multi-core CPU works. Newer Intel Core Ultra and AMD chips include an NPU that accelerates on-device AI without a discrete GPU.
- Disk: 5–50 GB free per model. Quantized 7B files are ~4–6 GB each; larger models grow accordingly.
- OS: Windows, macOS, and Linux are all fully supported by the three tools below.
That checklist sizes a single desktop or laptop. If you are stepping up to serving several people at once, the hardware sizing guide works through which GPU to buy for AI workloads and how much memory each tier of model needs.
Quantization is what makes this feasible on consumer hardware. It compresses model weights from 16-bit to 4-bit (or 5/6/8-bit), cutting memory use by roughly 4x with only a small quality loss. Most local models you download are already quantized in the GGUF format that Ollama, LM Studio, and llama.cpp all read. For a fuller definition of a local LLM and help choosing which model family to run, see that guide. For more information on which models are supported and how to bring your own, visit the Supported LLM Models and Bring Your Own page.
1 Step 1: Pick a Tool — Ollama vs LM Studio vs llama.cpp
Choose LM Studio if you want a one-click graphical app, Ollama if you want a clean command line with a built-in API, or llama.cpp if you want maximum control and the leanest possible footprint. All three are free, open source, run the same GGUF models, and work on Windows, macOS, and Linux. In fact, Ollama and LM Studio are both built on top of the llama.cpp engine — so picking is really about the interface you prefer.
| Tool | Interface | Best for | API for scripts | Learning curve |
|---|---|---|---|---|
| LM Studio | Polished desktop GUI | Beginners, non-coders, model browsing | Yes (OpenAI-compatible) | Lowest |
| Ollama | CLI + local server | Developers, automation, app integration | Yes (REST + OpenAI-compatible) | Low |
| llama.cpp | Command line / library | Power users, custom builds, embedded | Yes (server binary) | Higher |
All three are open-source projects: Ollama, LM Studio, llama.cpp.
Our recommendation for most readers: start with LM Studio if you have never run a model before — it has a built-in model catalog, automatic hardware detection, and a chat window. Move to Ollama the moment you want to script the model, plug it into an editor, or expose a local API. Reach for raw llama.cpp only when you need custom compilation flags or are embedding inference into another application. If you are weighing Ollama alternatives for a team rather than a single machine, the enterprise roundup compares the supported options side by side.
2 Step 2: Choose a Model That Fits Your Hardware
Pick the largest open-weight model your memory can hold at 4-bit quantization — for most laptops that means a 7B–14B model such as Llama 3.x, Qwen 2.5, Gemma 2, or Mistral. Bigger is generally smarter, but only if it fits in memory without spilling to disk, which collapses speed. Match the model to your RAM first, then to the task.
| Your memory | Model size to run | Good open models | Typical use |
|---|---|---|---|
| 8 GB | 3B–7B (4-bit) | Llama 3.2 3B, Phi-3 mini, Gemma 2 2B | Quick chat, drafting, simple Q&A |
| 16 GB | 7B–14B (4-bit) | Llama 3.1 8B, Qwen 2.5 14B, Mistral 7B | General assistant, coding help, RAG |
| 32 GB | up to ~32B (4-bit) | Qwen 2.5 32B, Gemma 2 27B | Stronger reasoning, longer context |
| 64 GB+ / 24 GB GPU | 70B (4-bit) | Llama 3.x 70B, Qwen 2.5 72B | Near-frontier quality, fully local |
Open models have become remarkably capable. Meta has reported that its Llama family surpassed 1 billion downloads, underscoring how mature the open-weight ecosystem now is (Meta, 2025). For privacy-sensitive work, the practical upside is that a model living on your disk has no usage caps, no per-token billing, and no exposure of your prompts — the same open models (Llama, Gemma, Qwen, Mistral) that power local DIY setups also run inside supported products like AirgapAI.
Which GGUF Quantization Should You Download?
Download the Q4_K_M build of the largest model your memory can hold. It averages
about 4.8 bits per weight, cuts a 16-bit model to roughly a quarter of its size, and costs a quality
drop most people never notice. Step up to Q5_K_M or Q6_K only when
you have memory to spare, and drop below 4-bit only to fit a class of model that otherwise will not run.
| Your memory | Model class that fits | Quantization to download | Typical file size | What you trade |
|---|---|---|---|---|
| 8 GB RAM / 6 GB VRAM | 3B – 8B | Q4_K_M |
~2.0 GB (3B) · ~4.9 GB (8B) | Runs, but leave the 8B for a machine with nothing else open. |
| 16 GB RAM / 8–12 GB VRAM | 8B – 14B | Q4_K_M (Q5_K_M if it fits) |
~4.9 GB (8B) · ~9.0 GB (14B) | The comfortable default. Q5_K_M buys a little quality for ~15% more memory. |
| 32 GB RAM / 16–24 GB VRAM | 24B – 32B | Q4_K_M |
~15 GB (24B) · ~20 GB (32B) | Noticeably better reasoning; decode speed drops on CPU-only machines. |
| 64 GB+ RAM / 48 GB VRAM | 70B – 72B | Q4_K_M, or IQ3_M to squeeze it in |
~42 GB (Q4_K_M) · ~32 GB (IQ3_M) | Near-frontier quality locally. Below Q4 the quality loss becomes visible. |
File sizes are the published GGUF builds for Llama 3.x, Qwen 2.5 and Mistral families; every runtime on this page reads the same files. Sizing rule: file size in GB is roughly parameters in billions × bits per weight ÷ 8.
What the GGUF suffixes mean
- Q8_0 — about 8.5 bits per weight — effectively indistinguishable from the full-precision model, and roughly twice the size of a 4-bit build. Use it when memory is abundant and the answer has to be exact.
- Q6_K — very close to Q8_0 at about three quarters of the size. A good stop when a 4-bit build feels careless but Q8_0 will not fit.
- Q5_K_M — a modest step up from 4-bit for roughly 15% more memory. Worth taking when the model is small relative to your RAM.
- Q4_K_M — about 4.8 bits per weight and the most-downloaded build of nearly every open-weight model. This is the default answer for almost everyone.
- IQ3_M / Q3_K_M — the fit-a-bigger-model option. Reasoning and instruction-following degrade measurably; a Q4_K_M build one size class down is usually the better trade.
- Q2_K — experiments only. Output quality falls off a cliff, and a smaller model at Q4_K_M will beat it on the same memory.
The model file is not the whole memory bill. The KV cache that holds your conversation grows with context length: budget roughly 1–2 GB on top of an 8B model at a 4,000–8,000 token context, and more if you raise it. If a model loads and then dies mid-answer, the context window is usually the culprit — not the quantization. Comparing model families before you pick a size? The LLM selection guide ranks the current open and closed options side by side.
3 Step 3: Install the Tool and Download the Model
Installation is a single download for each tool, and pulling a model is one command or one click. Everything below runs offline after the model file finishes downloading. Here is the fastest path for each tool.
LM Studio (GUI)
Download the installer from lmstudio.ai, open the app, and use the built-in search to find a model (for example "Llama 3.1 8B Instruct"). LM Studio recommends a quantization that fits your hardware, downloads it, and loads it — no terminal required.
Ollama (CLI)
Install Ollama, then run a single pull-and-chat command such as ollama run llama3.1.
Ollama downloads the model the first time and drops you straight into a chat prompt; the same
command later starts an instant local session.
llama.cpp (power users)
Clone and build llama.cpp, download a GGUF file from a model hub, and run the llama-cli
or llama-server binary pointed at the file. This gives you per-flag control over
threads, context length, and GPU offload layers.
The only step that needs the internet is the initial model download. After that you can disconnect entirely — pull your model files while online, then run them on a plane, in a SCIF, or on an air-gapped machine with zero connectivity.
Copy-Paste Commands for Ollama, LM Studio and llama.cpp
Every runtime on this page follows the same three moves: install the runtime, pull a quantized model, then start either a chat session or a local OpenAI-compatible API. The blocks below are the commands for each one, including the endpoint it exposes, so an existing script can point at your own machine by changing a single base URL.
One command installs it, one command pulls the weights and drops you into a chat.
# 1. install (macOS and Linux; Windows has an installer at ollama.com)
curl -fsSL https://ollama.com/install.sh | sh
# 2. pull a 4-bit model and start chatting (first run downloads it)
ollama run llama3.1:8b
# 3. manage what is on disk
ollama list
ollama rm llama3.1:8b
# 4. run the local API in the background
ollama serve
# 5. call the model from a script
curl http://localhost:11434/api/generate -d '{"model":"llama3.1:8b","prompt":"Summarize this in three bullets"}'
Install the desktop app, download a model from the Discover tab, then drive it from the CLI when you want to script it.
# 1. install the desktop app from lmstudio.ai, then add its command line
npx lmstudio install-cli
# 2. list the models you downloaded in the app
lms ls
# 3. load one into memory
lms load llama-3.1-8b-instruct
# 4. start the OpenAI-compatible server
lms server start
# 5. check what is running
lms ps
Build it once, then point the binaries at any GGUF file with full control over threads, context and GPU offload.
# 1. build (CMake detects Metal on macOS and CUDA on Linux/Windows)
git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp
cmake -B build
cmake --build build --config Release -j
# 2. chat with a GGUF file (-ngl 99 offloads every layer to the GPU,
# -c sets the context window, -cnv opens conversation mode)
./build/bin/llama-cli -m models/Llama-3.1-8B-Instruct-Q4_K_M.gguf -c 4096 -ngl 99 -cnv
# 3. or serve the same model over an OpenAI-compatible API
./build/bin/llama-server -m models/Llama-3.1-8B-Instruct-Q4_K_M.gguf -c 4096 -ngl 99
Once the weights are on disk, every command above runs with the network off. That is the whole point of the exercise: pull the model while you are connected, then work on a plane, in a lab, or on a machine that has never had a network cable in it. For an organization-wide deployment of the same idea — GPU servers, vLLM, many concurrent users — follow how to deploy an LLM on-premise.
4 Step 4: Run and Chat (CLI or GUI)
Once the model is loaded, you chat with it exactly like a cloud assistant — in LM Studio's chat window, in Ollama's terminal prompt, or through a local API on your own machine. The first response may take a moment as the model loads into memory; after that, replies stream token by token.
- GUI chat: in LM Studio, type into the chat box and adjust temperature, context length, and system prompt from the sidebar — no code needed. For what temperature and the other sampling settings actually change, see the prompt engineering guide.
-
CLI chat: with Ollama,
ollama run llama3.1opens an interactive prompt; type your message and press Enter to get a streamed reply. - Local API: both Ollama and LM Studio expose an OpenAI-compatible endpoint (typically on localhost), so existing apps and scripts can point at your local model by changing one base URL — no key, no cloud.
- Editor integration: developer tools can connect to that local endpoint for in-editor coding help. For a packaged, supported local coding assistant, see AirgapAI Code.
Expect roughly 5–15 tokens per second for a 7B model on a recent laptop CPU, and 40–100+ tokens per second on a dedicated GPU. If responses feel slow, that is almost always a sign the model is too large for your memory — drop to a smaller model or a more aggressive quantization.
Watch: A Model Answering With the Network Unplugged
This 68-second clip shows a model answering on a stock laptop with the network cable pulled out — no API key, no round trip, no connection at all. The assistant on screen is AirgapAI, the packaged option covered further down, but the loop is identical to what Ollama, LM Studio or llama.cpp give you once the weights are on disk: prompt in, tokens out, nothing leaves the device.
Recorded on a stock laptop with the network cable unplugged. See the full AirgapAI demo.
5 Step 5: Add Your Own Documents (RAG Basics)
To make a local LLM answer from your own files, you use retrieval-augmented generation (RAG): your documents are split into chunks, converted to embeddings, stored in a local vector index, and the most relevant pieces are fed to the model with each question. This keeps everything offline while letting the model cite your PDFs, notes, and internal docs.
- Easiest path: LM Studio and front-ends like Open WebUI or AnythingLLM let you drag in documents and chat over them with a local model — no coding.
- Developer path: pair Ollama with a local vector database and one of the open embedding models to build a custom RAG pipeline you fully control.
- The accuracy lever: RAG quality lives or dies on how cleanly your source text is prepared. Messy, duplicated, or poorly chunked documents cause hallucinations.
This is where data optimization matters most. Iternal's Blockify restructures raw documents into compact, deduplicated IdeaBlocks before they reach the vector database — an approach that delivers roughly 78X more accurate retrieval using about 3X fewer tokens, and works with any vector store. For local RAG that needs to be trustworthy, cleaning the data first is the highest-leverage step you can take.
Chat With Your Own Documents Without Sending Them Anywhere
A document-grounded setup on your own machine is five parts: a folder of documents, a cleaning pass, a local embedding model, a local vector index, and the chat model you already installed. Everything stays on disk. The part that decides whether the answers are trustworthy is the cleaning pass, not the model you picked.
- Collect the documents in one folder Start narrow: one project, one product line, one policy set. A tight corpus of 50 clean documents outperforms a dump of 5,000 mixed ones, because retrieval has fewer near-identical passages to confuse.
- Clean and structure the text before it is chunked Strip navigation furniture, run OCR over scanned PDFs, and collapse the six near-duplicate versions of the same policy into one current version. This is the step most local setups skip, and it is the step that decides whether the answers are usable.
- Pick an embedding model that runs locally Compact open embedding models such as nomic-embed-text or the BGE small family run on the same machine as the chat model and add very little memory. Whatever you choose, embed and query with the same model.
- Store the vectors in a local index Chroma, LanceDB and Qdrant all run on a laptop, and front-ends like Open WebUI or AnythingLLM ship with a built-in store so there is nothing to configure. The index lives in a folder you control.
- Query with citations turned on Ask the front-end to show which passages it retrieved. If an answer looks wrong, the retrieved chunks tell you immediately whether the problem is the model or the source text — and it is usually the source text.
What actually breaks local document chat
- Scanned PDFs with no OCR layer — they embed as empty pages, so the model answers from nothing.
- Near-duplicate documents — five revisions of one policy split the retrieval score five ways and the model quotes the stale one.
- Chunks that cut through tables — half a table has no meaning, and the model will confidently invent the other half.
- Boilerplate headers and footers — repeated on every page, they dominate similarity search and crowd out the real content.
Every item on that list is a data problem, which is why the highest-leverage tool in a local setup is the one that runs before the vector database. Iternal's Blockify restructures raw documents into compact, deduplicated IdeaBlocks — roughly 78X more accurate retrieval using about 3X fewer tokens — and writes into any vector store, including the local ones above. Same laptop, same offline guarantee, far fewer confident wrong answers. See how Blockify prepares documents.
Troubleshooting & Performance Tips
Most local-LLM problems trace back to one cause: the model is too big for your available memory. The fixes below resolve the overwhelming majority of slow, crashing, or out-of-memory sessions.
- Replies are very slow: the model is spilling out of RAM/VRAM. Use a smaller model or a lower-bit quantization (try 4-bit, or drop from 13B to 7B).
- Out-of-memory / crash on load: reduce the context length, close other apps, or pick a smaller quant. On GPUs, lower the number of offloaded layers.
- GPU not being used: confirm GPU offload is enabled in LM Studio's settings or set the GPU-layers flag in Ollama/llama.cpp; verify your drivers (CUDA/Metal) are current.
- Weak answers: raise the quantization (8-bit over 4-bit if memory allows), choose a larger or more recent model, or improve your system prompt and RAG document quality.
- Short, cut-off responses: increase the maximum output tokens and the context window in your tool's settings.