Ollama - Self Hosted AI¶
Reference page
I'm not running Ollama right now. This page is kept as a reference for running local models on a desktop GPU (AMD RX 6800 XT, ROCm). Commands are for Debian.
Ollama Installation¶
Official script:
This will auto detect hardware and install necessary dependancies
curl -fsSL https://ollama.com/install.sh | sh
To run a model, use:
ollama run gemma3 or ollama run qwen2.5-coder:14b
Models¶
Models I used at the time (newer ones exist, check the Ollama library):
| Category | Model | Size | Speed | Use Case |
|---|---|---|---|---|
| Coding | Qwen 2.5 Coder 32B | 19GB | Medium | Complex scripts, Docker, Python, Arch Linux help. |
| Logic | DeepSeek R1 32B | 19GB | Medium | Debugging weird errors, math, logic puzzles. |
| Writing | Gemma 2 27B | 16GB | Fast/Med | Emails, documentation, stories, cover letters. |
| Speed | Llama 3.1 8B | 5GB | Instant | Quick facts, summarization, simple chat. |
Quick Pull List¶
You can copy and paste this block to download them all at once:
ollama pull qwen2.5-coder:32b
ollama pull deepseek-r1:32b
ollama pull gemma2:27b
ollama pull llama3.1
Open-WebUI¶
For a nice GUI, you can use Open-WebUI.
This compose assumes you have ollama running on host machines. For other configs, check the docs
https://github.com/open-webui/open-webui
### --- OpenWebUI - Interface for Ollama --- ###
# https://github.com/open-webui/open-webui
services:
open-webui:
image: ghcr.io/open-webui/open-webui:main # pin a release tag in production
container_name: open-webui
restart: always
# host networking lets the container reach Ollama on 127.0.0.1:11434; the UI is then on port 8080
network_mode: host
#ports:
# - "3000:8080"
volumes:
- ./open-webui-data:/app/backend/data
extra_hosts:
- host.docker.internal:host-gateway
Access this at http://localhost:8080.
Note
To correctly show models in the WebUI, I had to manually set the connections (admin page > settings) for Ollama API as http://127.0.0.1:11434
ROCm¶
ROCm (Radeon Open Compute) is AMD's open-source software stack for GPU computing.
This is needed to use the GPU as compute instead of just for graphical reasons.
Installation: Ollama's install script downloads its own ROCm runtime libraries for supported AMD cards, so on
Debian you usually only need the in-kernel amdgpu driver (already in Debian's kernel) and the firmware:
sudo apt install firmware-amd-graphics # from non-free-firmware
sudo usermod -aG render,video ollama # the install script normally does this
rocm-smi (used below) is packaged in Debian: sudo apt install rocm-smi. For the full ROCm stack (other ROCm
apps), follow AMD's guide and pick Debian 13 where it's listed:
https://rocm.docs.amd.com/projects/install-on-linux/en/latest/install/quick-start.html
After installation, to verift it is working run:
watch -n 1 rocm-smi
This will monitor the GPU so you can watch it work.
While monitoring, run:
ollama run qwen2.5-coder:14b "some fancy shit here in rust"
You should see the GPU spike.
OR
Check the boot logs. Ollama is pretty clear on what is being used.
sudo journalctl -u ollama --no-pager | grep "rocm"
Optimization¶
xpand Context Window¶
By default, Ollama uses a 4,096 token context window. This is too small for large code files or pasting logs. 6800 XT (16GB VRAM) has enough room to run the 14B model with a much larger "memory" of your conversation.
- Goal: Increase context to 16k or 32k.
- Why: Allows the model to see your entire config file or script at once.
How to set it permanently:
-
Edit the Ollama service:
-
Add these environment variables to the
[Service]section:[Service] # Listen on all interfaces (the API has no authentication: firewall port 11434 to trusted hosts) Environment="OLLAMA_HOST=0.0.0.0" # Enable Flash Attention (Crucial for RDNA2 performance at high context) Environment="OLLAMA_FLASH_ATTENTION=1" # Set default context to 32k (fits in your 16GB VRAM with 14B model) Environment="OLLAMA_CONTEXT_LENGTH=32768" -
Save, exit, and restart:
Model Selection¶
You have 64GB RAM, which puts you in a unique position. You can run models larger than your GPU VRAM.
- The "Daily Driver" (Fast & Capable):
qwen2.5-coder:14b - VRAM Usage: ~9GB (Model) + ~2-4GB (Context). Fits 100% on GPU.
- Speed: Instant.
- Use case: General questions, writing small scripts, Linux commands.
-
Optimization: Create a custom model file to lock in parameters (see below).
-
The "Heavy Lifter" (Maximum Accuracy):
qwen2.5-coder:32b - VRAM Usage: ~20GB.
- Your Setup: 16GB on GPU + ~4GB spillover to System RAM.
- Speed: Slower (expect 4-8 tokens/sec), but significantly smarter at complex logic.
- Use case: Debugging a complex race condition, architecting a new system, or when 14B gets stuck.
Recommendation: Keep both. Use 14B for speed, switch to 32B when you need a "senior engineer" to look at your code.
Model File¶
Don't just use the raw model. Create a custom "Modelfile" to bake in your preferences (Linux, Docker, minimal fluff).
- In Open WebUI, go to Workspace (left sidebar) -> Models -> Create a Model.
- Name:
username-Coder-14B - Base Model:
qwen2.5-coder:14b - System Prompt:
You are an expert Linux flight simulation technician and DevOps engineer. You prefer "Gruvbox" aesthetics where applicable. You specialize in Docker, Self-Hosting, and System Administration. Guidelines:
- When providing code, use strictly official documentation sources.
- Do not use conversational filler ("Here is the code you asked for"). Just provide the solution.
- Prefer
docker composeoverdocker run.- Assume a modern Linux environment (Debian).
- Advanced Params:
- Temperature:
0.2(Lower is better for code; prevents hallucinations). -
Context Length:
32768(Ensure this matches your hardware capability). -
Save & Use.
Specific model locations¶
# Create the folder
sudo mkdir -p /mnt/fast_ssd/ollama_models
# (Optional) Move existing models if you already downloaded some
sudo mv /usr/share/ollama/.ollama/models/* /mnt/fast_ssd/ollama_models/
sudo chown -R ollama:ollama /mnt/fast_ssd/ollama_models
sudo chmod -R 775 /mnt/fast_ssd/ollama_models
Update systemd service:
Add this to .service
restart
Verify
Check folder