Budgeting for Local LLM Deployment: VRAM Requirements and Break-Even Analysis
This article provides a comprehensive guide to calculating the budget for locally deploying large language models. It details VRAM requirements, KV cache calculations, and hardware configurations across three performance tiers. By comparing local deployment costs with cloud API pricing, the article establishes a break-even analysis and includes a Python script to automate these calculations, helping developers and engineers make informed hardware purchasing decisions.
1. Defining Goals and Assumptions
The budget is determined by your target performance tier. Higher targets demand greater VRAM capacity, memory bandwidth, and interconnect bandwidth, which naturally increases the number of GPUs required and the overall cost. This article defines three tiers:
- Functional (Can run): The model can be loaded and outputs normally with no strict speed requirements. Suitable for functional verification and offline batch processing.
- Single-user 25 tokens/s: When a single user interacts, the output speed reaches 25 tokens/s.
- 10 Concurrency at 25 tokens/s: 10 users use the system simultaneously, with a total throughput of approximately 250 tokens/s.
The following calculations are based on a set of example assumptions. Before purchasing, replace the “assumption” values with your actual configurations and the “placeholder” values with supplier quotes.
| Parameter | Example Value | Description |
|---|---|---|
| Total Parameters | 2800B (2.8T) | B stands for billion parameters; determines the VRAM lower limit |
| Active Parameters | 40B | Determines the computation and memory access per token |
| Quantization Format | 4-bit elements, sharing one 8-bit scale factor per 32 elements | Effective bit width: 4.25 bit |
| Layers / KV Heads / Head Dim | 60 / 8 / 128 | Determines KV cache size |
| Hidden Dimension | 8192 | Determines tensor parallel communication volume |
| KV Cache Precision | 2 bytes (BF16 or FP16) | Counted in bytes |
| VRAM per Card / Usable Rate | 80 GB / 90% | Reserves 10% for fragmentation and communication buffers |
| Bandwidth per Card / Derating Factor | 2000 GB/s / 0.5 | Derating factor must be based on benchmark results |
| Power per Card / Avg Utilization | 700 W / 60% | Card only, excludes other server components |
| Comm Delay | 20 μs / all-reduce | Placeholder; replace with communication test results |
| PUE | 1.3 | Placeholder; replace with actual datacenter value |
| Electricity Price | $0.8 / kWh | Placeholder, not market price |
| Total HW Price / Depreciation / Monthly Ops | $2,000,000 / 36 months / $10,000 | Placeholder, includes server |
| Cloud API Price | $30 / Million tokens | Placeholder, based on total tokens |
Unit convention used in this article: GB refers to decimal 10^9 bytes, which differs from GiB.
2. VRAM, KV Cache, and Concurrency
2.1 VRAM Calculated by Total Parameters
Mixture of Experts (MoE) models have a large total parameter count, but only activate a small fraction of experts per token. While compute depends only on active parameters, VRAM must be calculated based on total parameters, as routing might call any expert at any time. CPU memory, NVMe, and expert sharding (offloading) can hold some weights, but cache misses will read from slower media, making this approach suitable only for offline batch processing, not latency-sensitive interactive scenarios.
Effective bit width = 4 + 8 ÷ 32 = 4.25 bit. Weight volume = 2800 × 4.25 ÷ 8 = 1487.5 GB. Adding a 20% overhead for non-quantized tensors, metadata, memory alignment, and runtime workspace, the base VRAM is 1785.0 GB. The 20% overhead is an empirical value. After loading an actual model, you should calibrate this factor using framework VRAM statistics or nvidia-smi.
2.2 KV Cache
KV cache bytes = 2 × Layers × KV Heads × Head Dim × Bytes × Context Length × Concurrency. Using the table parameters, the KV cache per token is 2 × 60 × 8 × 128 × 2 = 245,760 bytes (~0.25 MB). For an 8192 token context per user, the KV cache is 2.01 GB; for 10 users, it totals 20.13 GB.
Note: Compressed attention structures like MLA cannot use this formula directly and must be recalculated based on their actual architecture.
2.3 Card Count and Communication
Minimum cards = ceil(Total VRAM ÷ (VRAM per Card × Usable Rate)). At concurrency 1, total VRAM is 1787.01 GB, requiring at least 25 cards. At concurrency 10, total VRAM is 1805.13 GB, requiring at least 26 cards. Rounding up to 8 cards per server, both scenarios require 32 cards (4 servers).
Tensor parallelism performs two all-reduces per layer. Communication per token is 2 × 8192 × 2 bytes × 2 times × 60 layers ≈ 1.97 MB. This figure only represents data volume; actual communication time depends on interconnect bandwidth and per-call latency, which must be tested physically.
2.4 Speed Limits
During decoding, each token requires reading the weights corresponding to the active parameters: 40 × 4.25 ÷ 8 = 21.25 GB. Single-step time consists of two parts: VRAM read time, and communication latency (60 layers × 2 times × 20 μs = 2.4 ms).
Example calculation results:
- Batch 1: Single step ~3.064 ms, theoretical per-stream max ~326.4 tokens/s.
- Batch 10: Single step ~9.041 ms, per-stream ~110.6 tokens/s, total ~1106.1 tokens/s.
These are theoretical maximums, not measured values. Under these assumptions, the speed targets are met on paper, but actual gaps must be confirmed via benchmarking.
3. Power Consumption and Three-Tier Scenarios
All three tiers use the same 32-card hardware. This is because the VRAM lower limit determines the card count, and all tiers fall between 25 and 26 cards. The target tier mainly affects concurrency scheduling and whether bandwidth is sufficient, not the raw card count.
Power calculated per card: 32 cards × 700 W × 60% = 13.44 kW. Over 720 hours, monthly power consumption is 9676.8 kWh. Multiplied by a PUE of 1.3, this becomes 12,579.84 kWh. At $0.8 / kWh, the electricity cost is approximately $10,063.87 / month.
Local fixed monthly costs are as follows:
- Depreciation: $2,000,000 ÷ 36 months = $55,555.56 / month
- Operations: $10,000.00 / month
- Electricity: $10,063.87 / month
- Total: $75,619.43 / month
Note: Electricity is calculated as a fixed cost based on average utilization. If actual load fluctuates significantly, recalculate based on actual power draw.
Monthly usage and costs for the three tiers. Cloud costs are calculated as monthly total tokens multiplied by $30 / million tokens:
- Functional (Offline batch, 100M tokens/month): Cloud $3,000.00, Local $75,619.43.
- Single-user 25 tokens/s (8 hrs/workday, 22 days/month): Monthly usage ~15.84M tokens, Cloud $475.20, Local $75,619.43.
- 10 Concurrency at 25 tokens/s (8 hrs/workday full load): Monthly usage ~158.4M tokens, Cloud $4,752.00, Local $75,619.43.
4. Break-Even Analysis and Sensitivity
Break-even monthly usage = Local fixed monthly cost ÷ Cloud API price × 10^6. Plugging in the numbers: 75,619.43 ÷ 30 × 10^6 ≈ 2.521 billion tokens/month. This equates to a sustained average throughput of ~972.5 tokens/s.
Only by sustaining close to this throughput long-term can local deployment be cheaper than the cloud. Below this usage volume, the cloud is more cost-effective.
Sensitivity results (in billions of tokens/month):
| Variable | Value | Break-Even Usage |
|---|---|---|
| Total HW Price | $1,000,000 | 15.95 |
| Total HW Price | $2,000,000 (Baseline) | 25.21 |
| Total HW Price | $3,000,000 | 34.47 |
| Cloud API Price | $20 / Million tokens | 37.81 |
| Cloud API Price | $30 / Million tokens (Baseline) | 25.21 |
| Cloud API Price | $45 / Million tokens | 16.80 |
Depreciation accounts for about 73% of local monthly costs, making hardware quotes and depreciation periods the most sensitive inputs. Before purchasing, obtain real quotes and recalculate this table.
5. Complete Code and Validation Checklist
The following code relies only on the Python standard library and can be run directly. The speeds and costs use placeholder values from this article; the output is only for validating the formulas and does not represent any real device performance or quotes.
import mathGB = 1e9 # Decimal GB, 1 GB = 10^9 bytesHOURS_PER_MONTH = 720 # 30 days * 24 hoursNODE_CARDS = 8 # 8 cards per serverdef effective_bits(elem_bits=4, scale_bits=8, block_size=32):"""Average bit width per element (including scale factor)."""if block_size <= 0:raise ValueError("block_size must be a positive number")return elem_bits + scale_bits / block_sizedef weight_gb(total_params_b, bits):"""Weight volume (GB). total_params_b unit is billion parameters."""return total_params_b * bits / 8def base_memory_gb(weights_gb, overhead_ratio=0.2):"""Base VRAM including non-quantized tensors, metadata, etc."""return weights_gb * (1 + overhead_ratio)def kv_cache_gb(layers, kv_heads, head_dim, kv_bytes, context_len, concurrency):per_token = 2 * layers * kv_heads * head_dim * kv_bytesreturn per_token * context_len * concurrency / GBdef min_cards(total_gb, card_gb=80, usable=0.9):return math.ceil(total_gb / (card_gb * usable))def round_to_node(cards):return math.ceil(cards / NODE_CARDS) * NODE_CARDSdef decode_step_ms(active_params_b, bits, cards, bw_gbs, bw_factor,batch, layers, allreduce_us):mem_ms = batch * active_params_b * bits / 8 / (cards * bw_gbs * bw_factor) * 1000comm_ms = layers * 2 * allreduce_us / 1000return mem_ms + comm_msdef monthly_local_cost(hw_wan, depr_months, ops, cards, card_w, util, pue, power_price):depr = hw_wan * 1e4 / depr_monthskwh = cards * card_w * util / 1000 * HOURS_PER_MONTH * puepower = kwh * power_pricereturn depr + ops + power, depr, powerdef breakeven_tokens(monthly_fixed, cloud_price_per_m):return monthly_fixed / cloud_price_per_m * 1e6def main():total_b, active_b = 2800, 40layers, kv_heads, head_dim, ctx = 60, 8, 128, 8192card_gb, usable, bw_gbs, bw_factor = 80, 0.9, 2000, 0.5card_w, util, pue, power_price = 700, 0.6, 1.3, 0.8hw_wan, depr_months, ops = 200, 36, 10000cloud_price = 30deploy_cards = 32# Input validationassert 0 < util <= 1 and 0 < usable <= 1assert total_b >= active_b, "Active parameters cannot be greater than total parameters"# VRAM and Concurrencybits = effective_bits()w = weight_gb(total_b, bits)base = base_memory_gb(w)print(f"Effective bits: {bits:.2f} bit")print(f"Weight volume: {w:.1f} GB")print(f"Base VRAM: {base:.1f} GB")assert abs(w - 1487.5) < 1e-6 # Validate example valuesfor conc in (1, 10):kv = kv_cache_gb(layers, kv_heads, head_dim, 2, ctx, conc)total = base + kvcards = min_cards(total, card_gb, usable)print(f"Concurrency {conc}: KV {kv:.2f} GB, Total VRAM {total:.2f} GB, "f"Min {cards} cards, Rounded {round_to_node(cards)} cards")# Speed limits (theoretical, replace with benchmark)for batch in (1, 10):step = decode_step_ms(active_b, bits, deploy_cards, bw_gbs, bw_factor,batch, layers, allreduce_us=20)per_user = 1000 / stepprint(f"batch {batch}: Single step {step:.3f} ms, Per-stream {per_user:.1f} tok/s, "f"Total {per_user * batch:.1f} tok/s")# Cost and Break-evenfixed, depr, power = monthly_local_cost(hw_wan, depr_months, ops, deploy_cards, card_w, util, pue, power_price)print(f"Depreciation {depr:.2f} / month, Ops {ops:.2f} / month, Power {power:.2f} / month")print(f"Total Local Fixed Cost: {fixed:.2f} / month")be = breakeven_tokens(fixed, cloud_price)print(f"Break-even monthly usage: {be / 1e8:.2f} billion tokens")print(f"Equivalent sustained throughput: {be / (HOURS_PER_MONTH * 3600):.1f} tok/s")scenarios = [("Offline batch (100M tokens/month)", 1e8),("Single-user 25 tok/s (8 hrs/workday, 22 days)", 25 * 3600 * 8 * 22),("10 Concurrency x25 tok/s (8 hrs/workday full load)", 250 * 3600 * 8 * 22),]for name, tokens in scenarios:cloud = tokens / 1e6 * cloud_priceprint(f"{name}: Cloud {cloud:.2f}, Local {fixed:.2f}")# Sensitivity (Unit: billion tokens/month)print("Sensitivity (billion tokens/month)")for hw in (100, 200, 300):f, _, _ = monthly_local_cost(hw, depr_months, ops, deploy_cards, card_w, util, pue, power_price)print(f"Hardware ${hw}00,000: {breakeven_tokens(f, cloud_price) / 1e8:.2f}")for price in (20, 30, 45):print(f"Cloud ${price} / Million tokens: {breakeven_tokens(fixed, price) / 1e8:.2f}")if __name__ == "__main__":main()
Example output after running:
Effective bits: 4.25 bitWeight volume: 1487.5 GBBase VRAM: 1785.0 GBConcurrency 1: KV 2.01 GB, Total VRAM 1787.01 GB, Min 25 cards, Rounded 32 cardsConcurrency 10: KV 20.13 GB, Total VRAM 1805.13 GB, Min 26 cards, Rounded 32 cardsbatch 1: Single step 3.064 ms, Per-stream 326.4 tok/s, Total 326.4 tok/sbatch 10: Single step 9.041 ms, Per-stream 110.6 tok/s, Total 1106.1 tok/sDepreciation 55555.56 / month, Ops 10000.00 / month, Power 10063.87 / monthTotal Local Fixed Cost: 75619.43 / monthBreak-even monthly usage: 25.21 billion tokensEquivalent sustained throughput: 972.5 tok/sOffline batch (100M tokens/month): Cloud 3000.00, Local 75619.43Single-user 25 tok/s (8 hrs/workday, 22 days): Cloud 475.20, Local 75619.4310 Concurrency x25 tok/s (8 hrs/workday full load): Cloud 4752.00, Local 75619.43Sensitivity (billion tokens/month)Hardware $1000,000: 15.95Hardware $2000,000: 25.21Hardware $3000,000: 34.47Cloud $20 / Million tokens: 37.81Cloud $30 / Million tokens: 25.21Cloud $45 / Million tokens: 16.80
6. Pre-Purchase Checklist
- Load the actual model once and measure true VRAM using framework stats or
nvidia-smito calibrate the 20% overhead factor. - Replace the 0.5 bandwidth derating factor with benchmark results, and measure actual communication latency to replace the 20 μs placeholder.
- Request formal tax-inclusive or exclusive quotes from suppliers, noting the quote date and region.
- Ensure PUE and electricity prices are taken from actual datacenter billing.
- Estimate monthly token volume using real business logs and plug them into the break-even table instead of using example loads.
- Confirm the selected model uses standard MHA or GQA architecture. If it uses MLA or similar, recalculate the KV cache.
All prices, power, and performance figures in this article are examples. They must be replaced with measured values and quotes before making any procurement decisions.
