Running Large Language Models Locally: A Complete Guide to VRAM and RAM Configuration

    This guide explains why published model sizes often differ from real-world VRAM requirements. It breaks down memory usage into model weights, KV cache, activations, and framework overhead; explains how parameter count and precision affect the minimum memory footprint; compares INT4 and INT8 quantization; provides rough requirements by model size and GPU memory tier; and offers practical guidance for unified-memory devices, context length, and deployment tuning.

    Why VRAM Estimates Often Do Not Match Reality

    Many developers encounter the same issue when running large language models locally: the weight size published by a model provider is one thing, but whether the model runs reliably is another. The reason is straightforward. Official figures usually represent the theoretical footprint of model weights in a specific precision. Real-world feasibility depends on additional factors, including runtime overhead, context caching, and the management costs of the inference engine. By separating these components, VRAM requirements can move from guesswork to a calculable estimate.

    Four Main Sources of VRAM Usage

    The memory used during a single inference task—whether dedicated VRAM or unified memory—can be roughly divided into four parts:

    1. Model weights: The main component. Its size is approximately the number of parameters multiplied by the number of bytes per parameter.
    2. KV cache: Strongly correlated with context length and batch size. It can become significantly larger with long-context workloads.
    3. Activations and intermediate tensors: These fluctuate with sequence length and parallelism. Peak usage often occurs in the middle stages of forward computation.
    4. Framework and fragmentation overhead: Fixed or semi-fixed costs from the inference runtime, operator caching, memory reservation, and similar sources.

    Focusing only on model weights is the root cause of most failed estimates. A more robust approach is to calculate the minimum weight requirement first, then leave enough headroom for the remaining three components.

    Parameter Count and Precision: The Hard Floor for Weights

    The VRAM required by model weights can be approximated with a simple formula:

    1. weight VRAM ≈ number of parameters × bytes per parameter

    Common precision levels correspond to the following approximate byte usage:

    Precision Bytes per parameter Approximate usage for 1B parameters
    BF16 / FP16 2 bytes about 2 GB
    INT8 1 byte about 1 GB
    INT4 0.5 bytes about 0.5 GB

    For example, a 7B-parameter model requires approximately 14 GB in BF16, 7 GB in INT8, and 3.5 GB in INT4. However, these are only theoretical lower bounds for the weights themselves. In practice, you still need to reserve space for the KV cache and runtime overhead. As a practical starting point, after INT4 quantization, it is usually safer to reserve an additional 20%–40% of the weight size for runtime space.

    Quantization: Trading Quality for Space

    Quantization is a technique for compressing floating-point weights into lower-bit representations. Common formats include INT8, INT4, and more aggressive variants. Its value is that it can roughly halve the weight footprint or reduce it to about one quarter, making models that would otherwise exceed available memory runnable.

    However, quantization is not free:

    • Quality loss: The lower the bit count, the coarser the numerical representation. The impact is more noticeable in scenarios that require precise reasoning, code generation, or mathematical computation.
    • Dequantization overhead: Some inference engines still compute internally at higher precision. Quantization primarily saves memory and bandwidth; it does not necessarily improve speed proportionally.
    • Format compatibility: Different quantization formats have different alignment schemes and group granularities, and inference frameworks support them to varying degrees.

    A practical recommendation is to compare INT4 and INT8 first. In many cases, INT4 is acceptable in terms of quality while reducing memory requirements by half, making it a cost-effective choice on limited hardware.

    VRAM Requirements by Model Size

    The table below compares common parameter sizes with approximate memory usage after quantization. These figures refer only to weights plus typical runtime headroom, not extremely long contexts.

    Parameter size Approximate usage with INT4 quantization Suggested VRAM/RAM starting point Typical use case
    About 2B–4B lightweight 2–4 GB Start with at least 6 GB Validating a minimal working setup, edge devices, or low-spec machines
    About 7B medium 4–6 GB 8–12 GB for a more comfortable experience A common first local experience for most users
    About 13B medium-large 8–10 GB 12–16 GB Better inference quality without using the heaviest models
    About 26B–32B large 16–20 GB 24 GB or more Quality-focused work, code, and long-context use

    These numbers are estimated ranges for comparison, not absolute guarantees. Actual usage will vary depending on context length, batch size, and the inference framework.

    Choosing Hardware by GPU Memory Tier

    Around 6 GB of VRAM: Start with lightweight models in the roughly 2B–4B range. Medium or large models may be possible in some cases, but choosing a large model as the default starting point often causes an out-of-memory error during loading.

    8–12 GB of VRAM: Lightweight models run comfortably, and medium-sized models around 7B are feasible with INT4. Pay attention to KV cache growth caused by context length, and avoid configuring systems right at the limit.

    12–16 GB of VRAM: Medium-to-large models around 13B become practical for serious experimentation. Being able to load a model does not necessarily mean stable inference. It is better to monitor actual generation speed rather than relying only on nominal specifications.

    24 GB or more VRAM: Larger models around 26B–32B are worth testing after quantization. However, the VRAM table is only a reference. Long contexts can still significantly increase memory usage, so leaving a buffer remains necessary.

    How to Evaluate Unified Memory Devices

    For devices with a unified memory architecture, such as laptops with integrated memory or mobile workstations, the evaluation logic differs from that of dedicated GPUs. They share memory, so both weights and runtime data occupy the same memory pool. Two factors are especially important:

    • Total available memory: The operating system and other applications consume part of the memory. You should leave a safety margin for the memory that can actually be allocated to the model, often around 20% of total memory for the system.
    • Memory bandwidth: This is a key bottleneck. Large language model inference is often memory-bandwidth-bound, meaning the bottleneck is frequently not compute capacity but the speed at which weights are moved from memory into compute units. More memory does not necessarily mean faster inference. Insufficient bandwidth can leave large models runnable but slow.

    A practical evaluation order is: first check whether the model fits in memory capacity, then check whether it can run fast enough based on memory bandwidth, and finally adjust context length to balance quality and speed.

    Context Length: The Most Easily Overlooked Variable

    Many people only look at model weight size but ignore the fact that the KV cache can grow linearly—or even faster—with context length. Tasks such as long conversations or long-document summarization may consume several gigabytes of VRAM for the KV cache alone, enough to break a configuration that otherwise seemed to fit. Common mitigation approaches include limiting the maximum context length, using inference methods with cache compression or sliding-window mechanisms, and reserving extra memory for long-running tasks.

    Practical Tuning Advice

    • Validate on a small model before moving to a large one: First run the full pipeline with a lightweight model and confirm that the inference framework, drivers, and quantization format all work correctly. Then gradually switch to larger models.
    • Monitor memory usage in real time: Observe the VRAM or memory usage curve during inference, identify when peaks occur, and avoid overflow in the middle of long tasks.
    • Start with a conservative context length: Begin with a shorter context to confirm stability, then increase it as needed instead of maximizing it immediately.
    • Compare quantized versions: Run the same model with both INT4 and INT8, weigh quality against memory usage, and choose the most efficient configuration acceptable for your use case.

    If local hardware is limited, you can also run heavy models in the cloud. Cloud platforms provide elastic compute capacity, pay-as-you-go inference services, and containerized deployment capabilities, avoiding the cost of purchasing high-VRAM GPUs. This is especially suitable for workloads with highly variable demand or long-context requirements.

    Summary

    Memory planning for local large language model deployment is essentially based on two steps: use parameter count and precision to determine the minimum weight requirement, then add context and runtime overhead to determine a safe memory margin. Once you understand these four layers, you can convert an official theoretical figure that is “for reference only” into a practical configuration plan for your own machine. With a small amount of VRAM, start with lightweight models; with medium VRAM, use INT4 to trade quality for space; with large VRAM, pursue larger models and long contexts; and for unified memory devices, prioritize memory bandwidth. Following this logic when selecting models and hardware will help you avoid the common pitfall of being able to load a model but not run it smoothly.