Local LLM Deployment on Mac and Linux
Run capable LLMs on your own hardware without depending on cloud APIs. This guide covers the practical tradeoffs between Ollama, llama.cpp, and direct model serving on Mac and Linux for offline-first workflows.
Why run models locally
Local deployment removes three practical risks from cloud-only AI workflows: API outages, per-token cost spikes, and data leaving your environment. For repetitive tasks such as formatting, classification, and local RAG over private docs, local models often deliver acceptable quality at zero marginal cost.
The tradeoff is hardware. Smaller models can run comfortably on a MacBook Air; larger models require GPU memory, unified memory bandwidth, or a Linux box with a decent consumer GPU. Choose the tool that matches your hardware and operational tolerance.
Ollama for fast iteration
Ollama is the fastest path from download to inference. It handles model packaging, quantization, and an OpenAI-compatible API out of the box. On a Mac with 16 GB or more unified memory, ollama run llama3.1:8b-instruct-q4_K_M is usually enough for drafting, rewriting, and structured extraction.
When Ollama is the right choice
- Single-user experimentation: you want one command to pull, run, and query.
- API compatibility: existing tools already expect an OpenAI-style endpoint.
- Mac-first setup: unified memory hides much of the VRAM management work.
When to look elsewhere
- You need fine-grained control over context sharding, batch size, or CPU/GPU threading.
- You want GGUF-based workflow tooling, custom prompt templates, or non-standard tokenizers.
- You are on headless Linux and need a lighter runtime footprint.
llama.cpp for control and portability
llama.cpp remains the most portable backend for GGUF models. It compiles cleanly on Mac and Linux, exposes explicit memory controls, and supports CPU-only inference when GPU access is limited. The workflow is longer than Ollama, but the knobs are yours.
A practical Linux pattern is to run llama-server on a machine with more memory than your laptop, then call it from your primary workstation. For Mac, Metal acceleration usually removes the need for that split unless you are running 70B-class models.
If you want a concrete workflow for shipping prompts alongside model setup, see Prompt engineering for structured outputs. For a comparison of cloud-vs-local tooling across a real team, see AI coding assistant code review.
Hardware and model selection
Use this rough sizing to avoid surprise OOMs:
| Machine | Practical max | Typical use |
|---|---|---|
| MacBook Air 8 GB | 7B Q4 | Light drafting, classification |
| MacBook Pro 16 GB | 13B Q4 | Structured extraction, translation |
| MacBook Pro 32 GB | 34B Q4 | Long context, local RAG |
| Linux 24 GB VRAM | 70B Q5 | Reasoning, agent-style tasks |
Prefer Q4 or Q5 quantization for general use. Q2 and Q3 are cheaper but degrade reasoning and instruction following more than most benchmarks suggest. Measure on your own workload rather than trusting leaderboard summaries.
Prompting differences
Local models often require shorter, more explicit instructions than large cloud APIs. Avoid assuming the same prompt will transfer directly. Reduce ambiguity, include the desired output format, and add a one-shot example when accuracy matters more than brevity.
Operational checklist
- Start with one model, one runtime, and one benchmark task.
- Pin the model file hash and runtime version in a short local README.
- Use an API gateway or script wrapper so your tooling does not hardcode one runtime.
- Schedule a monthly model refresh cadence; local models drift quickly in capability.
Local deployment is a reliability play, not a set-and-forget install. The benefit is control, and control only counts if you keep the stack current.
Troubleshooting common failures
If Ollama hangs on model load, check unified memory pressure first. On Mac, close GPU-heavy apps and rerun. On Linux, verify no other process is locking the GPU device file. If llama.cpp crashes immediately, rebuild from source after updating system OpenBLAS or cuBLAS dependencies.
Quantization mismatches also cause silent quality regressions. If responses degrade after a model update, compare the GGUF filename and quantization level against the previous pinned version. Do not treat a newer model file as automatically equivalent.
Cost comparison
Cloud APIs charge per token. Local models charge for hardware and electricity once. For high-volume tasks such as classification, normalization, or internal search, the crossover point is often much lower than teams expect.
| Scenario | Cloud API | Local model |
|---|---|---|
| Low volume, ad hoc queries | Low fixed cost | Not worth the setup |
| High volume, repetitive tasks | Expensive at scale | Usually cheaper |
| Private or regulated data | Compliance review required | Often simpler |
| Offline or air-gapped use | Not possible | Fits naturally |
Latency reality check
Local inference is not always faster than a good cloud API. Network latency can be lower than first-token time on an underpowered CPU. Benchmark your actual workflow, not isolated token speeds.