Local LLM on Linux: Environment, Service and Troubleshooting

📘 Tutorials 2026-07-19 · Updated 2026-11-29 3 min read

Deploying an LLM on Linux means managing drivers, CUDA, systemd and firewall yourself. Here is the full path plus how to choose between Ollama, vLLM and llama.cpp.

📜 Table of Contents

📖 Keep reading

Choose the engine first

Engine Good for Avoid when Key trait
Ollama One user, one box, fast iteration High-concurrency API One-command service
vLLM Many users, throughput Under 16GB VRAM, old GPUs Continuous batching
llama.cpp CPU, low VRAM, heavy quantization You need full GPU throughput GGUF, partial offload

Step 1: Check the box

nvidia-smi
free -h
df -h /usr /home
nproc

Old drivers break CUDA containers outright. RAM must exceed the model size even on GPU, because loading stages through host memory; otherwise the OOM killer stops you with no model-level error in the logs.

Step 2: Install Ollama

curl -fsSL https://ollama.com/install.sh | sh
systemctl cat ollama

The installer already creates a systemd unit. Do not hand-write one that overwrites it. Configure with:

sudo systemctl edit ollama.service
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
Environment="OLLAMA_MODELS=/data/models"
Environment="OLLAMA_KEEP_ALIVE=30m"
Environment="OLLAMA_MAX_LOADED_MODELS=2"

Then systemctl daemon-reload && systemctl restart ollama.

Step 3: Confirm it is on the GPU

ollama run qwen2.5:7b "Explain vector search in one sentence"
ollama ps

The PROCESSOR column tells the truth: 100% GPU, 100% CPU, or a split. A split means partial offload and a real speed penalty. Skipping this check is how people end up benchmarking a CPU.

Step 4: Lock the port before exposing it

OLLAMA_HOST=0.0.0.0 gives anyone who reaches port 11434 free use of your GPU. Restrict with ufw to your intranet, or keep it on localhost and put Nginx with auth in front. Raise client_max_body_size or long-context requests will hit 413.

Step 5: Measure real throughput

POST /api/generate with "stream": false returns eval_count and eval_duration; divide them for tokens per second on your actual hardware. Keep the number as a baseline for quantization or model changes.

VRAM to model size

VRAM Comfortable Experience
8GB 7B-8B Q4 Daily usable
12GB 8B Q5 or 14B Q4 Clear quality step up
24GB 32B Q4 Close to small cloud models
48GB+ 70B Q4 Local ceiling
No dGPU 3B Q4 Verification only

Troubleshooting

Symptom Likely cause Fix
Exits on start, CUDA error Driver/image mismatch Upgrade driver or change tag
Killed during load Host RAM too small Add RAM or smaller model
Extremely slow Fell back to CPU Check ollama ps
Port unreachable Still bound to 127.0.0.1 Set OLLAMA_HOST or use a proxy
Answer cut off Context exceeded Lower context, bigger window model

FAQ

Q: Is Ubuntu required? A: No, but driver and CUDA answers are easiest to find for Ubuntu.

Q: Can a GPU-less server run this? A: Yes for 3B-7B Q4, a few tokens per second. Fine for batch jobs, not for chat.

Q: Do I need Docker? A: Not with Ollama. Docker helps for vLLM and LocalAI.

Q: Does upgrading lose models? A: Models live in OLLAMA_MODELS, untouched by binary upgrades.

Related Articles
2026-08-07
Text to Video: Open-Sora, HunyuanVideo and CogVideo in 2026
2026-08-01
Run Ollama on Android in 2026: 4 Apps Compared
2026-07-19
Ollama Complete Guide: The Easiest Way to Run LLMs Locally
2026-08-06
Typesense (26,402 Stars) 2026: High-Performance Typo-Tolerant Search with Vector Support
2026-07-24
Best No Code AI Chatbot Builders 2026 6 Platforms
2026-07-23
AI Model Deployment Strategies Compared: Batch vs Real-Time vs Edge 2026

Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.

💬 Comments (0)

No comments yet. Be the first!

Login to comment