# Ollama and Open WebUI on a GPU-VPS: your own AI chat

> Install the NVIDIA driver, Ollama and the Open WebUI web interface on a GPU-VPS with Ubuntu, choose a model by VRAM and access it securely over HTTPS or an SSH tunnel.

Source: https://www.hukot.net/community/en/tutorials/ollama-and-open-webui-on-a-gpu-vps-your-own-ai-chat
Updated: 2026-11-25

Open WebUI is a ChatGPT-like web interface; Ollama runs the language models on the graphics card behind it. The result is your own AI chat on a GPU-VPS: neither prompts nor documents leave your server, and you don't pay per token.

## Prerequisites

- A GPU-VPS with Ubuntu 24.04 or 26.04 LTS and SSH access with `sudo` rights.
- For HTTPS access, a domain or subdomain whose `A` record points to the server's IP address.

> [!NOTE]
> The commands run as a regular user with `sudo`. If you are logged in as root, leave out `sudo`.

## Which model to choose

The model has to fit entirely into the graphics card's memory (VRAM); otherwise the CPU takes over part of the work and answers slow down a lot. The sizes assume Ollama's default quantization and leave room for the context.

| GPU-VPS | VRAM | Suitable models |
|---|---:|---|
| RTX 3090 / RTX 4090 | 24 GB | `gpt-oss:20b`, `gemma3:27b`, `qwen3:30b`, `mistral-small3.2` |
| 2 × RTX 3090 | 48 GB | the same with a longer context, `llama3.3:70b` |
| RTX PRO 6000 Blackwell | 96 GB | `gpt-oss:120b`, `llama3.3:70b` with a long context |

> [!NOTE]
> From 48 GB of VRAM, Ollama sets a context of up to 256,000 tokens by default. With `llama3.3:70b` on 2 × RTX 3090 it then no longer fits in the GPU memory and the CPU takes over part of the work. Set a shorter context, for example `Environment="OLLAMA_CONTEXT_LENGTH=8192"` with `sudo systemctl edit ollama`, and check with `ollama ps` that the model runs fully on the GPU.

The current models and their sizes are listed in the [Ollama library](https://ollama.com/library).

## Installation

### Graphics card driver

1. Check that the system sees the card:

   ```bash
   nvidia-smi
   ```

   If the output shows the card's name and the driver version, continue with installing Ollama.

2. If the command doesn't exist, install the recommended server driver and restart the server:

   ```bash
   sudo apt update
   sudo apt install -y ubuntu-drivers-common
   sudo ubuntu-drivers install --gpgpu
   sudo reboot
   ```

3. After the restart, run `nvidia-smi` again.

> [!NOTE]
> The RTX PRO 6000 Blackwell needs driver 570 or newer with the open kernel modules (the package with `-open` in its name). `ubuntu-drivers` picks it on its own; just check that `nvidia-smi` lists the card.

### Ollama

1. Install Ollama with the official script. It registers Ollama as a systemd service and finds the NVIDIA driver by itself:

   ```bash
   sudo apt install -y curl zstd
   curl -fsSL https://ollama.com/install.sh | sh
   ```

2. Download a model from the table above and try it in the terminal:

   ```bash
   ollama pull gemma3:27b
   ollama run gemma3:27b "Write one sentence about Prague."
   ```

Ollama listens only on `127.0.0.1:11434`, that is, only inside the server.

> [!DANGER]
> Never expose port `11434` to the internet. The Ollama API has no login, and anyone could use your graphics card.

### Open WebUI

1. Install Docker from the official repository following [the Docker and Docker Compose installation tutorial](tutorial:286).

2. Start Open WebUI:

   ```bash
   sudo docker run -d --network=host \
     -e OLLAMA_BASE_URL=http://127.0.0.1:11434 \
     -e HOST=127.0.0.1 -e PORT=3000 \
     -v open-webui:/app/backend/data \
     --name open-webui --restart always \
     ghcr.io/open-webui/open-webui:main
   ```

3. Check that the interface listens only locally:

   ```bash
   sudo ss -tlnp | grep 3000
   ```

   The output should show `127.0.0.1:3000`. The first start takes a minute or two while it downloads the files it needs.

The container runs in the host's network (`--network=host`) so that it can reach Ollama on `127.0.0.1`. Docker therefore opens no port to the internet and doesn't bypass the firewall rules.

## Accessing the interface

::: tabs
+++ Via a domain (HTTPS)
Make the interface available through Nginx with a Let's Encrypt certificate.

1. Install Nginx and Certbot:

   ```bash
   sudo apt install -y nginx certbot python3-certbot-nginx
   ```

2. Create the file `/etc/nginx/sites-available/open-webui`:

   ```nginx
   server {
       listen 80;
       server_name <domain>;
       client_max_body_size 100M;

       location / {
           proxy_pass http://127.0.0.1:3000;
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection "upgrade";
           proxy_set_header Host $host;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-Forwarded-Proto $scheme;
           proxy_buffering off;
           proxy_read_timeout 300s;
       }
   }
   ```

   Replace `<domain>` with the domain pointing to the server, for example `ai.example.com`.

3. Enable the site and issue the certificate:

   ```bash
   sudo ln -s /etc/nginx/sites-available/open-webui /etc/nginx/sites-enabled/
   sudo nginx -t
   sudo systemctl reload nginx
   sudo certbot --nginx -d <domain>
   ```

4. If you use the UFW firewall, allow HTTP and HTTPS:

   ```bash
   sudo ufw allow 'Nginx Full'
   ```

The interface is then at `https://<domain>`. More on certificates in [Setting Up Let's Encrypt with Nginx Server](tutorial:65), on the firewall in [Setting up firewall with UFW on linux](tutorial:96).
+++ Just for you (SSH tunnel)
Without a domain and without opening any ports, reach the interface through an SSH tunnel from your computer:

```bash
ssh -L 3000:127.0.0.1:3000 <user>@<server-ip>
```

Replace `<user>` with your user on the server and `<server-ip>` with its IP address. While the connection is open, the interface is at `http://localhost:3000` in your browser.
:::

## First login

1. Open the interface in your browser and create an account. **The first registered account becomes the administrator**, so do this right after starting it.
2. In **Admin Panel** → **Settings** → **General**, turn off **Enable New Sign Ups** unless you want other people to register. You then create accounts for colleagues yourself in **Admin Panel** → **Users**.
3. Pick the model you downloaded with Ollama at the top and ask your first question.

## Checking that the model runs on the GPU

While a reply is being generated, run on the server:

```bash
ollama ps
```

The `PROCESSOR` column should say `100% GPU`. If you see a CPU share (for example `30%/70% CPU/GPU`), the model doesn't fit into VRAM. Choose a smaller model. `nvidia-smi` shows the card's load too.

## Updates

Update Ollama by running the install script again and Open WebUI with a new container image. The data (accounts, conversations) stays in the `open-webui` volume.

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

sudo docker pull ghcr.io/open-webui/open-webui:main
sudo docker rm -f open-webui
sudo docker run -d --network=host \
  -e OLLAMA_BASE_URL=http://127.0.0.1:11434 \
  -e HOST=127.0.0.1 -e PORT=3000 \
  -v open-webui:/app/backend/data \
  --name open-webui --restart always \
  ghcr.io/open-webui/open-webui:main
```

::: cta
## Want your own private AI chat?

Configure your GPU-VPS and get Ollama with Open WebUI running today.

[Choose a GPU-VPS configuration](https://www.hukot.net/en/gpu-vps/)
:::
