The Truth About CPU Inference

Everyone thinks you need a GPU for local AI. You don’t. CPU inference works. It’s slower, yes — but “slower” doesn’t mean “unusable.” A modern CPU running a 3B model generates 20-40 tokens per second. That’s faster than you can read.

The misconception comes from people trying to run 70B models on CPU and concluding it’s unusable. That’s like trying to tow a trailer with a bicycle and concluding cars don’t work. Match the model to your hardware and CPU inference is perfectly viable.

What You Can Run on CPU

Model SizeQ4 RAM NeededTokens/sec (modern CPU)Verdict
1.5B1.5 GB50-80 t/sBlazing fast, limited capability
3B2.5 GB25-40 t/sGood for simple tasks
7B5 GB8-15 t/sUsable for chat, slower responses
13B8 GB3-6 t/sPainful but functional
30B+18 GB+1-2 t/sDon’t bother on CPU

Sweet spot for CPU: 3B-7B models with Q4_K_M quantization.

Setting Up CPU-Only Ollama

Install Ollama

1
2
3
4
5
# Linux
curl -fsSL https://ollama.com/install.sh | sh

# Windows: download installer from ollama.com
# Mac: download from ollama.com

Pull a CPU-Friendly Model

1
2
3
4
5
6
7
8
# Fast and capable — best starting point
ollama pull llama3.2:3b

# Slightly smarter, slower
ollama pull qwen2.5:3b

# Best 7B for CPU (if you have 16GB RAM)
ollama pull llama3.1:8b

Run It

1
ollama run llama3.2:3b

That’s it. Ollama automatically detects no GPU and falls back to CPU. No configuration needed.

Optimizing CPU Inference

1. Choose the Right Quantization

Q4_K_M is the sweet spot. It’s the best balance of quality and speed. Don’t go lower than Q3 — the quality degradation becomes noticeable.

1
2
3
# Ollama uses Q4 by default — that's correct
# If using llama.cpp directly:
./main -m model-q4_k_m.gguf -p "Hello" -t 8

2. Set Thread Count Correctly

The number of CPU threads matters. Too few = slow. Too many = context switching overhead.

Rule of thumb: Set threads to your physical core count (not logical/hyperthreaded).

1
2
3
4
5
6
7
8
# Check your cores
nproc

# Set threads for llama.cpp
./main -m model.gguf -t 8  # for 8 physical cores

# Ollama auto-detects, but you can override:
OLLAMA_NUM_THREAD=8 ollama run llama3.2:3b

3. Use Smaller Context Windows

Context length affects memory and speed. The default 2048 is fine for most tasks. Don’t crank it to 32768 on CPU — it’ll crawl.

1
2
3
# Ollama default: 2048 tokens — good for CPU
# To increase (at cost of speed):
OLLAMA_NUM_CTX=4096 ollama run llama3.2:3b

4. Close Memory-Hungry Apps

CPU inference uses system RAM. If you have 16GB and Chrome is eating 6GB, your model has 10GB to work with. Close what you don’t need.

5. Use Memory-Mapped Models

llama.cpp uses mmap by default, which means the model file is loaded from disk on demand rather than all at once. This reduces RAM usage but increases latency on first tokens. Keep models on an SSD, not a spinning hard drive.

llama.cpp: The Alternative

Ollama uses llama.cpp under the hood, but you can run llama.cpp directly for more control:

Build from Source

1
2
3
git clone https://github.com/ggerganov/llama.cpp
cd llama.cpp
make  # CPU-only build

Download a Model

1
2
# From HuggingFace
wget https://huggingface.co/TheBloke/Llama-3.2-3B-Instruct-GGUF/resolve/main/llama-3.2-3b-instruct-q4_k_m.gguf

Run It

1
./main -m llama-3.2-3b-instruct-q4_k_m.gguf -t 8 -c 2048 -p "Explain quantum computing simply"

Why Use llama.cpp Directly?

  • More control over parameters
  • No background service
  • Latest optimizations before they reach Ollama
  • Can build with specific CPU instruction sets (AVX2, AVX-512)

When CPU Makes Sense

  • Testing the waters: Try local AI before buying a GPU
  • Light tasks: Summarization, simple Q&A, text classification
  • Always-on servers: A 3B model on a mini PC sipping 15W
  • Coding assistant: 7B models handle code completion well, even at 10 t/s
  • Privacy-first setups: Air-gapped machines with no GPU

When You Need a GPU

  • Image generation: Stable Diffusion on CPU takes minutes per image vs seconds on GPU
  • Models above 13B: CPU is too slow for interactive use
  • Multiple users: One GPU serves multiple requests; CPU bottlenecks quickly
  • Training/fine-tuning: LoRA training on CPU is measured in days, not minutes
  • Real-time applications: Voice chat, live translation, anything with latency requirements

The Upgrade Path

Start on CPU. If you find yourself using local AI daily, buy a used GPU:

  1. Week 1: CPU-only with 3B model → decide if local AI is for you
  2. Month 1: Buy a used 3060 Ti ($150) → 7B models at full speed + image gen
  3. Month 6: Upgrade to 3090 ($800) → 30B models, training, multi-model

You don’t need to spend $800 on day one. Start free, upgrade when you hit a wall.

Real-World CPU Benchmarks

Tested on our infrastructure with various CPUs:

CPUModelTokens/secFirst Token
Ryzen 9 5950X (16C/32T)3B Q442 t/s0.8s
Ryzen 9 5950X7B Q415 t/s1.5s
Intel i5-12600H (12C/16T)3B Q428 t/s1.1s
Intel i5-12600H7B Q410 t/s2.0s
Raspberry Pi 5 (4C)1.5B Q48 t/s3.5s
Raspberry Pi 53B Q44 t/s6.0s

Yes, you can run AI on a Raspberry Pi. It’s slow, but it works.

Next Steps


Use the VRAM Calculator to see what you could run with a GPU upgrade.