How to Run Local LLMs with Ollama and Open WebUI on Your Homelab (Complete Guide)
How to Run Local LLMs with Ollama and Open WebUI on Your Homelab (Complete Guide)
If you've ever wanted to run AI models locally without sending your data to the cloud, this guide is for you. By the end, you'll have a production-ready local AI stack running on your homelab with a polished web interface, GPU acceleration, and enterprise-grade security.
Guide Summary
This complete guide walks you through deploying a local LLM stack using Ollama as the model runtime and Open WebUI as the chat interface. Covers hardware selection, Docker Compose deployment with GPU support, model management, RAG configuration, reverse proxy with TLS, security hardening, backups, and monitoring. Tested on Ubuntu 22.04/24.04, Proxmox VE 8.x, Docker 27.x, Ollama 0.3.x, Open WebUI 0.3.x.
Why Run LLMs Locally on Your Homelab?
Privacy and Data Sovereignty
When you chat with cloud AI services, every prompt, document upload, and conversation travels over the internet to someone else's servers. For personal projects this might be fine, but for sensitive work — financial data, medical records, proprietary code, or private conversations — local inference keeps everything on your hardware. Your data never leaves your network.
No API Costs or Rate Limits
Cloud APIs charge per token. A serious coding assistant workflow can easily burn through $50-100/month in API costs. Local models are free after the initial hardware investment. No rate limits, no billing surprises, no "you've exceeded your quota" messages during critical work.
Offline Capability
Your homelab doesn't need internet access to run inference. Whether you're on a plane, in a secure facility, or your ISP goes down, your AI assistant keeps working. This is critical for air-gapped environments and disaster recovery scenarios.
Custom Model Fine-Tuning
Want a model that speaks your company's internal DSL? Need a model trained on your specific documentation? Local inference lets you fine-tune models with LoRA adapters, create custom Modelfiles, and experiment without asking permission or paying for fine-tuning APIs.
Learning and Experimentation
Running models locally teaches you how they actually work — tokenization, quantization, context windows, KV caches, GPU memory management. This knowledge transfers directly to cloud deployments and makes you a more effective AI engineer.
Prerequisites: Hardware and Software Requirements
Minimum Hardware Specs
| Component | Minimum | Recommended | Notes |
|---|---|---|---|
| CPU | 4 cores (AVX2) | 8+ cores (AVX-512) | Apple Silicon uses unified memory |
| RAM | 16 GB | 32-64 GB | Model weights + KV cache + OS |
| GPU | None (CPU-only) | NVIDIA 12 GB+ VRAM | See GPU section below |
| Storage | 50 GB free | 200+ GB NVMe | Models are 2-50 GB each |
GPU Options
NVIDIA (Best Support)
- RTX 3060 12 GB → Excellent entry point (~$300 used)
- RTX 3090/4090 24 GB → Runs 70B models at 4-bit
- RTX 6000 Ada 48 GB → Runs 70B at 8-bit, 120B at 4-bit
- Data center: A100 40/80 GB, H100 80 GB
AMD (Improving via ROCm)
- RX 7900 XTX 24 GB → Good value, ROCm 6.0+ support
- MI300X 192 GB → Enterprise grade
Apple Silicon (Unified Memory)
- M1/M2/M3 Max/Ultra 64-192 GB → Best price/performance for large models
- No separate VRAM — system RAM is shared
Software Prerequisites
Network Considerations
- Ollama API defaults to
127.0.0.1:11434(localhost only) - Open WebUI defaults to port
3000 - For remote access, use a reverse proxy (Traefik/Nginx/Caddy) with TLS — never expose ports directly
Installing Ollama: The Model Runtime
Method 1: Native Installation
Start the service:
Method 2: Docker Container (Recommended for Homelabs)
Method 3: Docker Compose with GPU Support
Create docker-compose.yml:
Deploy:
Verifying Ollama Is Running
Basic Ollama Commands Cheat Sheet
| Command | Purpose |
|---|---|
ollama list | List downloaded models |
ollama pull llama3.1:8b-instruct-q4_k_m | Download a model |
ollama run llama3.1:8b-instruct-q4_k_m | Interactive chat |
ollama rm model-name | Remove a model |
ollama show model-name | Model details (Modelfile, template) |
ollama ps | Currently loaded models |
ollama serve | Start server manually (foreground) |
Pulling and Managing Models
Understanding Model Naming and Tags
Format: model-name:tag
- Model name:
llama3.1,mistral,qwen2.5,phi3,codellama - Size suffix:
:8b,:70b,:120b(parameters in billions) - Quantization tag:
:q4_k_m,:q8_0,:fp16,:q4_0
Quantization Explained
| Quantization | Size (8B) | Quality | Speed | VRAM (8B) |
|---|---|---|---|---|
fp16 / bf16 | ~16 GB | Best | Slow | 16 GB |
q8_0 | ~9 GB | Near-fp16 | Fast | 9 GB |
q6_k | ~7 GB | Excellent | Fast | 7 GB |
q5_k_m | ~5.5 GB | Very good | Fast | 5.5 GB |
q4_k_m | ~4.5 GB | Great | Fastest | 4.5 GB |
q4_0 | ~4 GB | Good | Fastest | 4 GB |
q3_k_m | ~3.5 GB | Decent | Fastest | 3.5 GB |
Recommendation: Start with q4_k_m — best balance of quality, speed, and memory.
Popular Models for Different Use Cases
Model Management Commands
Custom Modelfiles for Fine-Tuning
Create Modelfile:
Build and use:
Setting Up Open WebUI: The Chat Interface
Why Open WebUI Over Other Interfaces?
| Feature | Open WebUI | LibreChat | AnythingLLM | Chatbox |
|---|---|---|---|---|
| Self-hosted | Yes | Yes | Yes | No (cloud sync) |
| RAG (Documents) | Native | Yes | Yes | Limited |
| Pipelines/Tools | Native | No | Yes | No |
| Multi-user/Auth | Built-in | Yes | Yes | No |
| Model Management | From UI | Yes | No | Manual |
| Code Execution | Pipelines | Yes | Yes | No |
| Mobile PWA | Yes | Yes | Yes | No |
| Active Development | Very active | Active | Active | Slow |
Open WebUI is the most feature-complete, actively maintained option with native Ollama integration.
Docker Compose Setup with Ollama
Use the compose file from Method 3 above — it includes both services with proper networking.
Key environment variables for Open WebUI:
Generate a secure secret:
Configuration Options
Volumes persist:
/app/backend/data— SQLite database, uploaded files, vector DB, user settings
Key settings (adjust via UI after first login):
- Admin Panel → Settings → General — Site title, default model, signup
- Admin Panel → Settings → Ollama — Multiple Ollama endpoints
- Admin Panel → Settings → RAG — Chunk size, overlap, embedding model
- Admin Panel → Settings → Web Search — Engine, API keys
Enabling GPU Acceleration in Open WebUI
Open WebUI itself doesn't need GPU — it's a frontend. Ollama does the inference. Ensure Ollama container has GPU access (see Docker Compose deploy.resources.reservations.devices).
Verify GPU works:
First Login and Admin Setup
- Open
http://your-homelab-ip:3000 - First account created = Admin — use a strong password
- Immediately: Admin Panel → Settings → General → Disable Signup
- Configure your preferences in Settings (gear icon)
Key Features Walkthrough
RAG (Retrieval-Augmented Generation)
- Upload PDFs, Markdown, text files in chat via
+button - Documents are chunked, embedded, stored in local vector DB (ChromaDB)
- Queries retrieve relevant chunks → injected into context
Pipelines (Web Search, Tools)
- Admin Panel → Pipelines → Enable "Web Search"
- Add API keys for Serper, Tavily, or use DuckDuckGo (free)
- Model can now search the web during conversation
Model Management (from UI)
- Admin Panel → Models → Pull/Delete/Tag models
- See model sizes, parameters, last used
- Set default model per user
Connecting Open WebUI to Ollama
Default Connection (Same Host)
With Docker Compose, services communicate via service names:
- Open WebUI →
http://ollama:11434(Docker DNS) - No configuration needed — works out of the box
Connecting to Remote Ollama Instance
If Ollama runs on a different machine:
On the remote Ollama host, bind to all interfaces:
Troubleshooting Connection Issues
| Symptom | Cause | Fix |
|---|---|---|
| "Connection refused" | Ollama not running / wrong URL | Check docker compose ps, verify OLLAMA_BASE_URL |
| "Model not found" | Model not pulled on that Ollama | ollama pull model-name on the Ollama host |
| Slow first response | Model loading into VRAM | First load is slow; subsequent are fast |
| CORS errors | Browser blocking | Set OLLAMA_ORIGINS=* on Ollama |
Configuring Multiple Ollama Backends
Open WebUI supports multiple Ollama endpoints (Admin → Settings → Ollama → Add Connection). Useful for:
- GPU server for large models + CPU server for small models
- Different model collections per team
- Failover between instances
Model Sync Between Ollama and Open WebUI
Models pulled via CLI (ollama pull) appear automatically in Open WebUI. Models pulled via Open WebUI UI are stored in the same Ollama volume. They're the same model store.
Optimizing Performance: GPU Acceleration and Tuning
NVIDIA GPU Setup with nvidia-container-toolkit
On host (Ubuntu/Proxmox/Debian):
In docker-compose.yml (already shown in Method 3):
AMD ROCm Support
Apple Metal (MPS) on macOS
Native Ollama on macOS uses Metal automatically. No Docker needed — native install is faster on Apple Silicon.
CPU-Only Optimization Tips
If no GPU, optimize for CPU inference:
Model selection for CPU:
- Smaller models:
phi3:3.8b,gemma2:2b,qwen2.5:1.5b - 4-bit quantization essential (
q4_k_morq3_k_m) - Expect 2-10 tokens/second depending on CPU
Context Window and Batch Size Tuning
Trade-offs:
- Larger context → more VRAM/RAM, slower first token
- Larger batch → faster prompt processing, more VRAM
Monitoring GPU Usage
Advanced Features: RAG, Pipelines, and More
Setting Up RAG (Retrieval-Augmented Generation)
In Open WebUI:
- Click
+in chat → Upload document (PDF, MD, TXT, DOCX) - Document is processed → chunked → embedded → stored
- Chat with the document: "Summarize this PDF" or "What does section 3 say?"
Configuration (Admin → Settings → RAG):
- Embedding Model:
nomic-embed-text(pull first:ollama pull nomic-embed-text) - Chunk Size: 500-1000 tokens
- Chunk Overlap: 100-200 tokens
- Top K Results: 3-5
For better RAG, use a dedicated embedding model:
Document Ingestion and Vector Databases
Open WebUI uses ChromaDB (embedded SQLite) by default. For production scale, configure external ChromaDB or Qdrant:
Open WebUI Pipelines for Web Search and Tools
Admin Panel → Pipelines → Add Pipeline
- Web Search (built-in):
- Engine: DuckDuckGo (free), Serper, Tavily, Google
- Model decides when to search, retrieves results, synthesizes answer
- Custom Function Pipelines (Python):
- Create functions for: API calls, database queries, file ops, shell commands
- Model calls functions → gets results → continues reasoning
Example pipeline structure:
Custom System Prompts and Model Parameters
Per-model parameters (Admin → Models → Edit):
Per-chat system prompt (chat settings → System Prompt):
User Management and Access Control
Admin Panel → Users:
- Create users, assign roles (Admin, User)
- Set per-user model access
- View usage statistics
For teams:
- Disable public signup
- Create accounts manually
- Use groups for model access control (Enterprise feature)
Backups and Persistence
What to back up:
Automated backup script:
Add to crontab: 0 2 * * * /usr/local/bin/backup-homelab-ai.sh
Troubleshooting Common Issues
Open WebUI Can't Connect to Ollama
Out of Memory Errors
Fixes:
Slow Inference Speeds
| Issue | Fix |
|---|---|
| CPU-only on large model | Use smaller model (3B-7B) + q4_k_m |
| GPU not detected | Install nvidia-container-toolkit, check nvidia-smi in container |
| Swap thrashing | Add more RAM or reduce model size |
| First token slow | Normal — model loading. Keep model loaded: OLLAMA_KEEP_ALIVE=10m |
Model Not Found / Pull Failures
GPU Not Detected
Docker Permission Issues
Security Hardening for Production Homelabs
Reverse Proxy with TLS (Nginx/Traefik/Caddy)
Never expose port 3000 directly. Use a reverse proxy with automatic HTTPS.
Caddy (Simplest — Auto HTTPS via Let's Encrypt):
Traefik (If Already Using for Other Services):
Nginx (Manual Certs):
Authentication and Authorization
Open WebUI built-in:
- Admin creates all accounts (disable signup)
- Per-user model permissions
- API keys for programmatic access
Add SSO (OIDC/SAML) — Enterprise:
- Admin Panel → Settings → Authentication
- Configure Keycloak, Authentik, Authelia, Google, GitHub, Microsoft
Network-Level (Defense in Depth):
Network Isolation with Docker Networks
Rate Limiting and Abuse Prevention
At reverse proxy level (Caddy):
At Open WebUI level (Admin → Settings):
- Max message length
- Max file upload size
- Requests per minute per user
Regular Updates and Vulnerability Scanning
What's Next: Expanding Your Local AI Stack
Adding More Models for Different Tasks
Build a model zoo for specialized tasks:
Integrating with Automation (n8n, Home Assistant)
n8n Workflow Example:
- Webhook receives GitHub PR event
- Ollama analyzes code changes via Open WebUI API
- Posts summary as PR comment
Home Assistant:
- Voice assistant with local LLM (Wyoming + Open WebUI)
- Automation: "When motion detected, describe scene with LLaVA"
Building Custom Agents with Function Calling
Open WebUI Pipelines + Ollama tools = agents:
Fine-Tuning Models with LoRA
Monitoring and Observability
Prometheus + Grafana Stack:
Key metrics to alert on:
- GPU memory utilization > 90%
- Inference latency p99 > 30s
- Disk space < 10% free
- Container restart loops
Quick Reference: Complete Docker Compose
Deploy:
Verification Checklist
After deployment, verify each component:
- [ ] Ollama API responds:
curl http://localhost:11434/api/tags - [ ] Model pulls work:
docker exec ollama ollama pull llama3.1:8b-instruct-q4_k_m - [ ] Open WebUI loads:
http://your-ip:3000(or via reverse proxy) - [ ] Admin account created and signup disabled
- [ ] GPU detected:
docker exec ollama nvidia-smi(orrocm-smi) - [ ] Chat works: Send message, receive response
- [ ] RAG works: Upload PDF, ask question about it
- [ ] Web search works: Ask "What's the weather in Tokyo?"
- [ ] Reverse proxy works: HTTPS, valid cert, security headers
- [ ] Backups run: Test restore from backup
- [ ] Updates work:
docker compose pull && docker compose up -d
Summary
You now have a complete, production-ready local AI stack:
| Component | Purpose | Access |
|---|---|---|
| Ollama | Model runtime, API server | http://localhost:11434 (internal) |
| Open WebUI | Chat interface, RAG, pipelines | https://ai.yourdomain.com |
| Reverse Proxy | TLS, auth, rate limiting | Port 443 |
| Monitoring | Observability, alerts | Grafana dashboards |
Start small: One model (Llama 3.1 8B q4_k_m), CPU or single GPU, basic auth. Scale up: Add models, GPUs, RAG, pipelines, SSO, monitoring as needs grow.
The homelab AI journey is iterative. Each model you pull, each pipeline you build, each integration you automate teaches you more about running AI on your own terms — no API keys, no rate limits, no data leaving your network.
Production Ready
This stack has been tested on Ubuntu 22.04/24.04, Proxmox VE 8.x, Docker 27.x, Ollama 0.3.x, and Open WebUI 0.3.x. For production homelabs, add a reverse proxy with TLS, enable backups, and configure monitoring before exposing to the internet.
Last reviewed: August 2026 | Tested on: Ubuntu 22.04/24.04, Proxmox VE 8.x, Docker 27.x, Ollama 0.3.x, Open WebUI 0.3.x
No comments:
Please Don't Spam Comment Box !!!!