Local LLM Deployment Guide: Model Selection, GPU Memory Estimation, and Implementation

    Choosing a model for local deployment is often treated as picking from a leaderboard, but it is really an engineering decision. This article explains how to build a selection framework around business goals, estimate GPU memory including weights and KV cache, and move from a working prototype to an observable, rate-limited, and updatable service. It also covers quantization trade-offs, deployment configuration, load testing, monitoring, and scenario-specific guidance for knowledge QA, long-document processing, code assistance, and multimodal workloads.

    Questions like “Which large language models can I deploy locally?” are often framed as requests for a model list, but the real problem is systems engineering. The deciding factor is usually not which model name is trending. It is whether the team has a reliable way to discover and evaluate models, assess hardware constraints, and manage deployment operations. This article does not recommend a specific vendor or model product. Instead, it breaks the problem into three core parts: how to keep finding models worth evaluating, how to determine whether local hardware is sufficient, and how to move quickly from an experimental run to a production-ready service.

    1. Build the Selection Framework First — Don’t Start from a Leaderboard

    The first step is not to open a model catalog and try every option. Define business goals and constraints first, because requirements vary significantly by task:

    • Knowledge QA depends on retrieval-augmented context understanding and factual consistency.
    • Code assistance depends on completion quality and low latency.
    • Document summarization depends on long-context support and stability.
    • Multimodal tasks add preprocessing overhead and additional GPU memory demand for image or audio input/output.

    Without a well-defined business target, comparing parameter counts or public benchmark scores can lead to two common outcomes: a model that scores well but cannot be run with local resources, or a model that can run but does not satisfy the actual business requirement.

    A lightweight selection matrix is useful. It should cover at least the following dimensions:

    Dimension Suggested weight Key questions
    Task fit 30% Does the model support the required language, domain, context length, and modalities?
    Resource cost 25% Are GPU memory, system memory, storage, power, and concurrency costs acceptable?
    License and compliance 20% Does the license allow commercial use, redistribution, auditing, and local isolation?
    Runtime compatibility 15% Does it support common quantization methods, containerization, and service packaging?
    Operational maturity 10% Are logging, monitoring, upgrades, and failure recovery manageable?

    This matrix should be updated continuously as business feedback changes. Pay attention to model release cadence, weight file integrity, tokenizer and configuration completeness, trusted sources for quantized versions, and the maximum context limit supported by the runtime. Many deployment failures are not caused by model capability; they are caused by mismatched weight formats, configuration parameters, quantization precision, or runtime compatibility.

    For information gathering, prioritize official model documentation, technical reports, license text, and model cards. Cross-check those sources with model hosting platforms, open-source communities, and industry technical approaches. Do not rely on a single leaderboard, and do not assume that a larger parameter count means better results. A more reliable approach is to prepare a small business evaluation set with real questions, realistic input lengths, and realistic concurrency, then compare models on that set.

    2. Hardware Resource Evaluation: The VRAM Formula Is Only a Starting Point

    GPU memory is usually the core bottleneck for local LLM deployment, but it is not the only constraint. The assessment should also cover system memory, local storage, CPU preprocessing capability, multi-GPU interconnect bandwidth, and the target concurrency of the inference service.

    A common rule of thumb for weight memory is:

    Model weight GPU memory (GB) ≈ parameter count (in billions) × bytes per parameter

    At FP16/BF16 precision, each parameter uses about 2 bytes, so a 7B model needs about 14GB for weights, a 13B model about 26GB, and a 70B model about 140GB. With 8-bit quantization, the estimate is roughly 1GB per billion parameters; with 4-bit quantization, roughly 0.5GB per billion parameters.

    This formula is useful for initial screening, but it only covers weights. It does not include KV cache, activations, temporary buffers, inference runtime overhead, or GPU memory fragmentation. A more complete estimate is:

    Inference GPU memory ≈ weight memory + KV cache + activations/temp buffers + runtime overhead + safety margin

    KV cache can be approximated as:

    KV cache ≈ 2 × batch size × sequence length × number of layers × hidden dimension × bytes per element

    For example, a 7B-class model with 32 layers and a hidden dimension of 4096, running in FP16 with batch size 1 and an 8192-token context, has a theoretical KV cache of roughly 4GB. When concurrency increases or the context length doubles, KV cache grows quickly. Therefore, the fact that model weights fit into GPU memory does not guarantee that the service will run stably. Reserve 20–40% of GPU memory as headroom for long requests and traffic bursts.

    System memory should at least cover weight loading, preprocessing, and cache requirements. Local storage should account for weight file size, the number of quantized versions, and loading speed. Multi-GPU deployments also need to consider interconnect overhead. For scenarios that require fast cold starts, high-speed local storage and a deliberate model caching strategy can significantly improve the experience.

    Quantization is an important way to lower the resource barrier, but it is not free. 8-bit and 4-bit weight quantization can significantly reduce weight memory, and KV cache quantization can further compress long-context costs. However, these approaches may introduce accuracy loss, compatibility issues, and additional calibration work. Compare quantized and non-quantized versions on the business evaluation set, and record time-to-first-token, per-token latency, throughput, and peak GPU memory. If the business is highly sensitive to factual consistency, code correctness, or long-document details, be cautious about aggressive quantization.

    3. Fast Deployment: From “It Runs” to “It Is a Service”

    Fast deployment is not simply starting a process. It means turning the model into a service that can be observed, rate-limited, and upgraded. The following steps are a practical path:

    1. Baseline the environment. Pin the driver version, runtime version, container image, and dependency versions. Containerization reduces environment differences, but GPU mounts, shared memory, model directories, and log directories still need to be explicit.
    2. Prepare the model. Validate weight file integrity. Confirm that the configuration, tokenizer, quantization parameters, and license information are present. Store model files in a dedicated directory and use read-only mounts or object storage distribution to reduce accidental modification.
    3. Wrap the service. Expose a stable API interface with authentication, rate limiting, timeouts, request queues, and error codes. Set a maximum input length and a timeout policy for long-context requests so that one request cannot bring down the whole service.
    4. Tune parameters. Set maximum context length, batch size, concurrency, GPU memory utilization, and KV cache policy. Do not consume all GPU memory; keep headroom for recovery and burst traffic.
    5. Load test and monitor. Collect time-to-first-token, per-token latency, throughput, peak GPU memory, request queue time, error rate, and GPU memory overflow count. Set alerts on these metrics.
    6. Use canary releases and rollback. Test a new model or a new quantization version on a small share of traffic, and keep the previous version available for rollback.

    The following is a neutral deployment configuration example. The point is the parameter structure, not a specific tool:

    1. model:
    2. path: /models/local-model
    3. precision: int4
    4. max_context: 8192
    5. runtime:
    6. max_batch_size: 8
    7. max_concurrency: 16
    8. gpu_memory_fraction: 0.9
    9. enable_kv_cache_quant: true
    10. service:
    11. request_timeout_ms: 30000
    12. max_input_tokens: 6144
    13. rate_limit_per_minute: 120

    Each parameter should correspond to a business objective: maximum context determines long-document capability; batch size and concurrency determine throughput and peak GPU memory; GPU memory utilization determines the stability boundary; timeout and rate-limiting determine fault isolation. In deployment, load testing should be used to find the working point where latency is acceptable, GPU memory does not overflow, and the error rate is controlled.

    At the engineering layer, generic container platforms, object storage, logging services, and monitoring/alerting capabilities can handle model distribution, runtime observation, and troubleshooting. Cloud providers such as Baidu AI Cloud offer these categories, but the design should still be driven by local resources, data isolation, and service objectives—not by the goal of simply getting a deployment to succeed.

    4. Scenario-Specific Recommendations

    For individual developers and small teams, interaction experience and cost are usually the main concerns. Quantized 7B–13B models are a reasonable starting point on a single GPU or a small number of professional GPUs. If GPU memory is limited, prioritize controlling context length and concurrency instead of pursuing larger parameter counts.

    For enterprise teams that serve many concurrent users or production workloads, include GPU memory headroom, monitoring and alerts, rate limiting and circuit breaking, and canary releases in the initial plan. Multi-GPU parallelism or a “smaller model + retrieval-augmented generation” combination may be necessary.

    For knowledge base QA, start with a small-to-medium model plus retrieval-augmented generation and a business evaluation set. Validate retrieval quality and answer consistency before deciding whether to upgrade the model. For long-document processing, focus on context length, KV cache cost, and stability under long requests. For code assistance, focus on completion latency and local data isolation. For multimodal workloads, reserve preprocessing and postprocessing resources as part of the deployment plan.

    Ultimately, a recommendation for local LLM deployment should not be a static model list. It should be a repeatable decision process: clarify business goals, build a selection matrix, cross-check model information, use the GPU memory formula for initial screening, use load testing and monitoring to calibrate resource boundaries, and then use containerization, service wrapping, and canary/rollback to complete the engineering loop. Only when selection, evaluation, deployment, observation, and optimization form a closed loop can a team remain stable and controllable in a fast-changing technical environment.