Running Local LLMs on 8GB VRAM: Model Selection and Deployment Practices

    This article explains how to select and deploy local large language models on devices with 8 GB of VRAM. It covers VRAM estimation for model weights, KV cache, runtime buffers, and system reservations; evaluation criteria including startup cost, throughput, first-token latency, output quality, sustained load, and multimodal overhead; a reproducible benchmarking method with sample Python code; scenario-based model selection; and common configuration pitfalls.

    1. Why Local Model Selection Needs Separate Consideration

    Cloud APIs offer strong models and remove hardware concerns. In many scenarios, however, local deployment still has clear value: sensitive data stays on the device, offline environments can continue working, network fluctuations do not affect response time, and the cost of long-term high-frequency calls is more controllable.

    The main constraint on local devices is usually not compute, but VRAM capacity and VRAM bandwidth. The same model that runs smoothly on a server with ample VRAM may barely load on a laptop with 8 GB of VRAM, and long conversations can quickly exhaust the remaining headroom. Therefore, model selection should first answer two questions: can the model fit stably in VRAM, and after loading, does it meet the interaction experience requirements?

    2. Estimate First: Can the Model Fit in VRAM?

    The VRAM occupied by model weights can be estimated with an approximate formula:

    Weight VRAM ≈ number of parameters × bytes per parameter

    Common numerical precisions correspond to the following byte counts: 16-bit floating point is about 2 bytes, 8-bit integer is about 1 byte, and 4-bit quantization is about 0.5 bytes. For an 8-billion-parameter model, 16-bit precision requires about 16 GB for weights, far exceeding an 8 GB device; with 4-bit quantization, the weights are about 4 GB and can fit. A 4-billion-parameter model is about 2 GB under 4-bit quantization, leaving considerable headroom.

    Weights are only part of the picture. Actual operation also requires the following types of VRAM overhead:

    • KV Cache: the attention cache that stores historical context, with usage growing linearly with context length. When processing long documents, this part is often harder to control than the weights.
    • Runtime buffers: temporary tensors and scheduling overhead used by the inference framework.
    • System reservation: the operating system, display output, and other applications also consume VRAM.

    As a rule of thumb, reserve 20% to 30% headroom for the above overhead; otherwise, VRAM overflow is likely during long outputs or concurrent requests. File size only indicates weight size and does not directly represent peak runtime VRAM usage. During model selection, use monitoring data from actual runs as the basis.

    For devices with 8 GB of VRAM, the following rough judgments can be made:

    • 4-billion-parameter models with 4-bit quantization have ample headroom and are suitable for long-term residency.
    • 8-billion-parameter models with 4-bit quantization can run, but context length and concurrency need to be limited.
    • Multimodal models with a vision encoder have non-negligible additional overhead, and image input also increases context length.

    3. Evaluation Dimensions

    Model selection should not rely on a single metric. It is advisable to build an evaluation table across the following five aspects.

    3.1 Startup Cost

    Startup falls into two cases. Cold start means the model reads weights from disk and loads them into VRAM for the first time; the time depends on storage speed and model size. Warm start means the model is already resident in VRAM, and subsequent requests go directly into inference.

    For interactive tools, cold start determines how long the user waits the first time, while warm start determines how smooth daily use feels. If the tool needs to switch models frequently, cold start becomes the main experience bottleneck; in that case, it is better to keep one or two resident models fixed.

    3.2 Generation Throughput and Time to First Token

    Inference has two stages: prefill, which processes the input, and decode, which generates output token by token. Time to first token is mainly affected by prefill; the longer the input, the longer the wait. Decode speed, that is, tokens generated per second, is mainly limited by VRAM bandwidth when VRAM capacity is sufficient. Therefore, models with fewer parameters and lower-bit quantization usually decode faster.

    Note that decode speed is related to output length. A short classification task may finish in tens of milliseconds, while long-form writing may take tens of seconds; the two should be evaluated with separate criteria.

    3.3 Output Quality

    Quality evaluation should center on actual tasks. Common dimensions include:

    • whether expression in the target language is fluent and word choice is accurate;
    • whether format requirements are strictly followed, such as outputting valid JSON;
    • whether multi-turn instructions continue to be followed;
    • correctness of numerical calculation and logical reasoning.

    Low-bit quantization reduces VRAM usage, but it may have a visible impact on long-text coherence and numerical calculation. Compare results before and after quantization using the same test set.

    3.4 Resource Usage and Sustained Operation

    Laptop devices under prolonged high load may reduce clock frequency due to thermal limits, appearing normal in the first few minutes and then gradually slowing down. Therefore, tests should run continuously for several minutes to observe whether later-stage speed remains stable. At the same time, record peak VRAM usage and power consumption to determine whether other work is affected.

    3.5 Multimodal Capability

    The cost of image understanding consists of two parts: the additional computation of visual encoding, and the increased length caused by visual tokens converted from the image entering the context. The more detailed the description, the longer the output and the higher the latency. In practice, a lightweight multimodal model can be used as the default option, and a larger model can be selected only when detailed descriptions are needed.

    4. Reproducible Testing Method

    A single measurement is easily affected by cache, background processes, and temperature. The following practices are recommended:

    1. Use a fixed prompt set: cover tasks such as short classification, long-document summarization, code generation, structured output, and image description.
    2. Warm up: run once before formal timing and discard the result, avoiding counting loading time in the statistics.
    3. Repeat multiple times and take the median: the median is more resistant to occasional outliers than the average.
    4. Record latency, token count, and peak VRAM together, and compare different models under the same environment and the same parameters.

    Below is a benchmarking example based on a local HTTP interface. Replace the endpoint address and model name with the actual service configuration:

    1. import statistics
    2. import time
    3. import requests
    4. ENDPOINT = "http://127.0.0.1:8000/v1/chat/completions" # Example address; replace with your actual service
    5. PROMPTS = [
    6. "Summarize the topic of the following content in one sentence: This article discusses VRAM estimation methods for local large language models.",
    7. "Write a Python function that calculates the first n terms of the Fibonacci sequence, with brief comments.",
    8. ]
    9. def run_once(model: str, prompt: str) -> dict:
    10. payload = {
    11. "model": model,
    12. "messages": [{"role": "user", "content": prompt}],
    13. "max_tokens": 512,
    14. "stream": False,
    15. }
    16. start = time.perf_counter()
    17. resp = requests.post(ENDPOINT, json=payload, timeout=300)
    18. resp.raise_for_status()
    19. elapsed = time.perf_counter() - start
    20. usage = resp.json().get("usage", {})
    21. completion_tokens = usage.get("completion_tokens", 0) # If the service does not return usage, count tokens manually
    22. return {
    23. "latency_s": elapsed,
    24. "tokens": completion_tokens,
    25. "tokens_per_s": completion_tokens / elapsed if elapsed > 0 else 0.0,
    26. }
    27. def benchmark(model: str, rounds: int = 5) -> dict:
    28. run_once(model, PROMPTS[0]) # Warm-up; discard the result
    29. results = [run_once(model, p) for _ in range(rounds) for p in PROMPTS]
    30. return {
    31. "model": model,
    32. "median_latency_s": statistics.median(r["latency_s"] for r in results),
    33. "median_tokens_per_s": statistics.median(r["tokens_per_s"] for r in results),
    34. }
    35. if __name__ == "__main__":
    36. print(benchmark("your-model-name"))

    This script measures end-to-end elapsed time, including network and serialization overhead. For local services, this part is usually small, but if it is used to compare different server implementations, the calling method should remain consistent.

    5. Scenario-Based Selection

    The core of model selection is matching model capability to task requirements, rather than pursuing parameter scale for its own sake.

    • Lightweight tasks: classification, tagging, title generation, and short-text rewriting. These tasks produce short outputs and are sensitive to time to first token, making small models suitable; they can also serve as front-end nodes in a pipeline.
    • General Chinese conversation and writing: these require good instruction following and expression stability. Medium-sized models are usually a more balanced choice and are recommended as the local default model.
    • Complex reasoning and code generation: these have higher requirements for parameter scale and context length. With 8 GB of VRAM, it may be necessary to accept slower speed or route complex requests to larger models or cloud services.
    • Image understanding: suitable for multimodal models. If only text recognition or rough confirmation of image content is needed, a small model is sufficient; for fine-grained explanations or complex chart analysis, call a larger model.
    • Long-document processing: prioritize controlling context length and use chunked summarization followed by aggregation, avoiding KV Cache occupying VRAM for long periods.

    6. Common Pitfalls

    Incorrect chat template and stop token configuration. Models have specific requirements for input format. Incorrect role markers and stop tokens can cause output truncation, role confusion, or endless continuation. Use the template provided by the model publisher instead of manually concatenating strings.

    Inference mode not set according to the task. Some models support enabling or disabling reasoning process output. When enabled, output becomes longer and latency increases; for simple tasks, this may not provide real benefits.