Short answer: on an Ubuntu server with an NVIDIA card it takes four steps and about 20 minutes: install the driver, install Ollama, pull a model, and start Open WebUI for a chat in the browser. Nothing has to be open to the internet; you reach the chat through an SSH tunnel.
This guide uses an Ubuntu 24.04 GPU server with root access. The commands are the same on our GPU servers and on any other machine with an NVIDIA card.
Which card your model needs is in How Much VRAM Do You Need for an LLM?. In short: 12 GB for 8B models, 24 GB for 32B models.
01Install the NVIDIA Driver
Log in over SSH and run:
sudo apt update && sudo apt upgrade -y
sudo apt install -y ubuntu-drivers-common
sudo ubuntu-drivers install
sudo rebootLog in again after a minute and check the card:
nvidia-smiYou should see the card's name and its full memory, for example NVIDIA GeForce RTX 3090 ... 24576MiB. You don't need the CUDA toolkit: Ollama ships its own CUDA libraries. More on drivers in the help center.
02Install Ollama
curl -fsSL https://ollama.com/install.sh | shThe script installs Ollama as a service, finds the NVIDIA card and starts listening on 127.0.0.1:11434, which means only the server itself can reach it.
03Pull and Test a Model
ollama run llama3.1:8bThe first run downloads the model (about 5 GB), then you can chat in the terminal. Type /bye to leave. In a second SSH window, check where it runs:
ollama psThe PROCESSOR column should say 100% GPU. If it shows a CPU share, the model is too big for the card; pick a smaller one or a smaller quantisation. Bigger models to try, by card:
| Card | Try |
|---|---|
| 12 GB | llama3.1:8b, qwen2.5:7b, qwen2.5-coder:7b |
| 16 GB | qwen2.5:14b, phi4:14b |
| 24 GB | mistral-small:24b, qwen2.5:32b, qwen2.5-coder:32b |
04Add Open WebUI for a Chat in the Browser
Open WebUI is a ChatGPT-style interface for Ollama. Install Docker, then start it on the host network so it reaches Ollama on localhost:
curl -fsSL https://get.docker.com | sh
sudo docker run -d --network=host \
-v open-webui:/app/backend/data \
-e OLLAMA_BASE_URL=http://127.0.0.1:11434 \
--name open-webui --restart always \
ghcr.io/open-webui/open-webui:mainIt listens on port 8080. Close that port to the outside with the firewall, keeping SSH open:
sudo ufw allow OpenSSH
sudo ufw enable05Open the Chat Through an SSH Tunnel
On your own computer:
ssh -L 8080:127.0.0.1:8080 root@YOUR_SERVER_IPLeave that window open and visit http://localhost:8080 in your browser. The first account you create becomes the admin. Pick the model at the top and chat. Everything stays between your computer and your server.
Want to use it from your phone or share it with a team? Put it behind a reverse proxy like Caddy with HTTPS and a login, or use a private network like Tailscale or WireGuard. Don't open port 8080 or 11434 to the internet without a login in front.
06Use It From Your Own Code
Ollama speaks an OpenAI-compatible API, so most libraries work with a changed base URL. Through the same kind of tunnel (ssh -L 11434:127.0.0.1:11434 root@YOUR_SERVER_IP):
from openai import OpenAI
client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")
reply = client.chat.completions.create(
model="llama3.1:8b",
messages=[{"role": "user", "content": "Summarise this in one sentence: ..."}],
)
print(reply.choices[0].message.content)The key can be any text; Ollama does not check it.
07Keep It Running
- Ollama and Open WebUI start on their own after a restart: Ollama as a service, Open WebUI through
--restart always. - Update Ollama by running the install command again.
- Update Open WebUI with
sudo docker pull ghcr.io/open-webui/open-webui:main, then remove and start the container again with the same command. Your chats stay in theopen-webuivolume. - Keep a model loaded between requests with
OLLAMA_KEEP_ALIVE=-1in the service (sudo systemctl edit ollama), so the first answer after a pause doesn't wait for loading.
No. The NVIDIA driver is enough; Ollama ships the CUDA libraries it needs.
The model plus its context doesn't fit in the card's memory. Use a smaller model, a smaller quantisation, or a shorter context.
Yes. Open WebUI has user accounts, and Ollama answers requests in parallel. With several users, a card with more bandwidth like the RTX 3090 keeps answers fast.
The model runs on your server and nothing is sent to an AI company. Keep the ports closed and use the SSH tunnel, and the chats stay between you and your server.
- self host llm
- ollama gpu server
- open webui server
- private chatgpt
- host llm on gpu server
- ollama nvidia
- self hosted ai