How to Run Local LLMs with Ollama and Open WebUI on Ubuntu (Docker + NVIDIA GPU)

Overview

This step-by-step guide shows you how to run modern local large language models (LLMs) on Ubuntu using Ollama and Open WebUI with Docker and NVIDIA GPU acceleration. You will deploy a private, browser-based chat interface backed by fast local inference, ideal for secure prototyping, offline work, and cost control. The tutorial covers prerequisites, installation, configuration, persistence, and troubleshooting.

Prerequisites

Before you begin, make sure you have the following on your Ubuntu 22.04/24.04 host:

  • 64-bit Ubuntu with at least 16 GB RAM (more is better for larger models).
  • NVIDIA GPU (Turing or newer recommended) with recent drivers installed.
  • Admin (sudo) access and a stable internet connection.

1) Install NVIDIA Drivers and Container Toolkit

Install or verify the NVIDIA driver, then set up the NVIDIA Container Toolkit so Docker can use the GPU inside containers.

sudo apt update
ubuntu-drivers devices
# Choose the recommended driver (e.g., nvidia-driver-550) and install:
sudo apt install -y nvidia-driver-550
sudo reboot

After reboot, verify your GPU:

nvidia-smi

Install the NVIDIA Container Toolkit:

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit.gpg

distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -fsSL https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

sudo apt update
sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

2) Install Docker and the Compose Plugin

If Docker is not installed, add the official repository and install Docker Engine and the Compose plugin:

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
  https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker $USER
newgrp docker

3) Create a Docker Network and Volumes

A dedicated Docker network allows containers to talk to each other by name. Volumes ensure models and app data persist across container restarts.

docker network create ollama-net
docker volume create ollama
docker volume create open-webui

4) Run Ollama with GPU Acceleration

Start the Ollama container, expose the API port (11434), and attach the GPU. The volume keeps downloaded models persistent.

docker run -d \
  --name ollama \
  --gpus all \
  --network ollama-net \
  -p 11434:11434 \
  -v ollama:/root/.ollama \
  --restart unless-stopped \
  ollama/ollama:latest

Verify the API is reachable:

curl http://localhost:11434/api/tags

5) Deploy Open WebUI and Link It to Ollama

Open WebUI provides a clean browser-based chat interface for Ollama. Connect it to the Ollama container via the internal Docker network.

docker run -d \
  --name open-webui \
  --network ollama-net \
  -p 3000:8080 \
  -e OLLAMA_API_BASE=http://ollama:11434 \
  -v open-webui:/app/backend/data \
  --restart unless-stopped \
  ghcr.io/open-webui/open-webui:latest

Open your browser to http://localhost:3000 and complete the initial setup. By default, Open WebUI will detect the Ollama API base you provided and list available models once you pull them.

6) Pull a Model and Run Your First Chat

Use the Ollama CLI inside the container to download a model. For a good balance of performance and quality on consumer GPUs, start with an 8B or 7B quantized build.

docker exec -it ollama ollama pull llama3.1:8b-instruct-q4_K_M

Test generation via API:

curl -s http://localhost:11434/api/generate -d '{
  "model": "llama3.1:8b-instruct-q4_K_M",
  "prompt": "In one sentence, explain what Ollama does."
}'

In Open WebUI (http://localhost:3000), select the pulled model from the model dropdown and start chatting. You can adjust context size and GPU usage per chat in the advanced parameters.

7) Enable Persistence, Updates, and Autostart

Because you used named volumes, your models and Open WebUI data (users, chats, settings) persist through upgrades. To update, pull the latest images and recreate containers:

docker pull ollama/ollama:latest
docker pull ghcr.io/open-webui/open-webui:latest
docker stop open-webui ollama
docker rm open-webui ollama
# Re-run the docker run commands from steps 4 and 5

The --restart unless-stopped policy ensures both services start automatically after a system reboot.

8) Performance Tuning Tips

- Use quantized model variants (e.g., q4_K_M or q5_K_M) for faster inference with lower VRAM usage.

- For larger GPUs, try higher quality quantization (q6_K or q8_0) or larger models (e.g., 12B/13B) if VRAM allows.

- In Open WebUI’s advanced options, set num_ctx (e.g., 4096 or 8192) and increase num_gpu to offload more layers to the GPU. Start conservative and scale up if stable.

- Monitor GPU and memory with nvidia-smi while generating to right-size model and context length.

9) Securing Access

If you plan to access Open WebUI over the network, enable authentication in Settings and front it with a reverse proxy such as Caddy or Nginx for TLS. Avoid exposing the Ollama API directly to the internet. Restrict firewall rules to trusted IPs or a VPN.

Troubleshooting

GPU not used: If inference is slow and nvidia-smi shows 0% usage, confirm the container sees GPUs (docker run --rm --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smi). Re-run step 1 to fix NVIDIA toolkit integration, then restart Docker.

Permission denied to Docker: If docker commands require sudo, add your user to the docker group (sudo usermod -aG docker $USER; newgrp docker).

Port already in use: Change -p mappings (e.g., -p 11435:11434 or -p 3001:8080) and update OLLAMA_API_BASE in the Open WebUI container accordingly.

Out of memory or crashes: Use a smaller or more heavily quantized model, reduce num_ctx, or close other GPU workloads. Check container logs (docker logs ollama and docker logs open-webui).

Model not listed in WebUI: Ensure Open WebUI can reach Ollama via the internal name (ollama). Both containers must be on the same Docker network. Verify with curl http://ollama:11434/api/tags inside the open-webui container (docker exec -it open-webui sh).

What You Achieved

You now have a private, GPU-accelerated LLM stack on Ubuntu using Docker, Ollama, and Open WebUI. This setup lets you iterate quickly, control data residency, reduce costs, and stay productive even without an internet connection. You can add more models with docker exec -it ollama ollama pull <model> and switch between them in the WebUI as your use cases evolve.

How to Run Ollama + Open WebUI with GPU on Ubuntu Using Docker Compose

Local large language models (LLMs) have matured rapidly, and running them with GPU acceleration on your own server is now simple. In this step-by-step tutorial, you will deploy Ollama (model runtime) and Open WebUI (a friendly chat interface) on Ubuntu 22.04/24.04 using Docker Compose and the NVIDIA Container Toolkit.

Prerequisites

- An Ubuntu 22.04 or 24.04 machine with an NVIDIA GPU (Turing or newer recommended) and internet access.

- Administrative (sudo) access.

- Basic familiarity with the terminal and Docker.

1) Install NVIDIA Driver

First, make sure your system is up to date, then install the recommended NVIDIA driver. If you are already on the correct proprietary driver, you can skip this step.

sudo apt update && sudo apt upgrade -y
sudo ubuntu-drivers autoinstall
sudo reboot

After reboot, confirm the GPU is available:

nvidia-smi

You should see a table with your GPU model and driver version.

2) Install Docker Engine

Use the convenience script from Docker to install the latest Docker Engine quickly. Alternatively, follow the official repository instructions if you prefer a locked version.

curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
newgrp docker

Verify Docker is working:

docker run --rm hello-world

3) Install NVIDIA Container Toolkit

The NVIDIA Container Toolkit lets containers access your GPU. Install it and configure Docker to use the NVIDIA runtime.

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg

curl -fsSL https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

sudo apt update
sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

Test GPU access inside a container:

docker run --rm --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smi

If you see your GPU, you are ready for Ollama.

4) Create a Docker Compose file

Make a project directory and create a docker-compose.yml that runs both services with persistent volumes and GPU support.

mkdir -p ~/ollama-webui && cd ~/ollama-webui
nano docker-compose.yml
version: "3.9"
services:
  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    restart: unless-stopped
    ports:
      - "11434:11434"
    environment:
      - OLLAMA_KEEP_ALIVE=24h
    volumes:
      - ollama:/root/.ollama
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

  open-webui:
    image: ghcr.io/open-webui/open-webui:main
    container_name: open-webui
    restart: unless-stopped
    depends_on:
      - ollama
    environment:
      - OLLAMA_API_BASE_URL=http://ollama:11434
      - WEBUI_AUTH=true
    ports:
      - "3000:8080"
    volumes:
      - openwebui:/app/backend/data

volumes:
  ollama:
  openwebui:

Note: The deploy.resources.devices block requests GPU access using the NVIDIA driver. Docker Compose v2+ supports this on modern hosts. If your Compose version ignores it, see the troubleshooting section for alternatives.

5) Start the stack

Bring up both containers in the background:

docker compose up -d
docker compose ps

Open your browser to http://localhost:3000 (or the server’s IP on port 3000). The web interface will prompt for account setup if authentication is enabled.

6) Pull and run a model

You can pull models from the UI (Models section), or via CLI inside the Ollama container. Example with Llama 3.1 (8B):

docker exec -it ollama ollama pull llama3.1:8b

Once the model is downloaded, select it in Open WebUI and start chatting. GPU memory matters: 8B models typically need ~6–8 GB VRAM; 70B needs much more. If you are low on VRAM, try smaller or quantized variants (e.g., Q4_K_M builds).

7) Persistence, updates, and backups

- Your models and settings live in Docker volumes named “ollama” and “openwebui.” To back them up, stop the stack and archive /var/lib/docker/volumes/ollama and /var/lib/docker/volumes/openwebui.

- To update images: docker compose pull && docker compose up -d.

- To move the setup to another host, copy the Compose file and restore the volumes.

8) Secure access (optional)

For internet exposure, place Open WebUI behind a reverse proxy with TLS (e.g., Caddy or Nginx) and keep WEBUI_AUTH=true. Consider network ACLs or a VPN like Tailscale/WireGuard for private, zero-trust access.

Troubleshooting

- GPU not detected in containers: ensure nvidia-smi works on the host; re-run sudo nvidia-ctk runtime configure --runtime=docker; restart Docker; try docker compose down && up -d.

- If your Compose version ignores deploy.devices, try adding a profile or running with CLI flags. For example, launch Ollama separately:

docker run -d --name ollama --gpus all -p 11434:11434 \
  -v ollama:/root/.ollama --restart unless-stopped ollama/ollama:latest

- Performance tips: set model context length lower in WebUI, avoid running multiple models at once, and monitor VRAM usage with nvidia-smi.

With this setup, you get a modern, GPU-accelerated local LLM stack that is fast, private, and easy to maintain using Docker Compose. Enjoy building AI workflows without sending your data to the cloud.

Install Ollama and Open WebUI on Ubuntu 24.04 with NVIDIA GPU Acceleration (Step-by-Step)

Overview

Running a local large language model (LLM) is easier than ever thanks to Ollama and Open WebUI. Ollama handles model downloads and inference, while Open WebUI gives you a clean, chat-style interface in your browser. In this tutorial, you'll install both on Ubuntu 24.04 (works on 22.04 too), enable NVIDIA GPU acceleration, and deploy them with Docker Compose. The result is a fast, private AI stack you control.

What You'll Need

- Ubuntu 24.04 or 22.04 (fresh or existing server/desktop).
- An NVIDIA GPU with recent drivers (Turing/RTX or newer recommended).
- Root or sudo access.
- Open ports 3000 (Open WebUI) and 11434 (Ollama) on your firewall if you access remotely.

Step 1: Install NVIDIA Drivers and Verify CUDA

First, update your system and install the recommended NVIDIA driver. On Ubuntu Desktop you can use Additional Drivers, but the CLI route is reliable:

sudo apt update && sudo apt -y upgrade
sudo ubuntu-drivers autoinstall
sudo reboot

After reboot, confirm the GPU is visible:

nvidia-smi

If you see a driver table with your GPU, you're set. If not, re-run the install or check Secure Boot status (disable or enroll the MOK as needed).

Step 2: Install Docker, Compose, and NVIDIA Container Toolkit

Install Docker from the official repository so you get the latest engine and the Compose plugin:

sudo apt-get remove -y docker docker.io containerd runc || true
sudo apt update
sudo apt install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release; echo $VERSION_CODENAME) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker $USER
newgrp docker

Add NVIDIA Container Toolkit so Docker can access the GPU:

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
distribution=$(. /etc/os-release; echo $ID$VERSION_ID)
curl -fsSL https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#' | sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt update
sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

Verify Docker can see the GPU:

docker run --rm --gpus all nvidia/cuda:12.3.2-base-ubuntu22.04 nvidia-smi

Step 3: Create a Docker Compose File for Ollama and Open WebUI

Create a working directory and a docker-compose.yml:

mkdir -p ~/ollama-openwebui && cd ~/ollama-openwebui
nano docker-compose.yml

Paste the following content, then save:

version: "3.9"
services:
ollama:
image: ollama/ollama:latest
container_name: ollama
restart: unless-stopped
ports:
- "11434:11434"
volumes:
- ollama:/root/.ollama
environment:
- OLLAMA_KEEP_ALIVE=24h
gpus: all

openwebui:
image: ghcr.io/open-webui/open-webui:main
container_name: open-webui
restart: unless-stopped
ports:
- "3000:8080"
environment:
- OLLAMA_API_BASE_URL=http://ollama:11434
- ENABLE_AUTH=True
volumes:
- openwebui:/app/backend/data
depends_on:
- ollama

volumes:
ollama:
openwebui:

Bring everything up:

docker compose up -d

Open WebUI will be available at http://<your-server-ip>:3000 and Ollama's API at http://<your-server-ip>:11434.

Step 4: Pull a Model and Test Inference

Use Ollama to pull an LLM. Llama 3 8B is a good starting point if you have at least ~8–10 GB of free VRAM:

docker exec -it ollama ollama pull llama3:8b

You can test quickly from the CLI:

docker exec -it ollama ollama run llama3:8b

Or open your browser and navigate to Open WebUI (port 3000). Create an account on first visit, select the model, and start chatting. If GPU is being used, you should see activity in:

watch -n 1 nvidia-smi

Step 5: Secure and Maintain the Stack

- Firewall: Allow only needed ports (adjust to your network policy). For local-only use, block remote access to 3000/11434.
- Reverse proxy: For TLS and a friendly domain, put Nginx or Caddy in front of Open WebUI and obtain a Let's Encrypt certificate.
- Updates: Keep images fresh and restart the stack regularly:

docker compose pull
docker compose up -d

Back up volumes so you don't lose chats or downloaded models:

docker run --rm -v ollama:/data -v "$(pwd)":/backup alpine tar czf /backup/ollama-vol.tgz -C /data .
docker run --rm -v openwebui:/data -v "$(pwd)":/backup alpine tar czf /backup/openwebui-vol.tgz -C /data .

Troubleshooting

- No GPU in containers: Confirm the toolkit is active. Check docker info | grep -i nvidia. Re-run sudo nvidia-ctk runtime configure --runtime=docker and restart Docker.
- Model out-of-memory (OOM): Use a smaller model or quantized variant (e.g., llama3:8b-instruct-q4_0). Close other GPU apps. You can also reduce context in Open WebUI settings.
- Slow generation: Ensure you're not falling back to CPU (watch nvidia-smi). Update drivers and Docker images. Use recent CUDA-compatible drivers (550+ often recommended).
- Open WebUI cannot reach Ollama: Check the environment OLLAMA_API_BASE_URL=http://ollama:11434. View logs with docker logs open-webui and docker logs ollama.
- Port conflicts: Change the host ports in docker-compose.yml (e.g., map "127.0.0.1:3000:8080" to bind only locally).

Where Models Are Stored and How to Clean Up

Models live in the Ollama volume (/root/.ollama inside the container). To list installed models:

docker exec -it ollama ollama list

Remove a model you no longer need:

docker exec -it ollama ollama rm llama3:8b

If you ever want to stop and remove the stack:

docker compose down

To reclaim space including volumes (this deletes your models and chat history), run:

docker compose down -v

Wrap-Up

You now have a private, GPU-accelerated LLM environment powered by Ollama and Open WebUI on Ubuntu. With Docker Compose, updates and maintenance are straightforward, and volumes keep your data persistent. From here, try different models (Mistral, Phi-3, Llama 3 Instruct), experiment with prompt templates, and fine-tune performance for your hardware. Enjoy your local AI workstation or server—no cloud required.

Deploy Ollama and Open WebUI on Ubuntu 22.04/24.04 with NVIDIA GPU Acceleration (Docker Compose)

Running large language models locally is easier than ever. In this guide, you will deploy Ollama and Open WebUI on Ubuntu 22.04 or 24.04 using Docker Compose, with optional NVIDIA GPU acceleration for faster inference. Ollama handles model management and inference, while Open WebUI gives you a clean, browser-based interface. By the end, you will have a persistent, secure setup ready for daily use.

Prerequisites

You need an Ubuntu 22.04 or 24.04 server with at least 16 GB RAM for 7B–8B models (more is better), 30+ GB free disk space, and internet access. GPU acceleration is optional but recommended: an NVIDIA GPU with drivers installed significantly speeds up responses. You will also need sudo privileges. If UFW or another firewall is enabled, plan to allow TCP 3000 (Open WebUI) and 11434 (Ollama) for local access.

Step 1: Update Ubuntu

Make sure your system is current. This reduces dependency conflicts and ensures you get the latest Docker packages.

sudo apt update && sudo apt -y upgrade
sudo reboot

Step 2: Install Docker Engine and Docker Compose Plugin

Install the official Docker repository, Docker Engine, and the Compose plugin. This is the most reliable way to run both Ollama and Open WebUI containers with persistent volumes.

sudo apt update
sudo apt install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo $VERSION_CODENAME) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker $USER
newgrp docker

Step 3 (Optional but Recommended): Enable NVIDIA GPU for Containers

If you have an NVIDIA GPU, install the proprietary driver and the NVIDIA Container Toolkit so Docker can access the GPU. If you are CPU-only, skip to Step 4.

# Install NVIDIA driver (reboot after)
sudo ubuntu-drivers autoinstall
sudo reboot

# After reboot, verify the GPU
nvidia-smi

# Install NVIDIA Container Toolkit
distribution=$(. /etc/os-release; echo $ID$VERSION_ID)
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | \
sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -fsSL https://nvidia.github.io/libnvidia-container/stable/$distribution/nvidia-container-toolkit.list | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt update
sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

# Optional sanity test
docker run --rm --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smi

Step 4: Create a Docker Compose File

Use Docker Compose to orchestrate both services. The configuration below persists model data, restarts on failures, and binds Open WebUI to port 3000. GPU access is configured using device reservations. Save this as docker-compose.yml in an empty directory (for example, ~/ai-stack).

version: "3.8"
services:
  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    restart: unless-stopped
    ports:
      - "11434:11434"
    volumes:
      - ollama:/root/.ollama
    environment:
      - OLLAMA_KEEP_ALIVE=24h
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

  open-webui:
    image: ghcr.io/open-webui/open-webui:latest
    container_name: open-webui
    depends_on:
      - ollama
    restart: unless-stopped
    ports:
      - "3000:8080"
    environment:
      - OLLAMA_BASE_URL=http://ollama:11434
    volumes:
      - openwebui:/app/backend/data

volumes:
  ollama:
  openwebui:

If you do not have an NVIDIA GPU or do not want to use it, you can remove the entire deploy.resources block from the ollama service. Ollama will run on CPU automatically, albeit slower.

Step 5: Start the Stack

Bring the services online in detached mode. The first start will pull images, which may take a few minutes depending on your connection speed.

docker compose up -d
docker compose ps

Open your browser and go to http://<server-ip>:3000. The Open WebUI interface should load. The first time you access it, you will be prompted to create an account. This account is stored in the openwebui volume for persistence.

Step 6: Pull a Model and Run Your First Chat

You can pull a model either from the Open WebUI interface or via the Ollama CLI inside the container. Popular choices include llama3, llama3.1, mistral, and qwen. The example below pulls Llama 3 8B. Adjust the model size to fit your RAM/GPU VRAM.

# Pull from inside the Ollama container
docker exec -it ollama ollama pull llama3:8b

# Verify Ollama is responding
curl http://localhost:11434/api/tags

In Open WebUI, select the pulled model from the dropdown and start chatting. If you see slow responses on CPU, confirm that your GPU is being used by monitoring nvidia-smi while generating text.

Step 7: Secure and Tune Your Deployment

By default, Open WebUI exposes port 3000. If you only use it locally, bind to localhost by editing the compose file port mapping to "127.0.0.1:3000:8080". For remote access, place a reverse proxy like Nginx or Caddy in front with HTTPS. Inside Open WebUI settings, disable open sign-ups after creating your admin account to restrict access.

Consider setting model-specific parameters in Open WebUI such as temperature, top_p, and context length. Ollama supports model-level configuration via Modelfiles if you want reproducible prompts and system messages. You can also set OLLAMA_NUM_PARALLEL to control concurrency for multiple users.

Updating, Backups, and Uninstall

To update, pull the latest images and recreate containers without losing data, since volumes persist your models and settings.

docker compose pull
docker compose up -d

For backups, snapshot the ollama and openwebui volumes or back up the entire /var/lib/docker/volumes paths created by this stack. To remove the stack without deleting data, run docker compose down. To fully remove everything, include the -v flag to delete volumes.

docker compose down        # stops and removes containers
docker compose down -v     # also removes volumes (data loss)

Troubleshooting

If Open WebUI cannot connect to Ollama, ensure the OLLAMA_BASE_URL is set to http://ollama:11434 and that both containers are in the same compose project. If the port 3000 or 11434 is already in use, change the host-side port in the compose file. For GPU issues like “no CUDA devices found,” verify that nvidia-smi works on the host and that the NVIDIA Container Toolkit is installed and Docker was restarted. If you see permission errors using Docker, confirm your user is in the docker group and re-open your shell or use newgrp docker.

With this setup, you now have a modern, self-hosted AI stack on Ubuntu that is fast, secure, and easy to maintain. Enjoy experimenting with different models, fine-tuning settings, and integrating Open WebUI into your daily workflow.

How to Run Local LLMs on Ubuntu with Ollama and Open WebUI (GPU-Accelerated)

Running a private, fast large language model (LLM) on your own hardware is now practical thanks to Ollama and Open WebUI. This guide shows how to install Ollama on Ubuntu (with NVIDIA GPU acceleration) and connect it to Open WebUI for a clean, chat-style interface. You will get a secure, local setup that can run modern models such as Llama 3.1 and Mistral without sending data to the cloud.

What You’ll Build

You will install Ollama as a system service on Ubuntu 22.04/24.04, download a model, and run Open WebUI in Docker. The GPU will be used by Ollama to accelerate inference while Open WebUI provides a browser-based interface. The result is a local chat environment accessible at http://localhost:3000.

Prerequisites

• Ubuntu 22.04 LTS or 24.04 LTS on a machine with at least 16 GB RAM (more is better).
• An NVIDIA GPU (6 GB+ VRAM recommended) and the proprietary NVIDIA driver.
• Sudo privileges and internet access.

Step 1: Prepare Ubuntu and NVIDIA Drivers

Update the system first: sudo apt update && sudo apt upgrade -y. Install the latest recommended NVIDIA driver: ubuntu-drivers devices to inspect, then sudo ubuntu-drivers autoinstall. Reboot: sudo reboot. After reboot, confirm the GPU is visible with nvidia-smi. If you see your GPU and driver version, you’re ready.

Step 2: Install Ollama

Ollama is a lightweight runtime for local LLMs. Install it with: curl -fsSL https://ollama.com/install.sh | sh. The installer sets up the service and binary. Start or restart the service if needed: sudo systemctl restart ollama. By default, the Ollama API listens on http://127.0.0.1:11434.

Step 3: Pull a Model and Test

Pull a modern, efficient model. Examples: ollama pull llama3.1:8b or ollama pull mistral:7b. Test generation on the CLI: ollama run llama3.1:8b then type a prompt. Or test the API: curl http://localhost:11434/api/generate -d '{"model":"llama3.1:8b","prompt":"Hello"}'. If a model loads and responds, your base setup is working and it will use the GPU when possible.

Step 4: Install Docker (for Open WebUI)

If Docker is missing, install it quickly:
sudo apt-get install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo $VERSION_CODENAME) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update && sudo apt install -y docker-ce docker-ce-cli containerd.io
Optional but recommended: sudo usermod -aG docker $USER then log out/in.

Step 5: Launch Open WebUI

Open WebUI connects to the local Ollama API and gives a feature-rich chat interface with history and prompt templates. On Linux, map the host gateway inside the container so it can reach Ollama on the host:

docker run -d --name openwebui --restart unless-stopped -p 3000:8080 -e OLLAMA_BASE_URL=http://host.docker.internal:11434 --add-host=host.docker.internal:host-gateway -v openwebui-data:/app/backend/data ghcr.io/open-webui/open-webui:latest

Open a browser and visit http://localhost:3000. In Settings → Connections, ensure the Ollama base URL is http://host.docker.internal:11434. You can now select the model (e.g., llama3.1:8b) and chat.

Step 6: Optimize Memory and Context

If VRAM is limited, choose a smaller quantization (e.g., llama3.1:8b often defaults to Q4_K_M). List quantizations with ollama show llama3.1:8b. To increase context, create a custom model:
printf "FROM llama3.1:8b\nPARAMETER num_ctx 8192\n" > Modelfile
ollama create llama3.1-8k -f Modelfile
Then select llama3.1-8k in Open WebUI.

Step 7: Secure and Expose (Optional)

Keep Ollama bound to localhost unless you need remote access. If you must expose it, put Open WebUI behind a reverse proxy with TLS (e.g., Nginx or Caddy) and enable authentication in Open WebUI (Settings → Auth). For UFW: sudo ufw allow 22/tcp, sudo ufw allow 3000/tcp (if local), then sudo ufw enable. Prefer a proper domain and HTTPS if accessing remotely.

Updating and Backups

Update Ollama with the installer again or your package manager, then restart: sudo systemctl restart ollama. Update Open WebUI by pulling a new image: docker pull ghcr.io/open-webui/open-webui:latest then docker stop openwebui && docker rm openwebui and re-run the docker run command. Back up your chat data from the Docker volume openwebui-data using docker run --rm -v openwebui-data:/data -v $PWD:/backup alpine tar czf /backup/openwebui-data.tgz -C / data.

Troubleshooting

• GPU not used: verify nvidia-smi shows a running process during inference. Ensure the proprietary driver is loaded. If you previously installed CUDA separately, avoid driver mismatches.
• Open WebUI can’t reach Ollama: confirm curl http://localhost:11434 on the host works and that the Docker container uses --add-host=host.docker.internal:host-gateway or switch to --network host if acceptable.
• Slow first response: the first prompt loads weights into memory; subsequent prompts are faster. Consider smaller models or different quantization if latency is too high.
• Out-of-memory: reduce context (num_ctx), switch to a lower-precision quantization, or choose a smaller model (e.g., llama3.1:8b-instruct with Q4).

You’re Done

You now have a private, GPU-accelerated LLM stack on Ubuntu. Ollama handles fast local inference, and Open WebUI gives you a slick, familiar chat interface. With careful model selection, quantization, and context tuning, this setup can power assistants, coding copilots, and knowledge bots entirely on your hardware.

Popular Posts

Install Ollama and Open WebUI on Ubuntu 24.04 with NVIDIA GPU Acceleration (Step-by-Step)

Install Ollama + Open WebUI on Ubuntu 24.04 with NVIDIA GPU Acceleration (Step-by-Step)

Install a Local AI Chatbot on Ubuntu 24.04 with Ollama and Open WebUI (Step-by-Step)

Trending Now

Debian Adoption at CERN Signals Strong Momentum for Enterprise Linux

By the end of this article readers will understand the implications of CERN’s migration of 2,200 control systems to Debian 13, the performance enhancements in Firefox 155, and recent developments across several Linux distributions that affect system administration and user experience. Debian 13 Deployment at CERN: Scale and Significance The European Organization for Nuclear Research (CERN) has announced the migration of 2,200 of its control systems to Debian 13. This move represents one of the largest coordinated deployments of a Debian release in a scientific research environment. Control systems at CERN are responsible for monitoring and managing critical hardware, from accelerator components to detector subsystems. Their reliability hinges on a stable operating system with long‑term support, predictable update cycles, and a robust package ecosystem. Debian’s reputation for stability and its extensive testing process make it a natural fit for such mission‑critical workloads. Debia...