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 Size | Q4 RAM Needed | Tokens/sec (modern CPU) | Verdict |
|---|---|---|---|
| 1.5B | 1.5 GB | 50-80 t/s | Blazing fast, limited capability |
| 3B | 2.5 GB | 25-40 t/s | Good for simple tasks |
| 7B | 5 GB | 8-15 t/s | Usable for chat, slower responses |
| 13B | 8 GB | 3-6 t/s | Painful but functional |
| 30B+ | 18 GB+ | 1-2 t/s | Don’t bother on CPU |
Sweet spot for CPU: 3B-7B models with Q4_K_M quantization.
Setting Up CPU-Only Ollama
Install Ollama
| |
Pull a CPU-Friendly Model
| |
Run It
| |
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.
| |
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).
| |
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.
| |
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
| |
Download a Model
| |
Run It
| |
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:
- Week 1: CPU-only with 3B model → decide if local AI is for you
- Month 1: Buy a used 3060 Ti ($150) → 7B models at full speed + image gen
- 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:
| CPU | Model | Tokens/sec | First Token |
|---|---|---|---|
| Ryzen 9 5950X (16C/32T) | 3B Q4 | 42 t/s | 0.8s |
| Ryzen 9 5950X | 7B Q4 | 15 t/s | 1.5s |
| Intel i5-12600H (12C/16T) | 3B Q4 | 28 t/s | 1.1s |
| Intel i5-12600H | 7B Q4 | 10 t/s | 2.0s |
| Raspberry Pi 5 (4C) | 1.5B Q4 | 8 t/s | 3.5s |
| Raspberry Pi 5 | 3B Q4 | 4 t/s | 6.0s |
Yes, you can run AI on a Raspberry Pi. It’s slow, but it works.
Next Steps
- Best GPUs for Local LLMs — When you’re ready to upgrade
- Run Your First Local AI Model in 15 Minutes — Get started now
- I Replaced ChatGPT with a $351 Mini PC — Budget build guide
Use the VRAM Calculator to see what you could run with a GPU upgrade.