Local Deployment Guide for Open-Source LLMs: Four Options Matched to Scale
This guide explains how to decide between API usage and local deployment of open-source LLMs, and how to pick among four deployment options based on team size and workload. It covers pre-deployment evaluation (VRAM, context length, concurrency and latency), detailed configurations for a single 24GB GPU, multi-GPU workstations, inference clusters, and hybrid cloud setups, plus cost-comparison formulas, a decision table, and an OOM troubleshooting checklist.
1. Do the Math First: When Does Local Deployment Pay Off
APIs bill per token, so the invoice grows quickly as call volume increases. A business handling tens of millions of tokens per day can face a monthly bill in the tens of thousands of yuan. Local deployment splits cost into two parts: a one-time hardware investment, plus ongoing electricity, operations, and depreciation. The higher the call volume, the lower the fixed cost amortized per token.
Four scenarios mainly favor local deployment:
- High-frequency calls: intelligent customer service, code assistants, batch document processing.
- Data compliance: industries such as finance, healthcare, and government require sensitive data to stay within their own domain.
- Customization needs: RAG with private knowledge bases, fine-tuning, or agent orchestration.
- Service control: avoiding third-party rate limits and quota fluctuations that affect business.
If daily usage is only a few hundred thousand tokens, APIs are usually the more convenient choice. The formulas in Section 4 can help you find the break-even point.
The prices mentioned in this article are rough ranges for the Chinese market, estimated with tax and excluding datacenter modifications and displays. Prices fluctuate with market conditions—always confirm actual quotes before ordering.
2. Three Evaluations Before Deployment
1. VRAM: Weights, KV Cache, and Headroom
A rough estimate of weight VRAM is: parameter count (in billions) multiplied by bytes per parameter. FP16 takes 2 bytes per parameter, INT8 takes 1 byte, and INT4 takes 0.5 bytes. The table below estimates pure weight usage based on this rule. Actual quantized files are slightly larger because some layers remain at higher precision.
| Model Size | FP16 | INT8 | INT4 |
|---|---|---|---|
| 7B | ~14GB | ~7GB | ~3.5GB |
| 14B | ~28GB | ~14GB | ~7GB |
| 32B | ~64GB | ~32GB | ~16GB |
| 70B | ~140GB | ~70GB | ~35GB |
Total VRAM must also include:
- KV Cache: grows with context length and concurrency.
- Activation peaks: intermediate computation results during inference.
- Framework overhead: typically 1 to 2GB.
- Safety margin: reserve 10% to 20%.
Total VRAM ≈ (weights + KV Cache + activation peaks + framework overhead) × 1.1 to 1.2.
KV Cache can be estimated as:
KV Cache bytes = 2 × layers × KV heads × head dimension × bytes per element × context length × concurrency
For a 14B model with 48 layers, 8 KV heads, head dimension 128, and FP16 cache, the KV Cache per token is about 2 × 48 × 8 × 128 × 2 = 196,608 bytes, roughly 192KB. A single stream with 8K context needs about 1.5GB.
MoE models need to be viewed separately. At inference time only some experts are activated, so compute and latency are determined by the active parameters. However, all expert weights usually need to reside in VRAM, so memory usage is determined by the total parameter count. Fewer active parameters mainly reduce computation—they do not directly reduce weight VRAM.
2. Context Length
Long context significantly increases KV Cache usage. Growing context from 4K to 32K multiplies KV Cache by 8. Million-token contexts require techniques like PagedAttention and KV Cache quantization—and you must first confirm the hardware can handle it.
3. Concurrency and Latency
Offline batch processing prioritizes throughput; real-time chat prioritizes time-to-first-token. These different requirements determine whether you need continuous batching, tensor parallelism, and similar capabilities. Before choosing hardware, write down your business’s peak concurrency and acceptable time-to-first-token.
3. Four Deployment Options
Option 1: Single 24GB GPU — For Individuals and Prototyping
Suitable for: individual developers, small teams, prototype validation.
Hardware: one consumer GPU with 24GB VRAM, paired with 64GB RAM and a 2TB NVMe SSD. Total investment is roughly 20,000 to 40,000 RMB.
How large a model 24GB can run depends on model size, quantization bit-width, context length, and concurrency. The table below is estimated using vLLM with --gpu-memory-utilization 0.85, giving about 20.4GB of usable VRAM; after subtracting weights and framework overhead, the remainder goes to KV Cache. These numbers are estimates, not measured benchmarks.
| Model Size | Quantization | Approx. Weights | VRAM for KV Cache | Estimated Capacity | Verdict |
|---|---|---|---|---|---|
| 7B | INT4 | 4GB | 14GB | 32K context, ~6 concurrent streams | Good for prototypes |
| 14B | INT4 | 8GB | 10GB | 4K ~12 streams, 16K ~3 streams, 32K ~1 stream | Recommended entry choice |
| 32B | INT4 | 18GB | ~1GB | Only single stream at 2K–4K | Not recommended |
The following example loads a 14B INT4 model and exposes an OpenAI-compatible API:
vllm serve ./model-14b-awq-int4 --max-model-len 16384 --gpu-memory-utilization 0.85 --max-num-seqs 8 --port 8000
Parameter names and behavior follow the official documentation of your vLLM version. Before running, confirm the model format matches the quantization method.
Once deployed, any client supporting the OpenAI API can connect. For low-intensity personal use, you avoid per-token billing, but you still bear hardware depreciation, electricity, maintenance time, and model licensing costs.
Not suitable for: teams that need production-grade high concurrency, or models above 32B with long context.
Option 2: Multi-GPU Workstation — For R&D Teams of 10 to 100 People
Suitable for: R&D teams that need shared internal access.
Hardware: 2 to 4 professional 48GB GPUs or high-VRAM consumer cards. For example, four 48GB GPUs provide 192GB total VRAM, with total investment around 150,000 to 400,000 RMB.
Key technical points:
- Tensor parallelism (
--tensor-parallel-size) splits each layer’s weights across GPUs, breaking past single-card VRAM limits. The GPU count must divide the model’s attention head count evenly, or splitting is impossible. - Inter-GPU bandwidth determines speed. Many workstations connect GPUs only via PCIe; every layer requires data synchronization, and insufficient bandwidth noticeably slows things down. Prefer NVLink when available; otherwise keep tensor parallelism to 2 GPUs.
- PagedAttention allocates KV Cache in blocks, reducing VRAM waste from fragmentation.
- Continuous batching merges new requests into the running batch at each step, improving throughput.
- Prefix caching (
--enable-prefix-caching) reuses identical system prompts, avoiding repeated computation.
Bottleneck diagnosis: the decoding phase is usually limited by memory bandwidth. If throughput barely grows when concurrency doubles, check bandwidth and interconnects first. If OOM occurs, check VRAM first—see Section 6.
Example command loading a 70B INT4 model:
vllm serve ./model-70b-awq-int4 --tensor-parallel-size 4 --max-model-len 16384 --gpu-memory-utilization 0.90 --max-num-seqs 32 --enable-prefix-caching --port 8000
A 70B INT4 model’s weights are about 35 to 40GB; split across 4 GPUs that’s roughly 10GB per card, with the rest available for KV Cache.
Not suitable for: teams needing stable real-time service for hundreds of simultaneous users, or resource isolation across multiple business lines.
Option 3: Inference Server Cluster — For 100+ Users and Multiple Business Lines
Suitable for: organizations where multiple business lines share model services and require high concurrency, availability, and isolation.
Hardware: multiple 8-GPU servers, each with eight 80GB professional GPUs. A single server costs roughly 600,000 to 1.5 million RMB; cluster investment typically starts at several million RMB.
Key technical points:
- Use tensor parallelism within a node; use pipeline parallelism or multi-replica deployment across nodes. For smaller models, multiple replicas are usually simpler than cross-node splitting.
- Place a unified gateway in front of model services for load balancing, rate limiting, and authentication.
- Use tools like Kubernetes to schedule replicas and partition resource pools by model or business line.
- Monitor time-to-first-token, queue length, VRAM usage, and temperature, with alert thresholds.
Cost composition: hardware depreciates over 3 to 5 years; datacenter power, UPS, and cooling costs are non-negligible. At least one dedicated operations engineer is required.
Limitations: at small scale and low utilization, per-token cost can actually exceed API pricing. Datacenter modifications take time, and upfront preparation is substantial.
Not suitable for: individuals or single teams with low-frequency usage, or organizations without operations capability.
Option 4: Hybrid Cloud Architecture — For Volatile Traffic or Mixed Data Sensitivity
Suitable for: businesses whose peak traffic is several times normal levels, or organizations holding both sensitive and non-sensitive data.
Hardware: keep one Option 1 or Option 2 machine on-premises to handle sensitive data and everyday traffic. During peaks, route requests to the cloud—either renting GPUs by the hour or calling cloud model APIs directly.
Cost formula: monthly cost = local fixed cost + cloud rental hours × hourly rate (or monthly token fees for cloud APIs). Cloud GPU hourly rates follow the provider’s current pricing and vary significantly by region and instance type.
Key technical points:
- Use a unified OpenAI-compatible gateway so business code connects to a single entry point.
- Route requests based on sensitivity level, request length, or concurrency thresholds.
- Data must be de-identified before leaving your domain, with audit logs for every routing decision.
Limitations: you must maintain two environments, and cross-network calls add latency. Any data leaving your domain must pass compliance review—legal approval is a prerequisite.
Not suitable for: institutions whose data is all highly sensitive with no external transfer allowed, or businesses with stable traffic where local machines are already fully loaded.
4. API vs. Self-Hosted Cost Comparison Formulas
Use these formulas:
- Monthly API cost = monthly token volume (millions) × unit price (RMB per million tokens)
- Monthly self-hosted operating cost = electricity + operations labor + network and datacenter fees
- Electricity = average system power (kW) × daily running hours × 30 × electricity price (RMB/kWh)
- Payback months = total hardware cost ÷ (monthly API cost − monthly self-hosted operating cost)
If monthly API cost does not exceed monthly self-hosted operating cost, you will never break even. Payback months measure cash payback and ignore hardware residual value.
Example: a 4-GPU 48GB workstation with hardware costing 300,000 RMB, average power 1.2kW, electricity at 0.6 RMB/kWh, and operations at 2,000 RMB/month. Monthly self-hosted operating cost is about 1.2 × 24 × 30 × 0.6 + 2000 = 2,520 RMB. Assume a blended API price of 40 RMB per million tokens.
| Daily Token Volume | Monthly Tokens | Monthly API Cost | Monthly Savings | Payback Months |
|---|---|---|---|---|
| 3 million | 90 million | 3,600 RMB | 1,080 RMB | ~278 months, not worth it |
| 10 million | 300 million | 12,000 RMB | 9,480 RMB | ~32 months |
| 20 million | 600 million | 24,000 RMB | 21,480 RMB | ~14 months |
Two caveats when applying this. First, the machine must handle peak concurrency—meeting the daily average doesn’t guarantee surviving the peak. Second, changing API prices or electricity rates significantly changes results, so plug in your own numbers.
5. Decision Table
| Team Size and Scenario | Recommended Option | VRAM and Hardware | Budget Reference | Main Risks |
|---|---|---|---|---|
| Individual or 1–3 person prototype | Option 1 | Single 24GB GPU | 20,000–40,000 RMB | Concurrency and context limits |
| R&D team of 10–100 people | Option 2 | 2–4 GPUs, 96–192GB total | 150,000–400,000 RMB | Inter-GPU bandwidth, single-machine failure |
| 100+ users, multiple business lines | Option 3 | Multiple 8-GPU servers | Several million RMB and up | Datacenter and operations barriers |
| Volatile traffic or mixed data sensitivity | Option 4 | Small local machine plus cloud resources | Usage-based billing | Compliance and dual-environment maintenance |
6. OOM Troubleshooting Checklist
Work through the following in order:
- Identify the failing stage. Failure while loading weights means the weights don’t fit—switch to a smaller model or lower bit-width. If startup reports insufficient KV Cache space, continue with the steps below.
- Lower
--max-model-len, for example from 32768 to 16384. - Reduce
--max-num-seqsto limit simultaneously processed requests. - Slightly increase
--gpu-memory-utilizationby 0.02 to 0.05 each time, not exceeding 0.92. Before adjusting, use nvidia-smi to confirm no other processes are occupying the GPU. - Where hardware and version support allow, enable KV Cache quantization (e.g.,
--kv-cache-dtype fp8) and run output-quality regression tests. - Occasional OOM during operation is usually caused by long…
