Running LLMs Locally with a 12GB GPU: VRAM Estimation and Quantization Trade-offs
This article explains how to determine whether a large language model can run on a 12GB GPU. It covers the VRAM calculation formula, practical model size recommendations, and the trade-offs between Q4_K_M and Q6_K quantization formats, along with the cost of longer context windows.
Step 1: Estimate VRAM Before Choosing a Model
When deploying a model locally, VRAM is the first constraint. The model weights must fit into VRAM as a whole for inference to proceed at a reasonable speed. Therefore, the first step in selecting a model is to estimate the weight size.
A rough formula for weight memory usage is as follows:
Weight VRAM (GB) ≈ Number of parameters (B) × Average bits per weight ÷ 8
In practice, you also need to account for the KV cache and inference framework overhead, so it is generally wise to reserve 10–20% additional headroom. For GGUF format, Q4_K_M averages about 4.8 bits per weight, while Q6_K averages about 6.6 bits. Based on this formula, the approximate weight sizes for three common model classes are (these are estimates only; always refer to the model page for the actual file size):
| Model Scale | Approx. Q4_K_M Weight | Approx. Q6_K Weight | Relationship with 12GB VRAM |
|---|---|---|---|
| 9B Dense | 5.4GB | 7.4GB | Fits entirely, leaving room for KV cache |
| 27B Dense | 16.2GB | 22.3GB | Q4_K_M already exceeds 12GB; requires offloading |
| 35B MoE (total params) | 21GB | 28.9GB | Requires offloading most of the weights |
As the table shows, 12GB of VRAM can comfortably hold a 9B-class model in its entirety. For a 27B dense model, even Q4_K_M quantization brings the weight size beyond 12GB, and a 35B MoE model has even larger total weights. These larger models can only run with part of their weights offloaded to system RAM, which will slow down generation.
Step 2: What Can Run on a 12GB GPU
7B to 9B dense models are the safest choice for a 12GB GPU. The weights can stay entirely in VRAM, leaving enough space for a medium-length context window. Both Q4_K_M and Q6_K fit within the available memory; the choice comes down to your preference for quality versus speed.
27B dense models on a 12GB GPU require placing a substantial portion of the layers in system RAM. When layers reside in RAM, generation speed often drops considerably, because every generated token requires data to be moved between VRAM and RAM, and memory bandwidth is far lower than VRAM bandwidth. For interactive use, this is not usually an ideal setup.
35B-class MoE models present a different scenario. MoE models have a large total parameter count, but only a small subset of experts is activated for each inference step. At deployment time, you can keep the attention layers and shared weights in VRAM while offloading most of the expert weights to system RAM. Recent versions of llama.cpp provide related offloading parameters; please check the documentation for your specific version for the exact names and usage. This approach allows such a model to run on a 12GB GPU, but the speed depends on your system RAM capacity, memory bandwidth, and CPU performance. It cannot be predicted in advance and must be benchmarked on your own hardware.
Step 3: Quantization: Q6_K or Q4_K_M
Quantization represents weights with fewer bits in order to reduce the model size and VRAM footprint. In GGUF format, Q6_K and Q4_K_M are two commonly used levels.
- Q6_K: Produces larger files and consumes more VRAM, but it usually stays closer to the quality of the original weights.
- Q4_K_M: Produces significantly smaller files, allowing you to fit a larger model into the same memory or leave more space for the context.
The quality difference between the two varies by task. For simple Q&A and routine rewriting, the difference is often negligible. For complex reasoning, code generation, or tasks that require precise reproduction of the input, the gap may be more noticeable. The most reliable way to decide is to run a batch of samples from your own real tasks through both formats and compare the outputs, rather than relying on subjective opinions.
In terms of speed, smaller files mean fewer bytes to read from VRAM per token, so Q4_K_M is generally faster when VRAM bandwidth is the bottleneck. This outcome, however, depends on the specific model, the inference backend, and the offloading ratio, so it also needs to be tested in practice.
Step 4: The Cost of Context Length
The longer the context, the larger the KV
