Smart Systems for Home

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

Sizing VRAM, RAM & Storage for Local AI Inference

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To run a large language model (LLM) or image generator locally, you need enough VRAM (video memory) to hold the model weights, enough system RAM for the operating system and data shuffling, and enough storage for the model files and swap space. This guide walks you through calculating each, with practical rules of thumb and common pitfalls.

What You'll Need

  • The model you plan to run (name and parameter count, e.g., "7B" or "70B").
  • The precision you intend to use (e.g., FP16, INT8, INT4). If unsure, default to FP16 for quality or INT4 for lower VRAM.
  • Your GPU's VRAM capacity (check in Task Manager > Performance > GPU, or use nvidia-smi on Windows/Linux).
  • Your system RAM total (Task Manager > Performance > Memory).
  • Free storage space on your drive.

Step-by-Step

  1. Find the model's parameter count. This is usually in the model card on Hugging Face or the project's README. Common sizes: 1B, 3B, 7B, 13B, 30B, 70B.
  2. Calculate the model file size at full precision (FP16). Multiply the parameter count by 2 bytes (since FP16 uses 2 bytes per parameter). For example, a 7B model = 7,000,000,000 × 2 = 14 GB. A 70B model = 140 GB.
  3. Adjust for quantization. If using INT8 (8-bit), divide by 2 (so 7B → 7 GB). If using INT4 (4-bit), divide by 4 (7B → 3.5 GB). These are approximate; actual sizes may vary slightly.
  4. Add overhead for inference. The model weights are not the only VRAM consumer. You need extra for activations, KV cache, and CUDA context. A safe rule: add 20–30% of the model size, or at least 1–2 GB. For a 7B FP16 (14 GB), plan for ~17–18 GB VRAM. For a 7B INT4 (3.5 GB), plan for ~5–6 GB.
  5. Check if your GPU fits. If the total (model + overhead) is less than your GPU's VRAM, you're good. If not, you have options: use a smaller model, quantize more aggressively, or offload layers to system RAM (see step 7).
  6. If offloading, size your system RAM. When the model doesn't fit in VRAM, inference tools like llama.cpp or Hugging Face's accelerate can place some layers in system RAM. The model file still needs to fit in RAM (plus a few GB for the OS). So for a 70B FP16 (140 GB), you'd need at least 140 GB RAM, plus ~8–16 GB for the OS and other apps. For a 13B INT4 (6.5 GB), you could run with 16 GB RAM total.
  7. Size your storage. The model files themselves take up disk space equal to the quantized size. A 7B FP16 is ~14 GB; a 70B INT4 is ~35 GB. But also consider your swap file (pagefile on Windows) – if you run out of RAM, Windows will use disk as virtual memory, so having 50–100 GB free is wise for large models. Also, if you download multiple models, plan for that.
  8. Test with a small model first. If you're new, start with a 1–3B model (like Qwen2.5-1.5B or Phi-3-mini) to verify your setup before downloading a 70B behemoth.

Common Mistakes

  • Forgetting overhead. People think a 7B FP16 (14 GB) fits in a 16 GB GPU, but it doesn't because of the extra memory needed for the inference process. You'll get out-of-memory errors.
  • Using FP16 when you could use INT4. If you're tight on VRAM, quantizing to INT4 can cut memory usage by 75% with only a slight quality drop. Many people unnecessarily buy bigger GPUs.
  • Ignoring system RAM when offloading. If you offload to CPU, the model must fit in RAM. A 70B model won't run on a 32 GB RAM system even with a 24 GB GPU.
  • Not accounting for context length. The KV cache grows with the number of tokens you process. A long context (e.g., 32k tokens) can add several GB of VRAM. Check your tool's documentation for how to estimate this.
  • Assuming all models are the same size. A 7B model from one company may have a slightly different architecture (e.g., more layers) that affects size. Always check the actual file size on the download page.

Tips

  • Use a tool that auto-detects VRAM. Ollama, LM Studio, and llama.cpp can often tell you if a model fits before you download it.
  • Prefer INT4 for most local use. The quality difference from FP16 is often imperceptible for chat, and it lets you run larger models on modest hardware.
  • Keep your GPU drivers up to date. Newer drivers can improve memory efficiency and performance.
  • Close other GPU apps. Browsers, video players, and other software can consume VRAM. Close them before running inference.
  • Use a fast SSD. If you're offloading to system RAM, the model loads from disk each time. An NVMe SSD will cut load times significantly.

Troubleshooting

Out-of-memory (OOM) error during inference. This means your VRAM (or RAM if offloading) is insufficient. Reduce the context length, lower the batch size, or try a more aggressive quantization. If using llama.cpp, add --n-gpu-layers to offload more to CPU.

Model loads but runs very slowly. If you're offloading to CPU, expect 10–50x slower than GPU. Check your CPU's RAM speed and consider using a smaller model or more GPU layers.

System becomes unresponsive. This often happens when Windows uses the pagefile heavily because RAM is full. Close other apps, or increase your pagefile size (but this is a band-aid; you really need more RAM).

Model fails to load with a "CUDA out of memory" error. Even if the model fits, the CUDA context needs a few hundred MB. Try reducing the number of GPU layers by 1 or 2.

Downloaded model doesn't match expected size. Check if the model is in a different format (e.g., safetensors vs. bin) or if it includes additional files like tokenizers. The actual weights are usually the bulk of the size.

Frequently Asked Questions

How much VRAM do I need for a 7B model?

At FP16, you need about 17–18 GB VRAM (14 GB weights + overhead). At INT4, about 5–6 GB. If your GPU has 8 GB, you can run a 7B INT4 with some offloading.

Can I run a 70B model on a 24 GB GPU?

Yes, but only with heavy quantization (INT4 or INT3) and possibly offloading some layers to CPU. A 70B INT4 is about 35 GB, so it won't fit in 24 GB VRAM alone; you'll need at least 16 GB of system RAM to offload the rest.

Is system RAM as fast as VRAM?

No. System RAM (DDR4/DDR5) is much slower than GDDR6/HBM. Offloading to RAM will slow inference significantly. It's a fallback, not a performance solution.

How much storage do I need for local AI?

For one or two 7B models, 20–50 GB is enough. For a collection of 70B models, plan for 200+ GB. Always have at least 50 GB free for swap and temporary files.

What is the difference between VRAM and RAM for AI?

VRAM is on your graphics card and is used for the model's weights and computations. System RAM is used for the operating system, loading the model initially, and offloading if VRAM is insufficient. For best performance, the model should fit in VRAM.

Can I use integrated graphics (iGPU) for AI inference?

Yes, but it's slow. Integrated GPUs share system RAM, so you're limited by RAM speed and capacity. A 7B INT4 model might run, but expect very slow token generation.