A Practical Guide to Hardware for Running LLMs Locally

    Learn how to choose hardware for local LLM deployment by starting with model size, quantization, and context length. This guide covers VRAM estimation, KV cache overhead, tiered GPU recommendations, supporting components, and when to switch to cloud compute.

    1. Start With the Model, Not the GPU

    The most common mistake in local deployment is picking a GPU first and then looking for a model to fit it. The correct order is the reverse: define the model size, target precision, and context length first, estimate the VRAM requirement, and only then decide which card to buy.

    A rough but useful rule is:

    1. VRAM usage ≈ weight size + KV cache + runtime overhead

    Weight size is roughly the parameter count multiplied by the bytes per parameter: 2 bytes for FP16/BF16, about 1 byte for 8-bit quantization, and about 0.5 bytes for 4-bit quantization. For a 27 billion parameter model, the BF16 weights take about 54GB, 8-bit about 27GB, and 4-bit about 13.5GB. In other words, running 4-bit on a 16GB card is already tight, and 8-bit on a 32GB card is only barely enough.

    The part that is easy to overlook is the KV cache. It grows linearly with context length, and in long-context scenarios it often determines whether you run out of VRAM more than the weights themselves do. So “is there enough VRAM” is never a static answer. It is a joint function of model size, quantization precision, context length, and concurrency.

    2. VRAM and Quantization: The Cost Behind Precision

    The quality ranking widely accepted in the industry is roughly: full precision > 8-bit float ≈ high-quality low-bit quantization > aggressive low-bit quantization. One key observation worth generalizing is that different quantization schemes vary enormously in how many tokens they consume to complete the same task. Low-quality quantization often needs longer outputs to probe and correct itself, ultimately paying back the saved VRAM in the form of inference cost.

    This leads to an important practical principle: do not just ask whether a model runs, ask how many tokens it takes to converge. When evaluating a quantization scheme, fix the same task set and the same sampling parameters, and record three metrics:

    1. Metric 1: Task success rate (whether the output is correct and usable)
    2. Metric 2: Average tokens consumed per task (including retries)
    3. Metric 3: Time to first token and output tokens per second

    If a 4-bit scheme lowers the success rate and multiplies token consumption, it is actually more expensive in total cost. A more reasonable choice is then a larger-VRAM card running 8-bit, or a shorter context with retrieval enabled to split long documents into smaller chunks.

    Entry-level single GPU (around 16GB VRAM): suitable for 4-bit quantization of 7 billion to 14 billion parameter models, with context kept to a few thousand tokens, for light tasks such as code completion, text rewriting, and structured extraction. The advantages are low cost and simple deployment; the limitation is that long documents and long multi-turn conversations can easily trigger VRAM overflow.

    Mainstream single GPU (around 32GB VRAM): can run 8-bit quantization of 20 billion to 30 billion parameter models, or 4-bit quantization of larger models. Context can be pushed to the ten-thousand token range, but this needs to be tested in practice. This is currently the most balanced tier in terms of value for personal experimentation.

    Multi-GPU and multi-machine: when a single card does not have enough VRAM, tensor parallelism or pipeline parallelism can split the model across multiple cards. A single machine with multiple cards is limited by inter-card interconnect bandwidth, while scaling across machines is more sensitive to network bandwidth and latency, and communication overhead can significantly reduce throughput. Multi-machine setups are therefore better suited to scenarios where VRAM is insufficient but lower throughput is acceptable, rather than high-concurrency online serving.

    On platform choice, personal experimentation should prioritize general-purpose GPUs with a mature ecosystem and well-supported drivers and inference frameworks, avoiding the hidden costs of niche accelerators such as missing operators, incomplete quantization support, and lagging framework compatibility.

    4. Supporting Components That Are Often Underestimated

    CPU and memory: memory capacity should be no less than 1.5 to 2 times the VRAM, used for weight loading, shard caching, and paging. Memory bandwidth directly affects model loading speed and performance in some offloading scenarios.

    Storage: model weights can easily reach tens of gigabytes, so a dedicated SSD for the model library is recommended. Sequential read speed determines the cold-start experience.

    Power and cooling: high-load inference is a sustained full-load scenario. Leave more than 30% headroom in power supply capacity, and good chassis airflow is more effective than simply adding fans.

    Software stack: keep inference framework versions, quantization formats, and sampling parameters consistent, and write the configuration into a reproducible config file to avoid the “it runs on one machine but not another” problem.

    1. # Example: pin key variables in a reproducible config
    2. model: <local model path>
    3. quantization: <8bit|4bit>
    4. context_length: 8192
    5. tensor_parallel_size: 1
    6. sampling: {temperature: 0.2, top_p: 0.9}

    5. When Not to Keep Adding Hardware

    If the requirement is multi-user concurrency, stable online availability, and elastic scaling, the marginal cost of a local multi-machine setup will quickly exceed that of the cloud. A more pragmatic choice is to use general-purpose cloud compute: GPU cloud hosts for a self-managed environment, container platforms for elastic scaling, and object storage to host models and datasets, together with monitoring, alerting, and logging services to locate performance bottlenecks. Baidu AI Cloud offers corresponding capabilities in these general categories and they can be combined as needed, avoiding a one-time heavy capital investment.

    6. Deployment Checklist

    1. Define model size, precision, and context first, then choose the card.
    2. Evaluate quantization schemes on a real task set, looking at token consumption rather than only whether it starts.
    3. Reserve more than 20% of VRAM for the KV cache and fragmentation.
    4. Test network bandwidth before scaling to multiple machines, and confirm communication is not the bottleneck.
    5. Put the environment, quantization format, and sampling parameters into configuration to ensure reproducibility.
    6. Switch to elastic cloud compute in time when concurrency and stability requirements increase.