Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Why a Local AI Model Runs Slowly & How to Speed It Up

· 7 min read · Home Tech

In this article
  1. Background: Why Run AI Locally at All?
  2. How Local AI Inference Works (and Where the Bottleneck Is)
  3. How to Choose a Faster Model (Size vs. Quality)
  4. Quantization: Shrink the Model to Fit and Speed Up
  5. Hardware: GPU, CPU, RAM, and Storage
  6. Software and Settings That Affect Speed
  7. Common Problems and Misconceptions
  8. Costs and Alternatives
  9. Frequently Asked Questions

A local AI model runs slowly because it must process every token (word or word piece) through billions of parameters using only your computer's CPU, GPU, and memory—unlike cloud AI that uses massive data-center servers. You can speed it up by choosing a smaller model, quantizing it, using a GPU with enough VRAM, and adjusting generation settings. This article explains the main causes of slow inference and gives practical, step-by-step fixes you can apply today.

Background: Why Run AI Locally at All?

Running a large language model (LLM) or image generator on your own machine has clear benefits: privacy (your data never leaves your computer), no internet dependency, no per-query fees, and full control over the model. But local hardware is far less powerful than the GPU clusters used by cloud services. A consumer laptop might have 16 GB of RAM and a mid-range GPU, while a cloud server can have hundreds of gigabytes of high-bandwidth memory and dozens of top-tier GPUs. That gap is the root cause of slow performance.

How Local AI Inference Works (and Where the Bottleneck Is)

When you ask a local model a question, it doesn't “think” in the way humans do. It runs a forward pass through a neural network, layer by layer, to predict the next token. That prediction involves multiplying large matrices—essentially millions of arithmetic operations per token. The model repeats this process for each token in its response, so a 500-word answer might require thousands of individual passes.

The three main bottlenecks are:

  • Memory bandwidth: The model weights (the numbers that define the model) must be read from RAM or VRAM for every token. If the memory is slow or the model doesn't fit entirely in fast memory, this becomes the limiting factor.
  • Compute throughput: The GPU or CPU must perform all those multiplications. A GPU with more CUDA cores or tensor cores does this much faster than a CPU.
  • Memory capacity: If the model is larger than your VRAM (or RAM), it spills over to slower storage, causing a massive slowdown.

For example, a 7-billion-parameter model in 16-bit precision uses about 14 GB of memory. On a GPU with 8 GB VRAM, it won't fit, so it will use system RAM and possibly disk, making generation painfully slow.

How to Choose a Faster Model (Size vs. Quality)

The easiest way to speed up local AI is to choose a model that fits your hardware. Model size is measured in parameters (e.g., 7B, 13B, 70B). Larger models generally produce better answers but require more memory and compute. A good rule of thumb:

  • For 8 GB VRAM: use a 7B model quantized to 4-bit.
  • For 12-16 GB VRAM: use a 13B model quantized to 4-bit, or a 7B model in 8-bit.
  • For 24 GB VRAM: you can run a 30B model quantized, or a 13B in full precision.

Also consider the model's architecture. Newer models like Llama 3 or Mistral are more efficient than older ones of the same size. If you're using a CPU-only machine, look for models specifically optimized for CPU inference, such as those with “GGUF” format.

Quantization: Shrink the Model to Fit and Speed Up

Quantization reduces the precision of the model's weights, e.g., from 16-bit floating point to 8-bit or 4-bit integers. This cuts memory usage and increases speed because smaller data moves faster. The trade-off is a slight drop in accuracy, but modern quantization methods (like GPTQ, AWQ, or GGUF with k-quants) often produce results nearly indistinguishable from full precision for most tasks.

To quantize a model, you can download pre-quantized versions from platforms like Hugging Face (e.g., “TheBloke” provides many GGUF and GPTQ files) or use tools like llama.cpp to convert a model yourself. For example, a 13B model in 4-bit takes about 7 GB of memory, making it runnable on a 8 GB GPU.

Hardware: GPU, CPU, RAM, and Storage

Your hardware determines the ceiling for speed. Here's what matters:

  • GPU: A dedicated NVIDIA GPU with CUDA support is best. The more VRAM, the larger the model you can run entirely on the GPU. Even an older GTX 1080 Ti (11 GB) can run a 7B model at decent speed.
  • CPU: If you don't have a GPU, a modern multi-core CPU with AVX2 instructions can still run small models, but expect 5-20 tokens per second at best.
  • RAM: For CPU inference, you need enough system RAM to hold the model plus overhead. 16 GB is the minimum for a 7B model; 32 GB is better for 13B.
  • Storage: Use an SSD, not an HDD. If the model has to swap to disk, an HDD will be a huge bottleneck.

If you have a GPU but not enough VRAM, you can use offloading (e.g., with llama.cpp or Hugging Face's accelerate) to put some layers on the GPU and the rest on CPU, but this is slower than full GPU inference.

Software and Settings That Affect Speed

Beyond hardware, the software stack and generation parameters matter. Here are concrete steps:

  1. Use a fast inference engine: Tools like llama.cpp (with GPU support) or Ollama are highly optimized. Avoid running a model through a generic Python script without optimization.
  2. Enable GPU acceleration: In llama.cpp, compile with CUDA support and use the -ngl flag to offload layers to GPU. In Ollama, it's automatic if you have a compatible GPU.
  3. Reduce context length: The context (the amount of text the model remembers) uses memory and compute. If you don't need a huge context, set it to 2048 or 4096 tokens instead of 8192 or more.
  4. Cap output tokens: Set a maximum generation length (e.g., 512 tokens) to prevent the model from rambling.
  5. Use batching: If you're processing multiple prompts, some engines can batch them, improving throughput.

Also, close other programs that use GPU memory (like games or video editors) to free up VRAM.

Common Problems and Misconceptions

A frequent misconception is that a larger model will always be slower. In practice, a 70B model quantized to 4-bit might run at 5 tokens/sec on a high-end GPU, while a 7B model runs at 50 tokens/sec. But if the 70B model doesn't fit in VRAM and uses CPU offloading, it could be 10x slower than a smaller model that fits entirely on the GPU. So the key is fit, not just size.

Another issue is thermal throttling. Laptops often slow down the CPU/GPU when they get hot. Ensure proper ventilation and consider a cooling pad.

If your model is running at <1 token per second, check if it's actually using the GPU. In llama.cpp, the logs show how many layers are offloaded. If it says “offloaded 0/32 layers,” your GPU isn't being used.

Costs and Alternatives

Running AI locally has a hardware cost. A GPU with 16 GB VRAM can cost several hundred dollars, and a high-end one can exceed $2,000. However, you avoid ongoing cloud fees. If you only need AI occasionally, cloud services (like ChatGPT or Claude) might be cheaper and faster, but you sacrifice privacy and control.

Alternatives to running a full LLM locally include using a smaller distilled model (e.g., a 3B version of a larger model) or using a cloud API for heavy tasks and local for light ones. You can also use a hybrid approach: run a small local model for simple queries and fall back to cloud for complex ones.

Frequently Asked Questions

Q: How many tokens per second is considered “fast” for local AI?
A: For interactive use, you want at least 10 tokens per second. Reading speed is about 4-5 tokens per second, so anything above that is usable, but 20+ feels much more responsive. On a good GPU, a 7B quantized model can achieve 30-50 tokens/sec.

Q: Can I run a 70B model on a 16 GB Mac?
A: Yes, but slowly. A 70B model in 4-bit needs about 35 GB of memory, so it won't fit in 16 GB. You'd need to use a smaller quantization (2-bit) or offload to disk, which will be very slow. It's better to use a 13B or 30B model on 16 GB.

Q: Does using a GPU always speed up inference?
A: Usually, yes, but only if the model fits in VRAM. If the model is too large, the GPU will offload to CPU, which can be slower than just using CPU. Also, some GPUs have poor compute for AI (e.g., older cards without tensor cores), but they still help due to memory bandwidth.

Q: What is the best quantization for speed?
A: 4-bit quantization (like Q4_K_M in GGUF) is a good balance of speed and quality. 2-bit is faster but noticeably worse. 8-bit is slower but nearly lossless. For most users, 4-bit is recommended.

Q: Why is my model using 100% CPU but only 10% GPU?
A: That usually means the model is not fully offloaded to the GPU. In llama.cpp, increase the -ngl value to offload more layers. In other tools, check the settings for GPU layers or device placement.

Q: Will a better CPU help if I have a GPU?
A: Not much for inference, because the GPU does the heavy lifting. The CPU mainly handles tokenization and the operating system. A better CPU helps if you're doing CPU inference, but the GPU is the primary factor.