ThisCalculator

Everyday

Why a Local AI Model Runs Slowly & How to Fix It

Updated · Standard formula, shown below

Why a Local AI Model Runs Slowly & How to Fix It

If your local AI model feels sluggish, the cause is almost always a bottleneck in hardware resources—most commonly VRAM, RAM, or disk speed—rather than a problem with the model itself. You can improve performance by reducing the model’s memory footprint, upgrading your hardware, or adjusting runtime settings. This article explains the technical reasons behind slow inference and gives you practical, step-by-step fixes.

Background: What “Local AI� Means

Running an AI model locally means the model is downloaded to your computer and executed on your own hardware, rather than being accessed through a cloud API. This gives you privacy, offline access, and no per-token fees, but it shifts the entire computational burden onto your machine. The most common local models are large language models (LLMs) like Llama, Mistral, or Phi, which are measured in billions of parameters. Each parameter is a number that the model uses to make predictions, and the more parameters, the more memory and compute are required.

How Local Inference Works

When you send a prompt to a local model, the software (such as Ollama, llama.cpp, or LM Studio) loads the model’s weights into memory. The model then processes your input token by token, performing billions of mathematical operations per token. This is called inference. The speed of inference is limited by two main factors: memory bandwidth (how fast data can be moved between memory and the processor) and raw compute power (how many operations the processor can do per second). For most consumer hardware, memory bandwidth is the bigger constraint because the model weights are too large to fit in the processor’s fast cache, so every operation requires fetching data from slower RAM or VRAM.

Why Your Model Is Slow: The Bottlenecks

Here are the most common reasons a local model runs slowly, in order of likelihood:

  • Not enough VRAM (GPU memory): If the model doesn’t fit entirely in your GPU’s VRAM, the system must offload some layers to system RAM. This causes a massive slowdown because data has to travel over the PCIe bus repeatedly. Even a small spillover can cut speed by 10x.
  • Insufficient RAM: If the model plus your operating system and other apps exceed your RAM, the system starts using the page file on your disk, which is thousands of times slower. This can cause near-freezing behavior.
  • Slow disk speed: The first time you run a model, it must be read from disk into memory. If you have a mechanical hard drive (HDD), this can take minutes. Even on an SSD, a large model can take 10–30 seconds to load.
  • CPU-only inference: Running a model on a CPU is inherently slower than on a GPU because CPUs have far fewer cores optimized for parallel math. A 7B parameter model on a CPU might generate only 2–5 tokens per second, whereas a mid-range GPU can do 20–50.
  • Background processes: Other applications consuming CPU, RAM, or disk I/O can steal resources from the model, especially if you’re running on a laptop with power-saving settings.

How to Improve Performance: Step-by-Step

Follow these steps in order, from easiest to most involved:

  1. Use a quantized version of the model. Quantization reduces the precision of the weights (e.g., from 16-bit to 4-bit), which cuts memory usage by up to 75% and often speeds up inference on both CPU and GPU. Look for files with names like “Q4_K_M� or “q4_0� when downloading from Hugging Face or within your AI software.
  2. Close other applications. Shut down browsers, games, and background apps to free up RAM and CPU. On Windows, open Task Manager (Ctrl+Shift+Esc) to see what’s using resources.
  3. Set your power plan to High Performance. On Windows, go to Control Panel > Power Options and select “High Performance.� On macOS, ensure you’re plugged in and check Energy Saver settings. This prevents the CPU/GPU from downclocking.
  4. Update your GPU drivers. Outdated drivers can lack optimizations for AI libraries like CUDA or ROCm. Check the manufacturer’s website (NVIDIA, AMD, Intel) for the latest version.
  5. Adjust runtime settings. In llama.cpp or Ollama, you can set the number of CPU threads (e.g., --threads 8) and batch size. For Ollama, set OLLAMA_NUM_PARALLEL to 1 to reduce memory pressure. In LM Studio, lower the “Context Length� to reduce memory usage.
  6. Use GPU acceleration. If you’re running on CPU, switch to a GPU-based backend. For NVIDIA GPUs, ensure CUDA is installed. For AMD, use ROCm or DirectML. This can give a 10–50x speedup.
  7. Upgrade hardware. If you regularly run large models, consider adding more RAM, a faster SSD, or a GPU with more VRAM. A used NVIDIA GPU with 12GB+ VRAM is a common choice for local AI.

Common Mistakes and Misconceptions

One common mistake is assuming that a bigger model is always better. A 70B model will be far slower than a 7B model, and for many tasks, the smaller model is “good enough.� Another misconception is that more VRAM always means faster. While VRAM capacity is crucial, memory bandwidth (measured in GB/s) also matters. A GPU with 16GB of slow VRAM may be slower than one with 8GB of fast VRAM for a model that fits in both.

Also, people often forget that the first token (the initial response) can take longer than subsequent tokens because the model has to process the entire prompt. This is called “prefill� and is compute-bound, not memory-bound. If your prompt is long (e.g., a large document), prefill can take several seconds even on fast hardware.

Comparing CPU vs. GPU vs. NPU

Here’s a rough comparison of processing units for local AI:

  • CPU: Low cost, available everywhere, but slow. Good for small models (1–3B) or when you don’t have a GPU. Speed: 1–5 tokens/sec for 7B.
  • GPU (NVIDIA/AMD): Best performance for most users. High VRAM and bandwidth. Speed: 10–50+ tokens/sec for 7B with a mid-range card.
  • NPU (Neural Processing Unit): Found in some new laptops and phones. Very efficient for small models, but often limited by software support. Speed varies widely.

Costs and Practical Limits

Improving performance often costs money. A new GPU can range from a few hundred to thousands of dollars. However, you can often get a significant speedup for free by using quantization and closing apps. The practical limit is your hardware’s memory capacity. A 7B parameter model in 4-bit quantization requires about 4GB of RAM/VRAM. A 13B model needs about 8GB. A 70B model needs about 40GB—which is beyond most consumer setups.

Frequently Asked Questions

Q: Why is my model slow even though I have a good GPU?
A: Check if the model is actually using the GPU. In LM Studio or Ollama, look for “GPU layers� in the logs. If it says “offloaded 0/32 layers,� then it’s running on CPU. Also, ensure your GPU has enough VRAM—if the model spills over, speed drops dramatically.

Q: What does “quantization� mean and is it safe?
A: Quantization reduces the precision of the model’s weights (e.g., from 16-bit to 4-bit). This makes the model smaller and faster, with a slight drop in accuracy. For most conversational tasks, the drop is negligible. It’s safe and widely used.

Q: How many tokens per second should I expect?
A: For a 7B model on a modern CPU, expect 2–5 tokens/sec. On a mid-range GPU (e.g., RTX 3060), 20–40 tokens/sec. For a 13B model, halve those numbers. Anything above 10 tokens/sec feels usable for chat.

Q: Does the context length affect speed?
A: Yes. A longer context (the amount of text the model remembers) uses more memory and slows down the prefill stage. Reducing the context length from 8192 to 2048 can free up significant VRAM and speed up processing.

Q: Is it better to run a smaller model or a quantized larger model?
A: It depends on your task. A 7B model with 8-bit quantization is often faster and more accurate than a 13B model with 4-bit quantization, because the 13B model may be too large for your VRAM. Try both and compare.

Q: Can I use multiple GPUs to speed up inference?
A: Yes, but only if the software supports it. llama.cpp and Ollama can split layers across multiple GPUs. This can help with memory capacity, but the speed gain is limited by the interconnect speed between GPUs. It’s not recommended for most users.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.