Meet Ollama: Running Chatbots at Home
Phase 3 · The AI Behemoth
The inference engine that turns a GGUF file into a running AI, and the systemd unit that makes it boot-safe.
A model on disk is a dictionary in a language no human speaks. The forty-five hundred megabytes of floating-point numbers are the knowledge; they are not the conversation. Something has to take that dictionary, load the weights into a GPU, accept a prompt, run the forward-pass maths, stream the tokens back out, and manage the memory when the next request arrives. That something is called an inference engine, and the one I settled on for the homelab is Ollama.
Ollama is not the only option. llama.cpp is the bedrock underneath it, vLLM is the high-throughput server engineers pick for serving many users at once, text-generation-webui is the kitchen-sink frontend for researchers. Ollama’s pitch is narrower: a single binary, a tidy CLI, a small HTTP API, models pulled by name from a central registry like Docker images. For a one-person homelab that wants to spend less time on inference plumbing and more time on the work downstream of it, that pitch is exactly right.
The Analogy
A chess engine is a game cartridge. The cartridge holds the rules and the openings and the positions, but the plastic does not move pieces. You need a console to plug the cartridge into. The console knows how to read the cartridge, display the board, accept your moves, and send the machine’s moves back out.
Ollama is the console for language models. You do not write the console; you plug in cartridges. Each cartridge is a GGUF file under a short name: llama3.1, mistral, phi3. You can have a dozen cartridges on the shelf. Pull them in with one command, switch between them with one command, and the console handles the hardware details. The power cord stays plugged in; only the cartridges change.
The Tech Translated
Ollama does three jobs. Each of them is the kind of thing you could build yourself, and the reason to use Ollama is that someone already built them well.
Model management. ollama pull llama3.1:8b fetches a versioned GGUF from the Ollama registry, verifies its hash, and stores it under ~/.ollama/models. The same model can be fetched on a second machine and will deduplicate against the first via content hashes. Cartridge in the shelf, reproducibly.
Runtime scheduling. When you ask for a model, Ollama loads it into GPU memory if there is room, falls back to system memory if there is not, and unloads it on a timer when idle. If you ask for a second model while the first is running, Ollama makes a choice: unload the idle one, or run both if the VRAM fits. You do not write that logic. You just ask.
A stable HTTP API. Every request to Ollama goes through a small HTTP server on localhost:11434. It accepts an OpenAI-compatible chat-completions endpoint (so code written against OpenAI’s SDK works unchanged) and Ollama’s native streaming API. This turns the inference engine into a boring, composable dependency: anything that can make an HTTP request can talk to it.
# Install and start Ollama on Ubuntu 22.04.
curl -fsSL https://ollama.com/install.sh | sh
# Pull three cartridges.
ollama pull llama3.1:8b-instruct-q4_K_M
ollama pull mistral:7b-instruct-q4_K_M
ollama pull phi3:mini
# Run one interactively.
ollama run llama3.1:8b-instruct-q4_K_M
# Or hit the API (for use inside scripts, apps, or your own UI).
curl -s http://localhost:11434/api/generate -d '{
"model": "llama3.1:8b-instruct-q4_K_M",
"prompt": "Draft a one-paragraph project kick-off email."
}'
Running it as a service
The installer drops in a systemd unit, but the default configuration serves only the loopback interface and uses /usr/share/ollama as the data dir. For a headless GPU node that other machines on the LAN will use, two small overrides are worth adding:
# /etc/systemd/system/ollama.service.d/override.conf
[Service]
# Bind to all interfaces so other LAN machines can reach it.
# Only safe behind a trusted firewall — the service has no auth.
Environment="OLLAMA_HOST=0.0.0.0:11434"
# Put models on the ZFS pool rather than the root filesystem.
Environment="OLLAMA_MODELS=/tank/ollama-models"
# Allow long requests without timing out the connection.
Environment="OLLAMA_KEEP_ALIVE=60m"
Reload and restart:
sudo systemctl daemon-reload
sudo systemctl restart ollama
sudo systemctl enable ollama
With that, every other machine on the trusted LAN can talk to the engine by HTTP. The AI node becomes a shared, private inference server. The laptop does not need a GPU.
Modelfiles: the small honest customisation
Ollama’s Modelfile is a Dockerfile-style declarative override on top of a base model. You compose a variant without retraining anything: shrink the context, pin a system prompt, change the temperature. The Modelfile itself is a tiny text file you version alongside your notes.
# File: Modelfile
FROM llama3.1:8b-instruct-q4_K_M
# Lower temperature: more deterministic for technical writing.
PARAMETER temperature 0.3
PARAMETER num_ctx 8192
SYSTEM """
You are a precise technical editor for an Australian English portfolio.
Prefer AU spelling (colour, realise, organise). Never use em dashes.
Keep answers to two paragraphs unless explicitly asked for more.
"""
Then build it once:
ollama create editor -f ./Modelfile
ollama run editor
editor now behaves like a named, reusable assistant with the house rules baked in.
The Action
What broke
The first benchmark on the new install was wildly slower than expected. A 7B model was generating about 12 tokens per second on a card I knew could hit 70+. The GPU was clearly loaded (nvidia-smi showed the memory was occupied) and the fans were spinning, but the numbers were off by a factor of five. An hour of reading forums, and the cause turned out to be dull: the installer had defaulted to the CPU-only build because the Nvidia driver was present but the CUDA runtime was one major version behind Ollama’s expectation.
The fix was a single explicit environment variable plus a CUDA runtime install:
sudo apt -y install nvidia-cuda-toolkit
sudo systemctl edit ollama # add Environment="OLLAMA_CUDA=1"
sudo systemctl restart ollama
# Sanity: confirm the GPU path is active.
journalctl -u ollama -n 200 | grep -i "cuda"
Re-run the benchmark: 72 tokens/second on the 7B model. The fix was trivial; finding it was not. The lesson I took: after install, always run journalctl -u ollama on startup and look for the line that says which compute backend Ollama chose. If it says “CPU”, something is off.
The daily interaction
I use Ollama three ways. From the terminal for quick questions (ollama run phi3 for fast drafts). From the editor Modelfile above when I want technical writing with my house rules. From my laptop’s personal scripts, which hit the HTTP API on the LAN when I want a summary of a long document or a first pass at a tough email.
None of these are theatrical. All of them run on a machine in a cupboard, on models I can read the licence of, at a cost of a few watts over the already-on baseline. The console is plugged in. The cartridges are on the shelf. The conversation happens in the house, on hardware I can reach out and touch.
Footnotes
-
Ollama is open source under the MIT licence; the project home is ollama.com. The underlying inference engine is llama.cpp by Georgi Gerganov: github.com/ggerganov/llama.cpp. ↩