VRAM Needed for Local LLMs & Image Generators
In this article
To run large language models (LLMs) and image generators locally, you generally need between 6 GB and 24 GB of VRAM, depending on the model size and whether you use quantization or offloading. A 7B-parameter model fits in 6–8 GB with 4-bit quantization, while a 70B model requires 24 GB or more even when compressed. This article explains exactly how much VRAM each type of model needs, how to estimate it, and what to do if you have less.
How VRAM Is Used by AI Models
VRAM (video RAM) holds three things when you run a model locally: the model weights, the key-value (KV) cache, and the runtime overhead (CUDA contexts, activations, and framework buffers). The weights are the largest part—a model with 7 billion parameters stored in 16-bit floating point takes about 14 GB (7 billion × 2 bytes). In 4-bit quantization, the same model drops to about 3.5 GB. The KV cache grows with the context length (the amount of text the model can "remember" at once) and can add 1–4 GB. Runtime overhead typically consumes 0.5–1 GB. So the practical VRAM needed is roughly: weights + KV cache + 1 GB.
VRAM Requirements for LLMs by Size
Here are typical VRAM needs for popular open-weight LLM sizes, assuming 4-bit quantization (the most common way to run them locally) and a 4K context length:
- 1–3B parameters (e.g., TinyLlama, Phi-3-mini): 2–4 GB VRAM. Runs on almost any GPU from the last 5 years.
- 7–8B parameters (e.g., Llama 3, Mistral): 6–8 GB VRAM. This is the sweet spot for 8 GB cards like the RTX 3060 or 4060.
- 13–14B parameters (e.g., Llama 2 13B): 10–12 GB VRAM. Needs a 12 GB card like the RTX 3060 12GB or 4070.
- 30–34B parameters (e.g., Yi-34B, Mixtral 8x7B): 20–24 GB VRAM. Requires a 24 GB card like the RTX 3090 or 4090.
- 70B+ parameters (e.g., Llama 3 70B): 40+ GB VRAM with 4-bit quantization. Only feasible on dual 24 GB GPUs or with heavy CPU offloading (slow).
If you run models without quantization (full 16-bit), multiply the parameter count by 2 GB per billion parameters. For example, a 7B model needs 14 GB, not 6–8 GB.
VRAM Requirements for Image Generators
Image diffusion models like Stable Diffusion have different needs. They are smaller than LLMs but still require significant VRAM for the UNet (or transformer) and the text encoder. Here are typical requirements:
- Stable Diffusion 1.5 (2GB model): 4–6 GB VRAM to generate 512×512 images. Runs on 4 GB cards with low VRAM mode, but slowly.
- Stable Diffusion XL (SDXL) (6.5GB model): 8–12 GB VRAM for 1024×1024 images. An 8 GB card works with optimizations, but 12 GB is comfortable.
- FLUX.1-dev (12B model): 16–24 GB VRAM for 1024×1024 images. Requires a 24 GB card for reasonable speed.
Image generation also uses VRAM for the latent space, the VAE decoder, and the CLIP text encoder. Upscaling to higher resolutions (e.g., 2048×2048) can add 2–4 GB. If you use ControlNet or LoRA adapters, add 1–2 GB.
How to Calculate VRAM for Any Model
You can estimate VRAM for any LLM with a simple formula:
- Find the parameter count (e.g., 7B = 7,000,000,000).
- Multiply by bytes per parameter: 2 bytes for FP16, 1 byte for INT8, 0.5 bytes for INT4.
- Add the KV cache: roughly 1 GB per 4K context for a 7B model, scaling linearly with context length and model size.
- Add 1 GB for runtime overhead.
For image models, the formula is less standard because the architecture varies. A good rule is: take the model file size (e.g., 6.5 GB for SDXL) and multiply by 1.5–2 to account for the VAE, text encoder, and activations. So SDXL needs about 10–13 GB.
What If You Don't Have Enough VRAM?
If your GPU has less VRAM than the model needs, you have several options, each with trade-offs:
- Use CPU offloading (e.g., with llama.cpp or Ollama): the model is split between VRAM and system RAM. It works, but generation speed drops dramatically—often 10–50 tokens per second on CPU vs. 100+ on GPU.
- Use smaller quantizations: drop from 8-bit to 4-bit or even 3-bit. Quality degrades, but the model fits. For example, a 13B model in 3-bit needs about 5 GB.
- Reduce context length: if you set the context to 2K instead of 8K, you save 1–2 GB of KV cache.
- Use a smaller model: a 7B model will run on 6 GB, while a 13B model won't. Choose the smallest model that meets your quality bar.
- For image generators: enable "low VRAM" mode (e.g., --medvram or --lowvram in Automatic1111), which offloads parts of the pipeline to CPU. It works but slows generation by 2–3×.
Common Misconception: "More VRAM Always Means Faster"
Many people assume that buying a GPU with more VRAM automatically makes AI generation faster. That's not true. Speed is determined by the GPU's compute throughput (TFLOPS) and memory bandwidth, not just capacity. A 24 GB RTX 3090 is faster than a 24 GB RTX 4090? No—the 4090 is faster. But a 16 GB RTX 4060 Ti may be slower than an 8 GB RTX 4070 for the same model, because the 4070 has more CUDA cores. VRAM only matters when you run out of it; if the model fits, extra VRAM doesn't speed things up. However, having extra VRAM allows you to run larger models or longer contexts, which can indirectly improve quality.
Cost and Hardware Recommendations
Here's what you can expect to spend for different VRAM tiers (prices vary, but these are rough current ranges for new or used GPUs):
- 6–8 GB (RTX 3060, 4060): $200–$400. Good for 7B LLMs and SD 1.5.
- 12 GB (RTX 3060 12GB, 4070): $300–$600. Good for 13B LLMs and SDXL.
- 16 GB (RTX 4060 Ti 16GB, 4080): $400–$800. Good for 30B LLMs with 4-bit and SDXL comfortably.
- 24 GB (RTX 3090, 4090): $800–$2000. Runs 70B LLMs with 4-bit and FLUX.
If you're on a budget, consider used RTX 3060 12GB or RTX 3090 cards—they offer the best VRAM-per-dollar. Avoid cards with less than 6 GB for any serious AI work; they'll struggle even with 7B models.
Frequently Asked Questions
Can I run an LLM without a GPU?
Yes, but slowly. You can run models entirely on CPU using tools like llama.cpp or Ollama. A 7B model in 4-bit will generate about 5–15 tokens per second on a modern 8-core CPU, which is usable for chat but too slow for real-time coding assistance. You also need enough system RAM (at least 8 GB for a 7B model).
Is 8 GB VRAM enough for Stable Diffusion?
Yes, for SD 1.5 and SDXL with optimizations. SD 1.5 runs comfortably in 6 GB. SDXL needs about 8 GB, but you'll have to use --medvram or --lowvram to avoid out-of-memory errors. Generation speed will be slower than on a 12 GB card, but it works.
What does "quantization" mean and does it hurt quality?
Quantization reduces the precision of the model weights (e.g., from 16-bit to 4-bit) to save VRAM. It does degrade quality slightly—the model may produce less accurate or more repetitive outputs—but for most tasks, 4-bit is nearly indistinguishable from full precision. 3-bit and 2-bit show noticeable drops.
Can I use shared GPU memory (Windows) to run bigger models?
Windows has a feature called "Hardware-accelerated GPU scheduling" that can use system RAM as a fallback when VRAM is full. It works, but it's extremely slow because system RAM bandwidth is much lower than VRAM. It's better to use CPU offloading explicitly through the software (like llama.cpp) than to rely on Windows' automatic handling.
Do I need to match VRAM to the model's file size exactly?
No. The file size is the weights only. You also need room for the KV cache and runtime overhead. As a rule, add 20–30% to the file size for a rough VRAM estimate. For example, a 4 GB model file needs about 5–6 GB VRAM.
Is it better to buy a GPU with more VRAM or a faster GPU with less?
If your primary goal is running AI models, prioritize VRAM capacity over raw speed. A slower GPU with 16 GB will run more models than a faster one with 8 GB. For gaming, the opposite is often true. If you do both, look for a balance—like a 12 GB RTX 4070.