DEV Community

Cover image for Running AI Models Locally Without a GPU: A Practical Guide to GGUF and llama.cpp
Mango Developer
Mango Developer

Posted on Originally published at mangodeveloper.com

Running AI Models Locally Without a GPU: A Practical Guide to GGUF and llama.cpp

I'm writing this on a 2021 M1 MacBook Pro with 16GB of RAM. There's no NVIDIA GPU in sight. And right now, it's running a Llama 3.1 8B model at 18 tokens per second, answering questions about my codebase, summarizing PDFs, and doing it all offline. Three years ago, that sentence would have been science fiction.

The trick is quantization-specifically the GGUF format and the llama.cpp runtime. If you've been telling yourself you can't run local LLMs because you don't have a GPU, this guide is for you. We're going to set up a real local inference stack on a laptop or a cheap VPS, and I'll show you the production patterns I use to actually ship with it.

Why Run Models Locally (Without a GPU)

Three reasons, in order of importance for most teams:

Privacy and data residency. Legal, healthcare, finance, internal corporate data-you can't always ship it to an API. Local inference on a laptop or air-gapped server is the only compliant option.

Cost at the long tail. If you're doing batch processing-summarizing 100K documents, classifying a million support tickets-API costs add up fast. A $40/month VPS running Qwen2.5-7B-Q5 processes unlimited tokens. The math breaks even quickly.

Latency and offline use. No network round-trip. No rate limits. No API outages. For interactive coding assistants and embedded use cases, local is just better.

The trade-off, of course, is quality. A quantized 7B model is not GPT-4. But for a surprising range of tasks-classification, summarization, code completion, structured extraction-it's good enough, and you control it entirely.

$32

GGUF vs GPTQ vs AWQ

These are the three main quantization formats you'll see. They serve different runtimes.

Format Primary runtime Hardware focus Quantization method Best for
GGUF llama.cpp, Ollama CPU + Apple Silicon + GPU k-quants, NF4-style Local/CPU inference, edge deployment
GPTQ AutoGPTQ, vLLM NVIDIA GPU Post-training quantization GPU serving, server-side
AWQ vLLM, TGI NVIDIA GPU Activation-aware GPU serving, slight quality edge over GPTQ

For a no-GPU setup, GGUF is the only game in town. GPTQ and AWQ are GPU-first. The formats aren't interchangeable-you can't load a GPTQ model in llama.cpp.

Prerequisites

  • Any modern CPU, ideally with AVX2 support (post-2013 Intel, post-2015 AMD). ARM works great too-Apple Silicon is actually the best CPU inference platform right now.
  • 8GB RAM minimum for a 7B model at Q4. 16GB+ for comfortable multitasking.
  • 10-20GB free disk for models.
  • macOS, Linux, or Windows (WSL2 recommended on Windows).

No GPU required. If you do have one, llama.cpp will use it-but that's a bonus, not a requirement.

$33

$34

Picking the Right Model for Your Hardware

This is the question I get most. Here's my decision tree:

Your RAM Recommended model Quantization Notes
8GB Llama 3.2 3B Q4_K_M Good quality for the size
8GB Phi-3.5 Mini (3.8B) Q5_K_M Strong reasoning, small footprint
16GB Llama 3.1 8B Q5_K_M Best general-purpose local model
16GB Qwen2.5 7B Q5_K_M Excellent multilingual, code
16GB Mistral 7B v0.3 Q5_K_M Solid European-friendly alternative
32GB Llama 3.1 8B Q8_0 Max quality 7B
32GB Qwen2.5 14B Q5_K_M Meaningfully smarter than 7B
32GB Command R 35B Q3_K_M Great for RAG, just barely fits
64GB+ Llama 3.1 70B Q4_K_M Approaches GPT-4 class

A practical note: your OS and other apps use RAM too. Leave 4-6GB of headroom. If your system starts swapping during inference, performance falls off a cliff-disk is 1000x slower than RAM.

$35

$36

Plugging Into LangChain or LlamaIndex

# langchain_local.py
from langchain_community.chat_models import ChatOllama
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser

llm = ChatOllama(
 model="llama3.1:8b",
 temperature=0.3,
 num_ctx=8192, # IMPORTANT - default is 2048, too small for RAG
)

prompt = ChatPromptTemplate.from_messages([
 ("system", "You are a concise technical writer."),
 ("user", "{input}"),
])

chain = prompt | llm | StrOutputParser()
print(chain.invoke({"input": "Explain what a mutex is."}))
Enter fullscreen mode Exit fullscreen mode

The num_ctx setting is the single most common bug I see. Ollama defaults to a 2048-token context window, which is fine for chat but useless for RAG. Set it to 8192 or higher when you're passing retrieved chunks.

$37

$38

$39

$3a

$3b

Real-World Use Cases

  • Air-gapped document Q&A. Legal team runs a Llama 3.1 8B on an offline laptop to summarize contracts. Zero data egress, full audit trail.
  • Embedded coding assistant. Continue.dev or Cursor pointed at a local Qwen2.5-7B for code completion. No API key, works offline on flights.
  • Batch classification. Startup runs Qwen2.5-7B on a $40 VPS to classify 100K product reviews overnight. Total cost: $40/month. API equivalent: thousands.
  • Edge IoT. Phi-3.5 Mini on a Jetson Nano doing real-time visual question answering at a museum kiosk. No cloud dependency.
  • Dev/test environment. Run local models for integration tests so CI doesn't burn API credits. Free re-runs.

Wrapping Up

GGUF and llama.cpp have democratized LLM inference. What required a data center three years ago runs on a MacBook today. If you've been on the fence about local models because "I don't have a GPU," the excuse is gone.

The pragmatic path: install Ollama, pull a Q5_K_M 7B model, point your existing OpenAI-compatible code at localhost:11434, and see what happens. You might be surprised how far a quantized 7B gets you-and how nice it is to own your inference stack entirely.


Originally published on Mango Developer.

Top comments (0)