Local LLM Deployment: How to Choose Between Four Approaches
Compare four approaches to deploying large language models locally, from beginner-friendly runtimes to high-performance single-GPU inference, multi-GPU deployment, and alternative accelerator stacks. Learn how to choose a model, assess hardware requirements, prepare dependencies, and manage memory usage and inference performance.
Choosing Between Lightweight and Full-Scale Models
Open-source large language models often come in lightweight and full-scale variants. Lightweight versions have fewer parameters or fewer active parameters and can often run on a single consumer GPU. They are suitable for everyday conversations, code completion, and document summarization.
Full-scale versions offer higher inference quality for complex reasoning, multi-step analysis, and high-precision question answering, but require substantially more GPU memory and compute.
Consider three factors when choosing:
- Task complexity: A lightweight model is often sufficient for straightforward tasks.
- Hardware budget: GPU memory is a hard constraint. Estimate memory usage after quantization to determine which model variants are feasible.
- Concurrency: A single-user setup and a shared enterprise service have very different requirements for inference engines and deployment architecture.
For models that use a mixture-of-experts (MoE) architecture, only a subset of expert subnetworks is activated during inference. This reduces computation compared with a dense model of similar total parameter count. However, fewer active parameters do not automatically mean that all model weights require less memory.
Hardware Requirements Before Deployment
Start by checking five hardware characteristics:
- GPU memory capacity
- Supported inference precision, such as FP16, BF16, INT8, and INT4
- System RAM
- Available disk space
- Interconnect bandwidth between GPUs
As a rough starting point, a consumer GPU with 24 GB of memory may be sufficient for a lightweight model under specific conditions: a suitable parameter count, INT4 quantization, and restricted context length and batch size.
A quantized full-scale model typically requires 48 GB or more of GPU memory, or parallel execution across two or four GPUs. These figures are only reference points. Whether a model runs successfully must be tested against its actual size and configuration.
Without a dedicated GPU, CPU inference using system RAM is an option, but generation may be limited to a few tokens per second. This is useful for functional validation rather than regular use.
Reserve disk space equal to at least 1.5 times the model file size to accommodate extraction and verification after downloading.
Preparing the Environment and Downloading Models
Python 3.10 or later is recommended, with a virtual environment to isolate dependencies from the system environment. Core dependencies generally fall into three categories: a deep learning framework, tensor computation libraries, and an inference engine.
Check the compatibility matrix before installing dependencies:
| Component | How to check | Requirement |
|---|---|---|
| Python version | python --version |
Must fall within the inference engine’s supported version range |
| GPU driver | nvidia-smi or the vendor’s utility |
Must meet the compute library’s minimum driver requirement |
| Compute libraries | Check the CUDA, ROCm, or vendor-specific library version | Must match the deep learning framework’s build |
| Deep learning framework | Check the version with pip show |
Must be supported by the inference engine |
| Inference engine | Review the official release documentation | Follow the official compatibility matrix |
Model files are large. Use a download tool that supports resuming interrupted transfers, or enable Git’s large-file extension.
Choose a model-hosting platform that is accessible from your location. Download speeds depend on network conditions and platform limits; a mirror may help where supported.
After downloading, verify the files against the hashes provided by the hosting platform. Corrupted weights can cause loading failures, and the resulting error messages are not always easy to interpret.
Comparing the Four Deployment Approaches
| Approach | Best suited for | Hardware requirements | Concurrency | Deployment complexity | Main risk |
|---|---|---|---|---|---|
| Beginner-friendly local runtime | First-time local LLM users | Low: consumer GPU or CPU-only setup | Low; best for individual use | Low | Limited throughput; unsuitable for public-facing services |
| High-performance single-machine inference | Developers and teams seeking higher throughput and lower latency | Moderate: one GPU with medium-to-high memory capacity | Moderate | Moderate | Incorrect settings can exhaust GPU memory |
| Multi-GPU and distributed deployment | Enterprise workloads with high concurrency | High: multiple GPUs and suitable interconnects | High | High | GPU memory isolation, communication, and operational overhead |
| Full-stack adaptation for Chinese accelerator hardware | Organizations with specific domestic hardware or technology-control requirements | Depends on the accelerator | Depends on hardware and deployment design | Moderate to high | Operator coverage and numerical accuracy require validation |
Approach 1: Beginner-Friendly Local Runtime
Install a ready-to-use local inference runtime, download a model with one command, and start an interactive conversation with another.
More advanced users can adjust context length, thread count, and the proportion of the model offloaded to the GPU through configuration files. The model can also be exposed as a local service for other applications.
If installation goes smoothly, most setup time is spent downloading the model. The duration depends on file size and network speed.
This approach is useful for testing ideas, but its concurrency and throughput are limited.
Approach 2: High-Performance Single-Machine Inference
This approach uses an inference engine that supports continuous batching and paged attention. There are two common ways to use it:
- Offline batch inference in Python: Suitable for data-processing pipelines.
- An API service compatible with common chat interfaces: Existing applications can often connect by changing the service endpoint.
The following example is illustrative pseudocode. engine is a placeholder and must be replaced with the actual package name of your chosen inference engine. Check its official documentation for valid parameter names. The example will not run as written.
from engine import LLM, SamplingParamsllm = LLM(model="local_model_path", tensor_parallel_size=1, dtype="bfloat16")outputs = llm.generate(["Write a quicksort implementation"], SamplingParams(temperature=0.7, max_tokens=512))print(outputs[0].text)
Before running inference, install the selected engine in a clean virtual environment and verify dependencies against the compatibility matrix above.
temperature controls output randomness: higher values generally produce more varied output. max_tokens limits the maximum length of a generated response.
For Chinese accelerator hardware, use a backend adapted by the relevant hardware vendor. Where supported, switching the device configuration and compute backend may leave most inference code unchanged.
Approach 3: Multi-GPU and Distributed Deployment
Tensor parallelism splits model weights across multiple GPUs that work together. The parallelism setting specifies the GPU count; for a two-GPU configuration, set it to 2. The inference engine handles weight partitioning and communication scheduling.
Containerization is recommended for production. Package the inference service as a container image, then use a container orchestration platform for scaling, health checks, and rolling updates. Distribute incoming requests through a load balancer.
Pay particular attention to GPU memory isolation between instances, centralized logging, monitoring, and alerts.
Approach 4: Full-Stack Adaptation for Chinese Accelerator Hardware
This approach is relevant to organizations required to use Chinese accelerator hardware or maintain control over their technology stack. A unified compute framework abstracts hardware differences so that the same inference code can run across supported accelerator types.
The deployment sequence is:
- Install the accelerator drivers and compute libraries.
- Install the unified inference framework.
- Specify the device type and load the model.
- Start the service.
During validation, begin with a single accelerator and compare output accuracy against reference results. Expand to multi-accelerator parallelism only after confirming alignment.
What to Do When GPU Memory Is Insufficient
INT4 or INT8 quantization can substantially reduce GPU memory usage. The reduction depends on the model architecture and quantization method. Compare output quality before and after quantization on your target tasks.
Other options include:
- Shortening the context window
- Reducing batch size
- Offloading some model layers to system RAM
Offloading slows inference, so it requires a trade-off between GPU memory usage and latency.
How to Improve Inference Performance
Continuous batching, speculative decoding, and appropriate sampling settings can improve throughput or latency.
For multi-turn conversations, prefix caching can reduce time to first token, especially when requests include long system prompts or lengthy conversation histories.
For high-concurrency workloads, use request queuing and rate limiting at the gateway layer.
