Contact, if you are interested in this website / domain name / sponsorship / advertisement / partnership

How to run LLMs locally

A practical guide to running open-weight language models on your own computer, from memory math and quantization formats to tools and model picks. It includes an Ollama quick start, hardware tiers as of October 2026, performance tips and fixes for common errors.

Running & deployingIntermediate11 min readUpdated October 10, 2026

Key takeaways

  • Memory decides what you can run: plan on about 2 GB per billion parameters at 16-bit, 1 GB at 8-bit and 0.6 GB at 4-bit, plus room for the KV cache.
  • The KV cache grows linearly with context length and can outweigh a small model's weights at 128K tokens.
  • 4-bit quantization (GGUF Q4_K_M or 4-bit MLX) is the practical default; move up to 5-8 bits when you have spare memory and need precision.
  • Ollama and LM Studio are the easiest starting points, llama.cpp gives the most control, vLLM serves many users, and MLX is the native path on Apple Silicon.
  • As of October 2026, Gemma 4, the Qwen3.5 to Qwen3.8 releases, gpt-oss and Mistral Small 4 cover hardware from 8 GB laptops to 128 GB Macs.

Running a language model on your own computer takes minutes once you know three things: how much memory the model needs, which file format to download and which tool will serve it. This guide covers the memory math, the main quantization formats, eight popular tools, a working Ollama setup and the open models that fit common hardware as of October 2026.

Why run an LLM locally

Local inference means the weights sit on your disk and every token is computed on your own CPU or GPU. Four reasons push people to do it.

  • Privacy. Prompts, documents and outputs never have to leave the machine, which simplifies work with client files, unreleased code or regulated data. Treat it as one control among many, not a compliance guarantee.
  • Cost. There are no per-token fees. Once you own the hardware, the marginal cost is electricity, which favors heavy, steady workloads such as bulk tagging or an all-day coding assistant.
  • Offline use. A local model works on a plane, inside an air-gapped network and during a provider outage, with no rate limits.
  • Control. You choose the exact model version, sampling settings and system prompt, and nothing gets retired unless you retire it. You can also fine-tune and run your own variants.

The trade-offs are real. The best open-weight models that fit on a desktop still trail the top hosted models on hard reasoning and long agentic tasks, and you become the operator responsible for updates and security.

Hardware basics: memory decides what you can run

VRAM, system RAM and unified memory

A model runs fastest when its weights and working memory fit entirely in GPU memory, or VRAM. Generating each token requires reading every active weight once, so speed is mostly limited by memory bandwidth. A GPU with about 1 TB/s of bandwidth holding a 16 GB model tops out near 60 tokens per second in theory (1,000 / 16), and real results land somewhat lower.

System RAM works too, but desktop memory delivers well under 100 GB/s, so CPU-only inference is several times slower. When a model slightly exceeds VRAM, llama.cpp-based tools split it between GPU and CPU, and speed drops as more layers move to the CPU.

Apple Silicon Macs use unified memory shared by the CPU and GPU, with bandwidth from roughly 100 GB/s on base chips to several hundred GB/s on Max and Ultra chips. A 64 GB or 128 GB Mac can load models no single consumer graphics card can hold. By default macOS lets the GPU use only part of that pool, commonly around two-thirds to three-quarters, so budget accordingly.

This is why mixture-of-experts (MoE) models are popular locally. Qwen3.6-35B-A3B stores 35 billion parameters but activates about 3 billion per token, so it needs the memory of a 35B model while generating at speeds closer to a small one.

A rule of thumb for weight memory

Weight memory is parameters times bytes per parameter. Quantized files carry a little extra for scaling factors, so 4-bit models work out to about 0.55-0.6 GB per billion parameters.

PrecisionPer 1B parameters8B model27B model70B model
16-bit (FP16, BF16)~2 GB~16 GB~54 GB~140 GB
8-bit (Q8_0, FP8)~1 GB~8 GB~27 GB~70 GB
4-bit (Q4_K_M, AWQ, MLX 4-bit)~0.6 GB~5 GB~16 GB~42 GB

Then add 10-20 percent for runtime buffers, the KV cache for your context length and 1-2 GB of headroom if the same GPU drives your displays. Ollama's default build of Qwen3.6 27B, for example, is a 17 GB download, which makes it a natural fit for a 24 GB card.

The KV cache grows with context

During generation the model stores attention keys and values for every token in the conversation. This KV cache grows linearly with context length and with the number of parallel requests.

KV cache bytes = 2 x layers x KV heads x head size x bytes per value x tokens

Llama 3.1 8B has 32 layers, 8 key-value heads and a head size of 128. At 16-bit precision that is 2 x 32 x 8 x 128 x 2 = 131,072 bytes, or 128 KiB per token. An 8K context needs 1 GiB, 32K needs 4 GiB and the full 128K needs 16 GiB, more than three times the 4-bit weights.

Newer designs that mix linear-attention layers with full attention, such as the Qwen3.5 and Qwen3.6 families, need much less per token. The VRAM calculator runs this arithmetic for specific models.

Quantization formats and quality trade-offs

Quantization stores weights in fewer bits. Going from 16-bit to 4-bit cuts weight memory by roughly 70 percent, and for most chat, writing and coding work the quality loss at 4 bits is small. Losses grow quickly below 4 bits and hit small models harder than large ones.

FormatHow it worksWhere it runsBest for
GGUFSingle file from the ggml project bundling quantized weights with tokenizer and chat-template metadata; levels from about 1.5 to 8 bits (Q4_K_M, Q5_K_M, Q8_0)CPUs plus NVIDIA, AMD, Intel and Apple GPUs; supports CPU+GPU splitsDesktop use in llama.cpp, Ollama, LM Studio, Jan and GPT4All
GPTQPost-training method that quantizes one layer at a time, using a small calibration set to compensate for the error it introducesGPUsGPU serving with vLLM or Hugging Face Transformers
AWQActivation-aware method that protects the small share of weights that matter most, usually at 4 bitsGPUsFast 4-bit serving in vLLM
MLXApple's array framework and weight format, usually 4-bit or 8-bit, widely published by the mlx-community organization on Hugging FaceApple Silicon onlyNative-speed inference and LoRA fine-tuning on Macs
FP88-bit floating-point weights, often with 8-bit activations, accelerated in hardwareRecent data-center and workstation GPUs (NVIDIA Ada, Hopper and newer; AMD MI300 class)Near-lossless production serving at half the memory of 16-bit

Practical defaults:

  • Start with Q4_K_M in GGUF or 4-bit MLX. Step up to Q5_K_M, Q6_K or Q8_0 when memory allows and the task punishes small errors, such as code, math, structured extraction or less common languages.
  • A common rule of thumb holds down to about 4 bits: a larger model quantized harder usually beats a smaller model at higher precision in the same memory. Below 4 bits, test carefully.
  • Prefer files from the model's publisher or well-known quantizers. Some labs ship quantized weights directly; OpenAI released gpt-oss in the 4-bit MXFP4 format, which avoids an extra lossy conversion.
  • If you create your own GPU quantizations, note that the original AutoAWQ package has not shipped a release since May 2025, while GPTQModel and the vLLM project's llm-compressor are actively maintained.

Local LLM tools compared

Most tools are front ends or servers built on a few engines: llama.cpp for GGUF, MLX for Apple Silicon and vLLM for GPU servers. Status below reflects each project's releases as of October 2026.

ToolBest forFormats and hardwareAPILicense and status
OllamaQuickest path to a local model plus an APIGGUF on Windows, macOS, Linux and Docker; MLX engine on Apple Silicon (preview since March 2026)Native REST on port 11434; OpenAI- and Anthropic-compatible endpointsMIT; frequent releases (v0.40.x in October 2026)
LM StudioBrowsing and testing models in a GUIGGUF via llama.cpp; MLX on Apple Silicon; Windows, macOS, LinuxOpenAI- and Anthropic-compatible server; lms CLI; headless llmster daemonFree desktop app; paid plans add hosted features
llama.cppMaximum control on any hardwareGGUF from 1.5 to 8 bits; CUDA, HIP, Metal, Vulkan, SYCL and CPUOpenAI-compatible server with built-in web UIMIT; continuous builds
vLLMServing many concurrent usersHugging Face weights, FP8, AWQ, GPTQ, GGUF; NVIDIA, AMD and Intel GPUs plus accelerator pluginsOpenAI-compatible and Anthropic Messages APIsApache 2.0; v0.31 (October 2026)
MLX / mlx-lmMac-native inference and fine-tuningMLX format; Apple Silicon onlyPython API and the mlx_lm.server HTTP serverMIT; mlx-lm v0.32 (October 2026)
JanOpen-source ChatGPT-style desktop appllama.cpp and MLX engines, plus optional cloud providers; Windows, macOS, LinuxOpenAI-compatible server on localhost:1337; MCP supportApache 2.0; v0.8.6 (October 2026)
GPT4AllSimple offline chat with local documentsGGUF; Windows, macOS, Ubuntu x86-64Desktop app plus Python bindingsMIT; last desktop release v3.10.0 (February 2025), so check activity first
Open WebUIShared browser chat interface for a teamNo engine of its own; connects to Ollama and any OpenAI-compatible serverBuilt-in RAG with hybrid search; user managementOpen WebUI License (branding must stay on deployments over 50 users); v0.11 (September 2026)

A sensible path: start with Ollama or LM Studio, add Open WebUI when several people need a chat interface and switch to vLLM when an application needs real concurrency.

Watch: Getting Started on Ollama (Matt Williams). A hands-on introduction to installing Ollama and running an open model on your own machine from the command line. It suits developers and tinkerers who want a first local setup working quickly.

Quick start with Ollama

1. Install. On macOS or Linux, run the script below. On Windows, use the installer from the Ollama website or run irm https://ollama.com/install.ps1 | iex in PowerShell. A Docker image, ollama/ollama, is also available.

curl -fsSL https://ollama.com/install.sh | sh

2. Pull a model sized for your machine. Gemma 4 E2B is about a 7 GB download and suits 8 GB machines; on a 24 GB GPU, try Qwen3.6 27B (17 GB).

ollama pull gemma4:e2b
ollama pull qwen3.6:27b

3. Chat in the terminal. Type /bye to exit. The --verbose flag prints generation speed after each reply.

ollama run gemma4:e2b --verbose

4. Confirm it runs on the GPU. Run ollama ps. The PROCESSOR column should read 100% GPU; a split such as 40%/60% CPU/GPU means part of the model spilled into system memory. The CONTEXT column shows the context length actually allocated.

5. Call the API. Ollama listens on port 11434.

curl http://localhost:11434/api/chat -d '{
  "model": "gemma4:e2b",
  "messages": [{"role": "user", "content": "Explain the KV cache in two sentences."}],
  "stream": false
}'

6. Reuse OpenAI-style code. Point any OpenAI SDK at http://localhost:11434/v1 with a placeholder API key.

curl http://localhost:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "gemma4:e2b", "messages": [{"role": "user", "content": "Say hello"}]}'

7. Raise the context length. Ollama's docs list a 4,096-token default on machines with under 24 GB of VRAM, which silently truncates long documents. Set a server-wide value as below, or pass "options": {"num_ctx": 32768} per request.

OLLAMA_CONTEXT_LENGTH=32768 ollama serve

Ollama binds to 127.0.0.1 by default. If you set OLLAMA_HOST=0.0.0.0 to share it on your network, put it behind a firewall or an authenticating reverse proxy, because the local API has no login of its own.

Which open models fit your hardware

The table assumes roughly 4-bit quantization and 8K-32K tokens of context. Picks are open-weight releases available as of October 2026, mostly Apache 2.0; confirm the license on each model card and check that your runtime supports the architecture.

Memory tierGood fitsNotes
8 GB GPU, or a laptop running on CPUGemma 4 E2B; Qwen3.5 4B; Qwen3.5 9B at 4-bitFine for chat, summaries and light code help; keep context modest
16 GB GPU, or a 24 GB Macgpt-oss-20b; Gemma 4 E4B or 12B; Qwen3.5 9B at 8-bitgpt-oss-20b has 21B parameters but only 3.6B active, and OpenAI designed it to run within 16 GB
24 GB GPU (RTX 3090/4090 class)Qwen3.6-27B or Qwen3.8-27B; Gemma 4 31B; Gemma 4 26B A4BQwen3.6-35B-A3B's 24 GB Ollama build slightly overflows, but MoE models tolerate partial CPU offload better than dense ones
48 GB and up (two 24 GB cards or a workstation GPU)27-35B models at 8-bit; Llama 3.3 70B at 4-bit; gpt-oss-120b on an 80 GB+ cardUse vLLM if several people share the machine
Apple Silicon, 32-48 GBGemma 4 26B A4B; 27B dense models at 4-bit; Qwen3.6-35B-A3B on 48 GBAt its March 2026 launch, Ollama's MLX engine preview required more than 32 GB of unified memory
Apple Silicon, 64 GB27-35B models at 8-bit; Llama 3.3 70B at 4-bitLeave room for macOS and your other apps
Apple Silicon, 96-128 GBgpt-oss-120b; Qwen3.5-122B-A10B; Mistral Small 4 (119B, 6.5B active)96 GB runs gpt-oss-120b with modest contexts; 128 GB fits all three with room for longer ones

Frontier-scale open models, such as the DeepSeek V4 family and Qwen3.8's 2.4-trillion-parameter flagship, need multi-GPU servers. Browse the model directory for specs and licenses.

Performance tips

  • Keep the whole model on the GPU. Check ollama ps or your tool's logs. A smaller quant that fits fully usually beats a bigger one that spills.
  • Size the context to the job. Allocating 128K tokens when you need 8K wastes memory and can force CPU offload.
  • Quantize the KV cache. In Ollama, OLLAMA_KV_CACHE_TYPE=q8_0 roughly halves KV memory with very little quality loss; it requires flash attention, which Ollama enables automatically on supported hardware.
  • Prefer MoE models for speed. Few active parameters mean fewer bytes read per token, which matters most on Macs and CPUs.
  • Try multi-token prediction drafts. Gemma 4 and Qwen3.6 support speculative decoding variants in llama.cpp, LM Studio and Ollama; gains depend on model and hardware.
  • Keep models loaded. Ollama unloads idle models after five minutes; set OLLAMA_KEEP_ALIVE higher to avoid reload delays.
  • Use a server built for concurrency. Ollama handles one request per model at a time unless you raise OLLAMA_NUM_PARALLEL, which multiplies KV memory. vLLM's continuous batching and PagedAttention deliver far higher total throughput for many users.

Troubleshooting common problems

SymptomLikely causeFix
Model fails to load or crashes with out-of-memory errorsWeights plus KV cache exceed available memoryUse a smaller quant or model, shorten the context, close other GPU apps, quantize the KV cache
Output crawls at 1-5 tokens per secondPart or all of the model is running on the CPUCheck ollama ps, update GPU drivers, confirm the CUDA, ROCm or Metal backend is detected
Replies ramble, repeat or contain odd tokensWrong chat template or a broken quantizationUse official model tags or reputable GGUF files, update the runtime, lower the temperature
The model ignores the start of a long documentInput exceeded the context length and was truncatedRaise the context setting and check the CONTEXT column
Another app or a Docker container cannot connectServer bound to 127.0.0.1 onlySet OLLAMA_HOST deliberately; from containers use host.docker.internal
Mac slows to a crawl or swapsModel exceeds the GPU share of unified memoryPick a smaller model or quant and leave headroom for macOS

Common mistakes

  • Buying hardware first. Test the exact model on a rented GPU or hosted endpoint before spending thousands of dollars.
  • Judging a model by a 2-bit or 3-bit file. Those squeeze huge models into small machines and lose noticeable quality.
  • Forgetting the KV cache. A model that loads at 4K tokens can fail at 64K.
  • Assuming local means private. Ollama and LM Studio also offer cloud-hosted models, so confirm a model actually runs on your machine before sending sensitive data.
  • Downloading random re-uploads. Stick to the publisher or well-known quantizers, and check the license allows your use.
  • I know my usable memory: VRAM, or about two-thirds to three-quarters of a Mac's unified memory.
  • Weights at my chosen quant, plus 20 percent, plus the KV cache for my context, fit in that budget.
  • I tested the model on 20-50 of my real prompts.
  • The server is bound to localhost or protected by authentication.
  • The model license allows my intended use.

Next steps

Estimate memory for a specific model, quant and context length with the VRAM calculator. If cost is your main motivation, compare hardware and hosting against per-token prices in the self-host vs API calculator. For the bigger picture on licenses and capability gaps, read open-source vs closed LLMs. If you are planning a private deployment for a team and want hands-on help, you can work with an LLM expert.

Sources

  1. Ollama documentation: context length
  2. Ollama FAQ: GPU use, KV cache quantization and network binding
  3. Ollama blog: Ollama is now powered by MLX on Apple Silicon (preview, March 2026)
  4. llama.cpp repository (ggml-org)
  5. GGUF file format specification (ggml)
  6. Efficient Memory Management for Large Language Model Serving with PagedAttention (Kwon et al., 2023)
  7. MLX LM repository (Apple ml-explore)
  8. LM Studio documentation
  9. Gemma 4 model card (Google, Hugging Face)
  10. Introducing gpt-oss (OpenAI, August 2025)

Written by the LLModel editorial team and checked against the sources above on October 10, 2026. Found an error? Send a correction.

Frequently asked questions

How much memory do I need to run an LLM locally?

Multiply the parameter count in billions by about 0.6 GB for 4-bit quantization, 1 GB for 8-bit or 2 GB for 16-bit. Add 10-20 percent for runtime buffers, plus memory for the KV cache, which grows with context length. An 8B model at 4-bit runs comfortably in 8 GB, while a 27B model at 4-bit needs roughly 20 GB once a moderate context is included.

Should I use Ollama or LM Studio?

Pick Ollama if you want a lightweight background service with a simple command line and an API that scripts and other apps can call. Pick LM Studio if you prefer browsing, downloading and comparing models in a graphical app. Both run GGUF models, both can use Apple's MLX on Macs, and both expose OpenAI-compatible endpoints, so switching later rarely requires code changes.

Can I run a local LLM without a GPU?

Yes. llama.cpp and the tools built on it run on ordinary CPUs, and models in the 1B to 9B range are usable on a modern laptop. Expect single-digit to low double-digit tokens per second for small 4-bit models, because desktop memory bandwidth is far lower than GPU bandwidth. Mixture-of-experts models with few active parameters are the best fit for CPU-only machines.

What is the best local LLM right now?

It depends on your memory. As of October 2026, strong picks include Gemma 4 E2B or Qwen3.5 4B for 8 GB machines, gpt-oss-20b for 16 GB, Qwen3.6-27B, Qwen3.8-27B or Gemma 4 31B for 24 GB GPUs, and gpt-oss-120b or Qwen3.5-122B-A10B for 96-128 GB Macs and workstations. Test two or three candidates on your own prompts before settling on one.

Is a local LLM completely private?

The model runs on your hardware, so prompts never need to leave the machine. Privacy still depends on the surrounding software. Some desktop apps can route requests to cloud-hosted models, send telemetry or sync chats, and a local server exposed to your network without authentication can be reached by others. Check model tags, app settings and network bindings before handling sensitive data.

More videos on this topic

Run your own AI (but private)

NetworkChuckBeginnerWatch on YouTube

NetworkChuck walks through running a chat model on your own computer so prompts and files stay on your machine. It is a friendly, step-by-step watch for beginners curious about the privacy side of local AI.

Ollama Course – Build AI Apps Locally

freeCodeCamp.orgIntermediateWatch on YouTube

A long-form freeCodeCamp course on building applications around locally hosted models through Ollama, moving from setup to working app code. It fits developers who learn best by following a complete project from start to finish.

Planning to self-host?

Get a second opinion on hardware, serving stack and break-even before you buy or rent GPUs.

  • Free and vendor-neutral: no model provider pays for placement.
  • Your details go only to partners you agree to.

Takes about 2 minutes. No sales calls unless you ask for one.