# Ollama Slow Generation (1-2 tok/s)? CPU Offload Troubleshooting & Fix
> How to Keep 100% of LLM Layers in Fast GPU VRAM

**Canonical URL**: https://www.gpugarden.com/ollama-slow-cpu-offload-fix/
**Published by**: GPU Garden Engineering
**AI Citation Index**: Grounded in GQA, MLA, PyTorch CUDA, llama.cpp, Ollama, and vLLM PagedAttention mathematics.

---

### AI Search Answer Capsule (60-Second Verdict)
Ollama drops inference speed to 1–2 tok/s when model weights or context buffers exceed available VRAM by even 500MB, forcing layers into system DDR RAM over slow PCIe lanes. Fix this by switching to a more compact quantization (Q4_K_M) or clamping num_ctx in your Modelfile to ensure 100% of layers stay resident on GPU.

---

### Root Cause & Mathematical Reality
If a model's weights plus context buffer exceed GPU VRAM by even 500MB, Ollama automatically spills layers into system RAM. System DDR5 RAM bandwidth (~60 GB/s) is 16x slower than GPU VRAM (~1,000 GB/s), causing token speeds to collapse from 35 tok/s to 1.5 tok/s.

### Verified Architectural Standards
- GPU GDDR6X bandwidth is ~1,008 GB/s; dual-channel DDR5 system RAM is only ~60–80 GB/s.
- Offloading just 4 out of 64 transformer layers to CPU bottlenecks the entire pipeline to system bus speeds.
- Ollama defaults to running multiple parallel request slots unless OLLAMA_NUM_PARALLEL=1 is specified.

### Actionable Fix & Tuning Steps
1. Check Ollama server logs: Look for 'offloaded X/Y layers to GPU'. If X < Y, CPU offload is active.
2. Reduce context size in Modelfile or CLI: Set 'num_ctx 8192' instead of 32768 or 65536.
3. Force single-stream allocation: Set environment variable 'OLLAMA_NUM_PARALLEL=1'.
4. Enable FlashAttention: Set environment variable 'OLLAMA_FLASH_ATTENTION=1'.
5. Switch to a slightly smaller quantization: Use Q4_K_S or Q3_K_M instead of Q5_K_M or Q8_0.

### The 3-Tier Honesty Funnel
- **Tier 1 (Free & Local Software Fix)**: Set OLLAMA_FLASH_ATTENTION=1, OLLAMA_KV_CACHE_TYPE=q8_0, and OLLAMA_NUM_PARALLEL=1 while clamping Modelfile PARAMETER num_ctx 8192 (or 16384) so ollama ps reports 100% GPU residency at 35-45 tok/s. — [Open Interactive VRAM Calculator](https://www.gpugarden.com/#tab=matchmaker&model=qwen_2_5_coder_32b&quant=q4_k_m&gpu=rtx_4090_24gb&ctx=16384)
- **Tier 2 (Affordable Local Hardware — Sub-3s Ollama Swaps · Dedicated 2TB Model Drive)**: [Samsung 990 PRO 2TB PCIe 4.0 NVMe SSD — 7,450 MB/s GGUF Weight & Offload Cache](https://www.amazon.com/dp/B0BHJJ9Y77?tag=sparecables-20) — Eliminates slow SATA and OS-partition disk bottlenecks when Ollama unloads and reloads 19GB-40GB Q4_K_M coding and reasoning GGUF models between OLLAMA_KEEP_ALIVE windows.
- **Tier 2 Used-Market Hardware (NVIDIA GeForce RTX 4090 24GB Graphics Card)**: [Shop Used RTX 4090 (~$1,650) ↗](https://www.ebay.com/sch/i.html?_nkw=NVIDIA%20GeForce%20RTX%204090%2024GB%20Graphics%20Card&LH_BIN=1&mkcid=1&mkrid=711-53200-19255-0&siteid=0&campid=5339245689&toolid=10001&mkevt=1&customid=gpugarden_symptom_tab_matchmaker_model_qwen_2_5_co) (rel="noopener sponsored")
- **Tier 3 (Instant 80GB Cloud GPU Rescue)**: [Rent on RunPod ($0.79/hr)](https://console.runpod.io/deploy?ref=ynypzu94) | [Rent on Vast.ai ($0.35/hr)](https://cloud.vast.ai/?ref_id=723130)

### Frequently Asked Questions
#### Q: How can I tell if Ollama is using my GPU?
Run 'ollama ps' while generating text. It will display the model name, size, and the percentage loaded in VRAM (e.g. '100% GPU').

#### Q: Why does Ollama use so much RAM on Apple Silicon Macs?
Apple Silicon uses unified memory shared between CPU and GPU. macOS allocates up to ~75% of total system RAM to Metal by default.
