Self-Hosting an LLM: Options, Costs, and GPU Requirements

Khimananda Oli 7 min read Virtualization
Self-Hosting an LLM: Options, Costs, and GPU Requirements

By Khimananda Oli | Last reviewed: August 2026

Self-hosting an LLM gives you data sovereignty, predictable latency, and freedom from API rate limits, but success depends entirely on matching your workload to the right hardware and inference stack. Understanding self-hosting an LLM: options, costs, and GPU requirements prevents the most common failure mode: buying expensive GPUs that still cannot fit your target model in memory. Before provisioning infrastructure, review your baseline server hardening practices as outlined in my guide on securing a fresh Ubuntu VPS, because exposing an unhardened inference endpoint is a critical security risk.

Client AppsWeb / API / CLIInference ServerOllama / vLLMModel LoaderKV Cache MgmtBatch SchedulerGPU HardwareVRAM (24-80GB)CUDA CoresMemory BandwidthModel WeightsGGUF / AWQ / FP16
Core architecture for self-hosting an LLM showing inference server, GPU hardware, and model storage layers

What Are the Best Software Options for Self-Hosting an LLM?

Choosing the right inference engine determines your throughput, ease of deployment, and production viability. The ecosystem has matured significantly by 2026, with three dominant options covering distinct use cases.

Ollama for Development and Small Teams

Ollama remains the fastest path from zero to running model for individual developers and small teams. It bundles model downloading, quantization, and serving into a single binary with minimal configuration.

# Install Ollama on Ubuntu 24.04 LTS
curl -fsSL https://ollama.com/install.sh | sh

# Pull and run Llama 3.1 8B Instruct (Q4_K_M quantization)
ollama pull llama3.1:8b-instruct-q4_K_M

# Serve via REST API on port 11434
ollama serve &

# Test inference
curl http://localhost:11434/api/generate -d '{
  "model": "llama3.1:8b-instruct-q4_K_M",
  "prompt": "Explain Kubernetes pod scheduling",
  "stream": false
}'

Ollama excels at local development, prototyping, and low-concurrency workloads. However, it lacks advanced batching, continuous batching, and fine-grained resource controls needed for high-throughput production serving.

vLLM for Production Throughput

vLLM uses PagedAttention to manage KV cache memory efficiently, enabling 2–5x higher throughput than naive implementations. It supports continuous batching, OpenAI-compatible APIs, and tensor parallelism across multiple GPUs.

# Install vLLM with CUDA 12.6 support
pip install vllm==0.6.3.post1

# Serve Llama 3.1 70B with tensor parallelism across 4 GPUs
python -m vllm.entrypoints.openai.api_server \
  --model meta-llama/Llama-3.1-70B-Instruct \
  --tensor-parallel-size 4 \
  --gpu-memory-utilization 0.92 \
  --max-model-len 8192 \
  --port 8000

For teams building customer-facing applications or internal tools with concurrent users, vLLM is the default choice in 2026. Its memory management directly translates to lower cost per token served.

LocalAI and LM Studio for Specific Niches

LocalAI provides broader model format compatibility (including older GGML variants) and easier Docker-based deployment for heterogeneous environments. LM Studio offers a GUI-driven experience ideal for non-engineers evaluating models before committing to infrastructure. Neither matches vLLM's throughput for production, but both fill important gaps in evaluation and legacy support workflows.

How Much VRAM Do You Need for Different LLM Sizes?

VRAM is the single hardest constraint when self-hosting an LLM. Model weights must fit entirely in GPU memory alongside the KV cache, which grows with context length and batch size. Running out of VRAM causes silent fallback to system RAM, destroying performance by 50–100x.

Model SizeQuantizationWeight SizeMin VRAM (4K ctx)Recommended GPUAvg Tokens/sec
7B–8BQ4_K_M~4.5 GB8 GBRTX 4060 Ti 16GB45–65
13B–14BQ4_K_M~8 GB12 GBRTX 4070 Ti Super 16GB30–45
30B–34BQ4_K_M~19 GB24 GBRTX 4090 / RTX A500018–28
70BQ4_K_M~40 GB48 GB2× RTX 4090 / A600012–20
70BFP16~140 GB160 GB2× A100 80GB / H10025–40
405BQ4_K_M~230 GB260 GB4× H100 80GB8–14

Always add 20–30% headroom above weight size for KV cache. A 70B Q4 model at 40GB weights needs ~52GB VRAM for comfortable 8K context serving. If you are containerizing your inference stack, follow the patterns in my Docker containerization guide to ensure GPU passthrough and resource limits are configured correctly.

Select Modele.g., Llama 3.1 70BChoose QuantQ4_K_M ≈ 40GBEstimate KV Cache8K ctx ≈ 8-12GBAdd 20% OverheadSafety marginTotal VRAM Required40 + 12 + 10 = ~62GB → 2× RTX 4090 (48GB) insufficient✓ Use A6000 48GB × 2 or reduce to Q3_K_M
Step-by-step VRAM calculation workflow for determining GPU requirements when self-hosting an LLM

What Does Self-Hosting an LLM Actually Cost in 2026?

Total cost of ownership extends far beyond GPU sticker price. Budget accurately across four categories to avoid mid-project surprises.

  • Hardware acquisition: Consumer RTX 4090 ($1,600–$1,800) suits single-user 30B models. Professional RTX A6000 ($4,200) or A100 ($10,000+) enables multi-user 70B serving. Used enterprise GPUs from decommissioned training clusters offer 30–40% savings with acceptable warranty trade-offs.
  • Electricity and cooling: A dual-4090 workstation draws 700–900W under load. At Nepal's average commercial rate of NPR 12/kWh (~$0.09 USD), continuous operation costs ~$55/month. Add 20–30% for cooling in Kathmandu's summer heat; inadequate ventilation throttles GPUs and reduces lifespan.
  • Networking and storage: NVMe SSDs (2TB minimum) prevent model loading bottlenecks. For remote teams, factor in dedicated fiber or leased line costs; LLM inference over shared broadband introduces unacceptable latency for interactive use.
  • Operational overhead: Monitoring, updates, security patching, and incident response consume 4–8 engineering hours monthly. If your team lacks GPU operations experience, budget for consulting or managed services during the first quarter.

Compare this against API costs: GPT-4o-class performance via OpenAI runs $2.50–$10 per million output tokens. At 10M tokens/month, break-even versus a dual-4090 setup occurs around month 8–12. Below 5M tokens/month, APIs usually win on total cost unless data residency or customization demands self-hosting.

How Do You Optimize Performance and Reduce Costs?

Raw hardware is necessary but insufficient. These optimizations routinely deliver 2–3x effective throughput without additional spend.

  1. Quantize aggressively: Q4_K_M retains 97–99% of FP16 quality for instruction-tuned models while halving VRAM. Use AWQ or GPTQ for better accuracy at equivalent bit depths. Avoid Q2/Q3 except for experimentation; quality degradation becomes user-visible.
  2. Tune context length: Every doubling of max context increases KV cache linearly. Default to 4K unless your use case demonstrably requires longer windows. Implement retrieval-augmented generation (RAG) instead of brute-force context expansion.
  3. Enable speculative decoding: Pair a small draft model (1B–3B) with your primary model. vLLM and SGLang support this natively, yielding 1.5–2.5x speedup on structured outputs like code and JSON with negligible quality loss.
  4. Right-size concurrency: Continuous batching shines at 8–32 concurrent requests. Below 4 concurrent, Ollama's simpler scheduler often matches vLLM. Profile your actual traffic patterns before over-engineering.
  5. Monitor and autoscale: Track VRAM utilization, queue depth, and time-to-first-token. Set up alerts as described in my Prometheus and Grafana monitoring guide to catch saturation before users experience degradation.
Monthly Cost (USD)Throughput (tok/s)RTX 4090$55/mo elec28 tok/sA6000 48GB$75/mo elec38 tok/sH100 Cloud$2,200/mo85 tok/sBest: <5M tok/moBest: 5-20M tok/moBest: >20M tok/mo$55$75$2,200
Cost versus throughput comparison for self-hosting an LLM across consumer GPU, professional GPU, and cloud rental tiers

Making Your Self-Hosted LLM Deployment Production-Ready

Understanding self-hosting an LLM: options, costs, and GPU requirements gets you to a working prototype; operational discipline keeps it running reliably. Start with accurate VRAM sizing using the table above, select Ollama for development or vLLM for production, and budget honestly across hardware, power, and engineering time. Apply quantization and context tuning before purchasing additional GPUs—most teams leave 30–40% performance on the table through suboptimal configuration alone. Treat your inference stack like any other production service: automate deployments with infrastructure-as-code principles from my Terraform practical guide, enforce least-privilege access, and maintain observable metrics from day one. If your team needs hands-on guidance architecting a compliant, cost-efficient private LLM deployment, reach out to discuss your specific requirements.

Frequently Asked Questions

You need at least 6GB VRAM for 4-bit quantized 7B models. Full precision requires 14GB. RTX 3060 12GB or RTX 4060 Ti 16GB are common entry points in 2026.

Expect $15-$40 monthly in electricity for continuous 300W GPU usage. Hardware amortization adds $50-$150 monthly over three years. Cloud GPU rentals often exceed $200 monthly for comparable performance.

Yes, using llama.cpp with AVX2 support. Expect 2-5 tokens per second for 7B models. Suitable for testing but impractical for production workloads requiring real-time responses.

vLLM and Ollama lead in 2026. vLLM offers PagedAttention for high-throughput batching. Ollama simplifies local deployment with one-command setup. Both support GGUF, AWQ, and GPTQ quantization formats natively.

Never expose raw API ports publicly. Use reverse proxies like Caddy with mTLS authentication. Implement rate limiting via nginx and isolate the container in a dedicated VLAN with egress filtering.

Use Q4_K_M GGUF for balanced quality and speed on consumer GPUs. AWQ provides better accuracy for NVIDIA cards with CUDA support. Avoid Q2 variants as perplexity degradation makes outputs unreliable.

Yes. M-series unified memory allows loading larger models than discrete GPUs with same VRAM. An M4 Max with 128GB runs 70B Q4 models at 15 tokens per second using mlx-lm or Ollama.

Check TDP ratings and add 50W for system overhead. A 350W RTX 4090 draws 250W average during inference. Multiply by local kWh rate and 730 hours for monthly cost estimates.

NVMe Gen4 SSDs load 70B models in under 10 seconds. SATA SSDs take 30-45 seconds. Avoid HDDs entirely as seek times cause multi-minute loads and token generation stuttering.

Self-hosting breaks even around 2M tokens daily versus OpenAI pricing. Below that threshold, APIs win on convenience. Above it, owned hardware delivers 60-80% savings over twelve months.

Limited. QLoRA fine-tuning fits 7B models on 16GB VRAM. Full fine-tuning requires 3-4x inference VRAM. Most self-hosters use separate cloud instances for training then deploy quantized weights locally.

Context length exceeds KV cache capacity, not just model weights. Reduce max context or enable Flash Attention 2. Monitor VRAM with nvidia-smi and set explicit tensor parallelism limits in your serving config.

Not strictly required but strongly recommended. Containers prevent CUDA version conflicts and simplify updates. Official vLLM and Ollama images include optimized dependencies. Bare metal installs risk breaking system libraries during upgrades.

Use llmperf or vLLM benchmark scripts with realistic prompt distributions. Measure time-to-first-token and tokens-per-second separately. Test at expected concurrency levels since single-stream benchmarks misrepresent production throughput.

Use wired Gigabit Ethernet minimum. WiFi adds 5-20ms jitter. For multi-node setups, RDMA over Converged Ethernet reduces inter-GPU communication overhead. Bind serving ports to specific interfaces rather than 0.0.0.0.