AI

Ollama + Local LLMs — Running AI Models on Your Own Hardware

Install Ollama on Linux, download open AI models and run them on your own GPU, then add a ChatGPT-style web page with Open WebUI. Your prompts never leave your network.

A Mohammed Habib Sep 01, 2026 15 min read 118 views Updated Oct 24, 2026
Cover for Ollama + Local LLMs — Running AI Models on Your Own Hardware

In this guide you'll install Ollama on a Linux machine, download an AI model, chat with it, and put a ChatGPT-style web page in front of it. Everything runs on your own hardware, so your prompts and documents never leave your network.

I run Ollama on a Proxmox VM with a GPU passed through to it. It serves code completion, document summaries and a few internal chatbots for my homelab, and not a single token goes to the cloud. A few years ago this meant downloading 40 GB of files, setting up CUDA by hand and fighting out-of-memory errors for hours. With Ollama it's one install command.

What you need

  • A Linux machine. I use Ubuntu 24.04 LTS. Ubuntu 22.04 or newer is fine. Ollama also runs on macOS and Windows, but this guide covers Linux.
  • RAM: 8 GB minimum, 32 GB recommended.
  • A GPU (optional but strongly recommended): an NVIDIA card with 8 GB or more of video memory (VRAM) is the easy path. AMD cards work through ROCm. Without a GPU everything still works on the CPU, only much slower.
  • Disk: at least 20 GB free. 100 GB or more on an SSD if you plan to try several models.
  • CPU: 4 cores minimum, 8 or more is better.
  • Docker if you want the web interface in Step 5.
  • A terminal and sudo access.

A few words first

  • LLM (large language model): the AI itself. It's a big file of numbers ("weights") that predicts text. ChatGPT, Claude and Llama are all LLMs.
  • Model: one specific LLM you can download, like llama3.2 or mistral. Models come in sizes measured in parameters: 3B means 3 billion, 70B means 70 billion. More parameters usually means smarter, but also bigger and slower.
  • Quantization: shrinking a model by storing its numbers with less precision. A 4-bit version (you'll see names like Q4_K_M) is roughly a quarter of the full size and loses surprisingly little quality. This is what makes big models fit on home GPUs.
  • VRAM: the memory on your graphics card. The whole model has to fit in it to run at full speed. This is the number that matters most.
  • Context window: how much text the model can "see" at once, counted in tokens (a token is roughly three-quarters of a word). It covers your question, the conversation so far and any documents you paste in.
  • API endpoint: a web address that programs send requests to. Ollama listens on http://localhost:11434.
  • OpenAI-compatible: Ollama accepts requests in the same format as OpenAI's API. Any tool built for OpenAI can talk to Ollama if you point it at Ollama's address instead.

What Ollama is

Platform Ollama (local LLM runtime)
Purpose Run open-source LLMs locally with GPU acceleration
License MIT (Ollama), model-specific licenses
Supported GPUs NVIDIA (CUDA), AMD (ROCm), Apple Silicon (Metal)
Repository github.com/ollama/ollama
Feature Details
Model Library 100+ pre-built models (Llama 3, Mistral, Qwen, Gemma, DeepSeek, Phi)
One-Line Install Single bash command, no Python environment needed
GPU Acceleration Auto-detects NVIDIA/AMD/Metal, no manual CUDA setup
OpenAI-Compatible API Drop-in replacement for the OpenAI API on localhost:11434
Model Management Pull, list, remove, and create custom models with Modelfiles
Multi-User Serve multiple concurrent requests from the same GPU
Open WebUI ChatGPT-like web interface for non-technical users

Why run models locally

Most AI tools send your data to OpenAI, Anthropic or Google. That causes three problems:

  1. Privacy. Sensitive code, internal documents and customer data leave your network.
  2. Cost. API usage adds up fast. A busy dev team can spend $500+ a month on code completion alone.
  3. Latency. Each round trip to a cloud API adds 200–500 ms.

Local models fix all three, but only if setup is easy enough that you keep using them. That's where Ollama earns its place.

PACKET ANALYSIS
Runtime
Ollama (Go binary, single executable)
Model Format
GGUF (quantized, 2–40 GB per model)
Default Port
11434 (HTTP API)
API Format
OpenAI-compatible (/v1/chat/completions)
GPU Detection
Automatic (CUDA, ROCm, Metal)
Storage
/usr/share/ollama/.ollama/models (Linux install script default)

How much VRAM each model size needs

PACKET ANALYSIS
1–3B models
4 GB VRAM (Phi-3, Qwen2-1.5B)
7B models
6–8 GB VRAM (Llama 3, Mistral, Gemma 2)
13–16B models
10–16 GB VRAM (qwen2.5-coder:14b, deepseek-coder-v2:16b)
34B models
20–24 GB VRAM (CodeLlama-34B, Yi-34B)
70B models
40–48 GB VRAM (Llama 3-70B, Qwen2-72B)

Rule of thumb: a 7B model at Q4_K_M quantization needs about 5 GB of VRAM. A 70B model at Q4_K_M needs about 40 GB. CPU-only works, but it's 10–50x slower.

If you're not sure what you have, start with a small model. You can always go bigger later.

Step 1: Install Ollama

Run the official install script:

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

The script downloads the Ollama program, creates a background service called ollama.service, checks for an NVIDIA or AMD GPU (and fetches the extra AMD support files if it finds one), and starts the service.

Check it worked. Run these three commands:

ollama --version
# ollama version 0.6.2   (yours will probably be newer)

systemctl status ollama
# ● ollama.service - Ollama Service
#      Active: active (running) since ...

curl http://localhost:11434/api/tags
# {"models":[]}

You want a version number, active (running), and a small JSON reply. The empty models list is expected: you haven't downloaded anything yet.

If you have an NVIDIA GPU

The installer only works with the GPU if the NVIDIA driver is already installed. Check:

nvidia-smi

If that prints a table with your card's name and memory, you're set. If the command isn't found, install the driver and reboot:

sudo apt install nvidia-driver-535 nvidia-utils-535 -y
sudo reboot

Driver 535 is the one I used. Newer driver versions work too.

If you have an AMD GPU

Ollama needs AMD's ROCm drivers on Linux. The Ollama Linux docs point to AMD's ROCm install guide and list which cards are supported. Install the driver from there, then rerun the Ollama install script so it picks up the GPU.

Step 2: Download and run your first model

Browse the available models at ollama.com/library. Each page lists the sizes and tags you can download.

These are good first picks:

Model Download size VRAM Best For
llama3.2 2.0 GB 4 GB General chat, fast
llama3.1:8b 4.9 GB 6 GB Balanced quality/speed
mistral 4.4 GB 6 GB Instruction following
qwen2.5-coder:7b 4.7 GB 6 GB Code generation
deepseek-coder-v2:16b 8.9 GB 10 GB Advanced coding
gemma2:9b 5.4 GB 8 GB General, from Google
llama3.1:70b 43 GB 48 GB Best quality (needs a big GPU)

The part after the colon is the tag. It usually picks the size. No tag means the default, which is usually a 4-bit quantized build.

Download a model with ollama pull:

# Llama 3.2: small, fast, good for testing
ollama pull llama3.2

# A coding model
ollama pull qwen2.5-coder:7b

# A larger model, if you have the VRAM
ollama pull llama3.1:8b

Check it worked. ollama list shows the models you've downloaded:

ollama list

Now chat with one:

ollama run llama3.2
# >>> What is the capital of France?
# The capital of France is Paris.

# >>> /bye  (to exit)

The first answer can take a few seconds while the model loads into memory. After that it should be quick.

Step 3: Confirm the GPU is doing the work

While a model is loaded (keep ollama run open in one terminal), open a second terminal and run:

ollama ps

Look at the PROCESSOR column. 100% GPU means the whole model is in VRAM, which is what you want. 100% CPU means the GPU isn't being used. A split like 48%/52% CPU/GPU means the model didn't fit in VRAM and part of it spilled into system RAM, which slows it down a lot.

You can also watch the card live:

watch -n 1 nvidia-smi

VRAM usage should jump when the model loads and GPU utilization should climb while it's answering.

Multiple GPUs

If a model fits on one GPU, Ollama loads it there. If it doesn't fit, Ollama spreads it across all available GPUs. You don't need to configure anything for that:

# Check available GPUs
nvidia-smi -L
# GPU 0: NVIDIA GeForce RTX 4090 (24576 MiB)
# GPU 1: NVIDIA GeForce RTX 4090 (24576 MiB)

# A 70B model won't fit on one 24 GB card, so Ollama uses both
ollama pull llama3.1:70b
ollama run llama3.1:70b

Forcing CPU-only

If no GPU is found, Ollama falls back to the CPU on its own. To force CPU mode on purpose (for testing), the setting has to go on the Ollama server, not on the ollama run command. Use the same systemctl edit method shown in Step 7 and add:

[Service]
Environment="CUDA_VISIBLE_DEVICES=-1"

For AMD cards the variable is ROCR_VISIBLE_DEVICES=-1. Remove the line and restart Ollama to go back to the GPU.

Step 4: Use the API

Everything you can do in the chat window, programs can do over HTTP. Ollama exposes an OpenAI-compatible API on port 11434.

A basic request

curl http://localhost:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama3.2",
    "messages": [
      {"role": "user", "content": "Write a Python function to check if a number is prime"}
    ]
  }'

Check it worked. You get back JSON. The answer is in choices[0].message.content.

Streaming

With "stream": true the answer arrives word by word instead of all at once, like in ChatGPT:

curl http://localhost:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama3.2",
    "messages": [{"role": "user", "content": "Hello"}],
    "stream": true
  }'

From Python with requests

import requests

response = requests.post(
    "http://localhost:11434/v1/chat/completions",
    json={
        "model": "llama3.2",
        "messages": [{"role": "user", "content": "Explain Docker in 3 sentences"}],
        "stream": False
    }
)

print(response.json()["choices"][0]["message"]["content"])

From Python with the OpenAI SDK

This is where "OpenAI-compatible" pays off. Code written for OpenAI works after you change the address:

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:11434/v1",
    api_key="ollama"  # Ollama doesn't require a real key
)

response = client.chat.completions.create(
    model="llama3.2",
    messages=[{"role": "user", "content": "Hello"}]
)

print(response.choices[0].message.content)

Reaching Ollama from other machines

By default Ollama only listens on 127.0.0.1, so only the machine it runs on can use it. To let other computers on your network connect, set OLLAMA_HOST with the systemctl edit method from Step 7:

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"

Ollama's API has no password. Only do this on a network you trust, and block port 11434 from the internet.

Step 5: Add a web interface with Open WebUI

Open WebUI gives you a ChatGPT-style page in the browser. It's the easiest way to get people who don't use a terminal to try your models.

Install it with Docker:

docker run -d \
  --name open-webui \
  --network host \
  -v open-webui:/app/backend/data \
  -e OLLAMA_BASE_URL=http://localhost:11434 \
  --restart unless-stopped \
  ghcr.io/open-webui/open-webui:main

--network host lets the container reach Ollama on localhost. -v open-webui:... keeps your chats and accounts when the container is updated.

Check it worked. Open http://YOUR_SERVER_IP:8080 in your browser. The first account you create becomes the admin. Your Ollama models should appear in the model dropdown at the top of a new chat.

What you get:

Feature Details
Chat Interface ChatGPT-like UI with conversation history
Model Selection Dropdown to pick any Ollama model
RAG (Retrieval) Upload documents and ask questions about them
Image Generation Integration with DALL-E or Stable Diffusion
Multi-User User accounts with admin controls
API Keys Generate API keys for external tools

Step 6: Make custom models with a Modelfile

A Modelfile is a short text file that builds a new model on top of an existing one. You give it standing instructions (the system prompt) and settings. Three settings show up below:

  • temperature: how random the answers are. Lower is more focused and repeatable.
  • top_p: another randomness control. 0.9 is a common value.
  • num_ctx: the context window in tokens. Ollama's default is 4096. Bigger lets the model read more at once but uses more memory.

Example: a code reviewer

cat << 'EOF' > Modelfile
FROM qwen2.5-coder:7b

SYSTEM """You are a senior code reviewer. When given code:
1. Identify bugs and security issues
2. Suggest performance improvements
3. Check for style violations
4. Rate the code quality (1-10)
Be concise and specific."""

PARAMETER temperature 0.3
PARAMETER top_p 0.9
PARAMETER num_ctx 8192
EOF

ollama create code-reviewer -f Modelfile
ollama run code-reviewer

Check it worked. code-reviewer now shows up in ollama list. Paste in a function and it should answer in the review format above.

Example: a documentation writer

cat << 'EOF' > Modelfile
FROM llama3.1:8b

SYSTEM """You are a technical documentation writer. Write clear, concise documentation
for code. Follow these rules:
- Use active voice
- Include code examples
- Keep sentences under 25 words
- Use markdown formatting"""

PARAMETER temperature 0.5
PARAMETER num_ctx 16384
EOF

ollama create doc-writer -f Modelfile

Step 7: Manage the service

The installer runs Ollama as a systemd service, so it starts on boot.

sudo systemctl start ollama
sudo systemctl stop ollama
sudo systemctl restart ollama

Follow the logs live (useful when something goes wrong):

sudo journalctl -u ollama -f

Changing Ollama's settings

Every server setting in this guide (OLLAMA_HOST, OLLAMA_MODELS, CUDA_VISIBLE_DEVICES) is set the same way:

  1. Run sudo systemctl edit ollama. An editor opens.
  2. Add the setting under a [Service] line.
  3. Save, then reload and restart.

Example: store models on another drive

Models are large. Here's how to move them to a bigger or faster disk:

# Create the folder and give the ollama user access
sudo mkdir -p /mnt/fast-ssd/ollama
sudo chown -R ollama:ollama /mnt/fast-ssd/ollama

# Edit the service
sudo systemctl edit ollama
# Add:
# [Service]
# Environment="OLLAMA_MODELS=/mnt/fast-ssd/ollama"

sudo systemctl daemon-reload
sudo systemctl restart ollama

Check it worked. Run ollama pull llama3.2 and watch files appear under /mnt/fast-ssd/ollama. Models you downloaded before the change stay in the old folder, so pull them again.

Troubleshooting

ollama commands say they can't connect to the server. The service isn't running. Check systemctl status ollama, start it with sudo systemctl start ollama, and read sudo journalctl -u ollama for the reason it stopped.

"address already in use" when you run ollama serve. The service is already running on port 11434. You don't need ollama serve on Linux; the systemd service does that job.

Answers are painfully slow and ollama ps shows CPU. The GPU isn't being used. Run nvidia-smi. If it fails, the driver is missing or broken: reinstall it and reboot. If it works, check the Ollama logs for GPU errors. If ollama ps shows a CPU/GPU split instead, the model is too big for your VRAM. Pick a smaller model or a smaller tag.

Out-of-memory errors or the model stops mid-answer. Same cause: not enough VRAM. Close other GPU programs, use a smaller model, or lower num_ctx, because a bigger context window uses more memory.

Open WebUI shows no models. Open WebUI can't reach Ollama. With --network host, check that curl http://localhost:11434/api/tags works on the server. If you run Open WebUI on a different machine, set OLLAMA_HOST=0.0.0.0:11434 on the Ollama server and use its IP in OLLAMA_BASE_URL.

Permission denied after moving the model folder. The ollama user can't write there. Run sudo chown -R ollama:ollama on the new folder and restart the service.

What I'd tell anyone building one

  1. Start with llama3.2 or qwen2.5-coder:7b. Don't jump to 70B models. A 7B model at 4-bit quantization runs on any modern GPU and handles most everyday tasks well.

  2. VRAM is the bottleneck, not system RAM. A 70B model needs about 40 GB of VRAM: two RTX 4090s or one A100. Without that, stay with 7–13B models. On CPU alone expect 5–15 tokens per second, against 50–100+ on a GPU.

  3. Use quantized models. Q4_K_M and Q5_K_M give the best quality for their size. Q8 is nearly lossless but twice as big. FP16 (full precision) is almost never worth the VRAM.

  4. The OpenAI-compatible API is the best part. Tools that work with OpenAI's API (Continue, LangChain, LiteLLM) work with Ollama once you change the base URL.

  5. Open WebUI gets other people using it. Your non-technical colleagues won't use curl. Give them a browser page with a model dropdown and they will.

  6. Watch VRAM. Keep watch -n 1 nvidia-smi open while testing. Above about 95% usage you'll see slowdowns or out-of-memory errors. Leave 1 GB free.

Next steps

  • Connect a code editor. The Continue extension for VS Code works with Ollama through the same base URL used above.
  • Upload a few PDFs in Open WebUI and ask questions about them.
  • Write a Modelfile for a task you repeat every week.

Last updated: 2026-09-01. Tested on Ubuntu 24.04 LTS with an NVIDIA RTX 4090 (24 GB VRAM), Ollama v0.6.2 and Open WebUI v0.6+.

Comments (0)

Join the discussion — sign in to comment.

Sign in

No comments yet — be the first to share your thoughts.

Related reading