Docker: fix and clean up configs, update docs

This commit is contained in:
oobabooga
2026-03-04 22:59:45 -03:00
parent 387cf9d8df
commit 5a22970ba8
12 changed files with 52 additions and 299 deletions

View File

@@ -1,8 +1,3 @@
.env
Dockerfile
/characters
/loras
/models
/presets
/prompts
/training
/user_data

View File

@@ -1,8 +1,8 @@
# by default the Dockerfile specifies these versions: 3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX
# however for me to work i had to specify the exact version for my card ( 2060 ) it was 7.5
# https://developer.nvidia.com/cuda-gpus you can find the version for your card here
# Or for a programatic approach run `nvidia-smi --query-gpu=name,compute_cap --format=csv`
TORCH_CUDA_ARCH_LIST=7.5
# specify which cuda arch version your card supports (NVIDIA only)
# https://developer.nvidia.com/cuda-gpus
# or run: nvidia-smi --query-gpu=name,compute_cap --format=csv
# default in docker-compose.yml covers RTX 3090 (8.6) and RTX 4090 (8.9)
TORCH_CUDA_ARCH_LIST=8.6;8.9+PTX
# the port the webui binds to on the host
HOST_PORT=7860
# the port the webui binds to inside the container
@@ -13,12 +13,9 @@ HOST_API_PORT=5000
CONTAINER_API_PORT=5000
# Comma separated extensions to build
BUILD_EXTENSIONS=""
# Set APP_RUNTIME_GID to an appropriate host system group to enable access to mounted volumes
# Set APP_RUNTIME_GID to an appropriate host system group to enable access to mounted volumes
# You can find your current host user group id with the command `id -g`
APP_RUNTIME_GID=6972
# override default app build permissions (handy for deploying to cloud)
#APP_GID=6972
#APP_UID=6972
# Set cache env
TRANSFORMERS_CACHE=/home/app/text-generation-webui/cache/
HF_HOME=/home/app/text-generation-webui/cache/

View File

@@ -1,4 +1,4 @@
FROM pytorch/pytorch:2.2.1-cuda12.1-cudnn8-runtime
FROM pytorch/pytorch:2.9.1-cuda12.8-cudnn9-runtime
# Install Git
RUN apt update && apt install -y git
@@ -12,7 +12,7 @@ WORKDIR /app
# Install text-generation-webui
RUN git clone https://github.com/oobabooga/text-generation-webui
WORKDIR /app/text-generation-webui
RUN pip install -r requirements.txt
RUN pip install -r requirements/full/requirements.txt
# This is needed to avoid an error about "Failed to build mpi4py" in the next command
ENV LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH

View File

@@ -1,7 +1,6 @@
# BUILDER
FROM ubuntu:22.04
WORKDIR /builder
ARG TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX}"
ARG BUILD_EXTENSIONS="${BUILD_EXTENSIONS:-}"
ARG APP_UID="${APP_UID:-6972}"
ARG APP_GID="${APP_GID:-6972}"
@@ -14,8 +13,7 @@ WORKDIR /home/app/
RUN git clone https://github.com/oobabooga/text-generation-webui.git
WORKDIR /home/app/text-generation-webui
RUN GPU_CHOICE=B LAUNCH_AFTER_INSTALL=FALSE INSTALL_EXTENSIONS=TRUE ./start_linux.sh --verbose
COPY /user_data/CMD_FLAGS.txt /home/app/text-generation-webui/user_data
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000} ${CONTAINER_API_STREAM_PORT:-5005}
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000}
WORKDIR /home/app/text-generation-webui
# set umask to ensure group read / write at runtime
CMD umask 0002 && export HOME=/home/app/text-generation-webui && ./start_linux.sh
CMD umask 0002 && export HOME=/home/app/text-generation-webui && ./start_linux.sh --listen

View File

@@ -4,25 +4,9 @@ services:
build:
context: .
args:
# Requirements file to use:
# | GPU | requirements file to use |
# |--------|---------|
# | NVIDIA | `requirements.txt` |
# | AMD | `requirements_amd.txt` |
# | CPU only | `requirements_cpu_only.txt` |
# | Apple Intel | `requirements_apple_intel.txt` |
# | Apple Silicon | `requirements_apple_silicon.txt` |
# Default: requirements.txt`
# BUILD_REQUIREMENTS: requirements.txt
# Extension requirements to build:
# BUILD_EXTENSIONS:
# specify which cuda version your card supports: https://developer.nvidia.com/cuda-gpus
TORCH_CUDA_ARCH_LIST: ${TORCH_CUDA_ARCH_LIST:-7.5}
BUILD_EXTENSIONS: ${BUILD_EXTENSIONS:-}
APP_GID: ${APP_GID:-6972}
APP_UID: ${APP_UID:-6972}
APP_GID: ${APP_GID:-6972}
APP_UID: ${APP_UID:-6972}
env_file: .env
user: "${APP_RUNTIME_UID:-6972}:${APP_RUNTIME_GID:-6972}"
ports:

View File

@@ -1,14 +1,9 @@
# BUILDER
FROM ubuntu:22.04
WORKDIR /builder
ARG TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX}"
ARG BUILD_EXTENSIONS="${BUILD_EXTENSIONS:-}"
ARG APP_UID="${APP_UID:-6972}"
ARG APP_GID="${APP_GID:-6972}"
ARG GPU_CHOICE=A
ARG USE_CUDA118=FALSE
ARG LAUNCH_AFTER_INSTALL=FALSE
ARG INSTALL_EXTENSIONS=TRUE
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,rw \
apt update && \
@@ -18,8 +13,7 @@ WORKDIR /home/app/
RUN git clone https://github.com/oobabooga/text-generation-webui.git
WORKDIR /home/app/text-generation-webui
RUN GPU_CHOICE=N LAUNCH_AFTER_INSTALL=FALSE INSTALL_EXTENSIONS=TRUE ./start_linux.sh --verbose
COPY CMD_FLAGS.txt /home/app/text-generation-webui/
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000} ${CONTAINER_API_STREAM_PORT:-5005}
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000}
# set umask to ensure group read / write at runtime
WORKDIR /home/app/text-generation-webui
CMD umask 0002 && export HOME=/home/app/text-generation-webui && ./start_linux.sh
CMD umask 0002 && export HOME=/home/app/text-generation-webui && ./start_linux.sh --listen

View File

@@ -4,25 +4,9 @@ services:
build:
context: .
args:
# Requirements file to use:
# | GPU | requirements file to use |
# |--------|---------|
# | NVIDIA | `requirements.txt` |
# | AMD | `requirements_amd.txt` |
# | CPU only | `requirements_cpu_only.txt` |
# | Apple Intel | `requirements_apple_intel.txt` |
# | Apple Silicon | `requirements_apple_silicon.txt` |
# Default: requirements.txt`
# BUILD_REQUIREMENTS: requirements.txt
# Extension requirements to build:
# BUILD_EXTENSIONS:
# specify which cuda version your card supports: https://developer.nvidia.com/cuda-gpus
TORCH_CUDA_ARCH_LIST: ${TORCH_CUDA_ARCH_LIST:-7.5}
BUILD_EXTENSIONS: ${BUILD_EXTENSIONS:-}
APP_GID: ${APP_GID:-6972}
APP_UID: ${APP_UID:-6972}
APP_GID: ${APP_GID:-6972}
APP_UID: ${APP_UID:-6972}
env_file: .env
user: "${APP_RUNTIME_UID:-6972}:${APP_RUNTIME_GID:-6972}"
ports:
@@ -31,14 +15,4 @@ services:
stdin_open: true
tty: true
volumes:
- ./cache:/home/app/text-generation-webui/cache
- ./characters:/home/app/text-generation-webui/characters
- ./extensions:/home/app/text-generation-webui/extensions
- ./loras:/home/app/text-generation-webui/loras
- ./logs:/home/app/text-generation-webui/logs
- ./models:/home/app/text-generation-webui/models
- ./presets:/home/app/text-generation-webui/presets
- ./prompts:/home/app/text-generation-webui/prompts
- ./softprompts:/home/app/text-generation-webui/softprompts
- ./training:/home/app/text-generation-webui/training
- ./cloudflared:/etc/cloudflared
- ./user_data:/home/app/text-generation-webui/user_data

View File

@@ -1,7 +1,6 @@
# BUILDER
FROM ubuntu:22.04
WORKDIR /builder
ARG TORCH_CUDA_ARCH_LIST="${TORCH_CUDA_ARCH_LIST:-3.5;5.0;6.0;6.1;7.0;7.5;8.0;8.6+PTX}"
ARG BUILD_EXTENSIONS="${BUILD_EXTENSIONS:-}"
ARG APP_UID="${APP_UID:-6972}"
ARG APP_GID="${APP_GID:-6972}"
@@ -14,8 +13,7 @@ WORKDIR /home/app/
RUN git clone https://github.com/oobabooga/text-generation-webui.git
WORKDIR /home/app/text-generation-webui
RUN GPU_CHOICE=D LAUNCH_AFTER_INSTALL=FALSE INSTALL_EXTENSIONS=TRUE ./start_linux.sh --verbose
COPY /user_data/CMD_FLAGS.txt /home/app/text-generation-webui/user_data
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000} ${CONTAINER_API_STREAM_PORT:-5005}
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000}
# set umask to ensure group read / write at runtime
WORKDIR /home/app/text-generation-webui
CMD umask 0002 && export HOME=/home/app/text-generation-webui && ./start_linux.sh
CMD umask 0002 && export HOME=/home/app/text-generation-webui && ./start_linux.sh --listen

View File

@@ -4,25 +4,9 @@ services:
build:
context: .
args:
# Requirements file to use:
# | GPU | requirements file to use |
# |--------|---------|
# | NVIDIA | `requirements.txt` |
# | AMD | `requirements_amd.txt` |
# | CPU only | `requirements_cpu_only.txt` |
# | Apple Intel | `requirements_apple_intel.txt` |
# | Apple Silicon | `requirements_apple_silicon.txt` |
# Default: requirements.txt`
# BUILD_REQUIREMENTS: requirements.txt
# Extension requirements to build:
# BUILD_EXTENSIONS:
# specify which cuda version your card supports: https://developer.nvidia.com/cuda-gpus
TORCH_CUDA_ARCH_LIST: ${TORCH_CUDA_ARCH_LIST:-7.5}
BUILD_EXTENSIONS: ${BUILD_EXTENSIONS:-}
APP_GID: ${APP_GID:-6972}
APP_UID: ${APP_UID:-6972}
APP_GID: ${APP_GID:-6972}
APP_UID: ${APP_UID:-6972}
env_file: .env
user: "${APP_RUNTIME_UID:-6972}:${APP_RUNTIME_GID:-6972}"
ports:

View File

@@ -14,8 +14,7 @@ WORKDIR /home/app/
RUN git clone https://github.com/oobabooga/text-generation-webui.git
WORKDIR /home/app/text-generation-webui
RUN GPU_CHOICE=A LAUNCH_AFTER_INSTALL=FALSE INSTALL_EXTENSIONS=TRUE ./start_linux.sh --verbose
COPY /user_data/CMD_FLAGS.txt /home/app/text-generation-webui/user_data
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000} ${CONTAINER_API_STREAM_PORT:-5005}
EXPOSE ${CONTAINER_PORT:-7860} ${CONTAINER_API_PORT:-5000}
WORKDIR /home/app/text-generation-webui
# set umask to ensure group read / write at runtime
CMD umask 0002 && export HOME=/home/app/text-generation-webui && ./start_linux.sh --listen

View File

@@ -4,25 +4,11 @@ services:
build:
context: .
args:
# Requirements file to use:
# | GPU | requirements file to use |
# |--------|---------|
# | NVIDIA | `requirements.txt` |
# | AMD | `requirements_amd.txt` |
# | CPU only | `requirements_cpu_only.txt` |
# | Apple Intel | `requirements_apple_intel.txt` |
# | Apple Silicon | `requirements_apple_silicon.txt` |
# Default: requirements.txt`
# BUILD_REQUIREMENTS: requirements.txt
# Extension requirements to build:
# BUILD_EXTENSIONS:
# specify which cuda version your card supports: https://developer.nvidia.com/cuda-gpus
TORCH_CUDA_ARCH_LIST: ${TORCH_CUDA_ARCH_LIST:-7.5}
TORCH_CUDA_ARCH_LIST: ${TORCH_CUDA_ARCH_LIST:-8.6;8.9+PTX}
BUILD_EXTENSIONS: ${BUILD_EXTENSIONS:-}
APP_GID: ${APP_GID:-6972}
APP_UID: ${APP_UID:-6972}
APP_GID: ${APP_GID:-6972}
APP_UID: ${APP_UID:-6972}
env_file: .env
user: "${APP_RUNTIME_UID:-6972}:${APP_RUNTIME_GID:-6972}"
ports:

View File

@@ -1,208 +1,52 @@
Docker Compose is a way of installing and launching the web UI in an isolated Ubuntu image using only a few commands.
## Installing Docker Compose
## Prerequisites
In order to create the image as described in the main README, you must have Docker Compose installed (2.17 or higher is recommended):
You need Docker Compose v2.17 or higher:
```
~$ docker compose version
Docker Compose version v2.21.0
```
The installation instructions for various Linux distributions can be found here:
Installation instructions: https://docs.docker.com/engine/install/
https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
For NVIDIA GPUs, you also need the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html).
## Launching the image
## Quick start
Use these commands to launch the image:
There are four Docker variants available under `docker/`:
```
cd text-generation-webui
ln -s docker/{nvidia/Dockerfile,nvidia/docker-compose.yml,.dockerignore} .
cp docker/.env.example .env
# Edit .env and set TORCH_CUDA_ARCH_LIST based on your GPU model
| Directory | GPU | Notes |
|-----------|-----|-------|
| `docker/nvidia` | NVIDIA | Requires NVIDIA Container Toolkit |
| `docker/amd` | AMD | Requires ROCm-compatible GPU |
| `docker/intel` | Intel Arc | Beta support |
| `docker/cpu` | None | CPU-only inference |
To launch (using NVIDIA as an example):
```bash
cd text-generation-webui/docker/nvidia
cp ../.env.example .env
# Optionally edit .env to customize ports, TORCH_CUDA_ARCH_LIST, etc.
docker compose up --build
```
## More detailed installation instructions
The web UI will be available at `http://localhost:7860`.
* [Docker Compose installation instructions](#docker-compose-installation-instructions)
* [Repository with additional Docker files](#dedicated-docker-repository)
## User data
By [@loeken](https://github.com/loeken).
Create a `user_data/` directory next to the `docker-compose.yml` to persist your models, characters, presets, and settings between container rebuilds:
- [Ubuntu 22.04](#ubuntu-2204)
- [0. youtube video](#0-youtube-video)
- [1. update the drivers](#1-update-the-drivers)
- [2. reboot](#2-reboot)
- [3. install docker](#3-install-docker)
- [4. docker \& container toolkit](#4-docker--container-toolkit)
- [5. clone the repo](#5-clone-the-repo)
- [6. prepare models](#6-prepare-models)
- [7. prepare .env file](#7-prepare-env-file)
- [8. startup docker container](#8-startup-docker-container)
- [Manjaro](#manjaro)
- [update the drivers](#update-the-drivers)
- [reboot](#reboot)
- [docker \& container toolkit](#docker--container-toolkit)
- [continue with ubuntu task](#continue-with-ubuntu-task)
- [Windows](#windows)
- [0. youtube video](#0-youtube-video-1)
- [1. choco package manager](#1-choco-package-manager)
- [2. install drivers/dependencies](#2-install-driversdependencies)
- [3. install wsl](#3-install-wsl)
- [4. reboot](#4-reboot)
- [5. git clone \&\& startup](#5-git-clone--startup)
- [6. prepare models](#6-prepare-models-1)
- [7. startup](#7-startup)
- [notes](#notes)
### Ubuntu 22.04
#### 0. youtube video
A video walking you through the setup can be found here:
[![oobabooga text-generation-webui setup in docker on ubuntu 22.04](https://img.youtube.com/vi/ELkKWYh8qOk/0.jpg)](https://www.youtube.com/watch?v=ELkKWYh8qOk)
#### 1. update the drivers
in the the “software updater” update drivers to the last version of the prop driver.
#### 2. reboot
to switch using to new driver
#### 3. install docker
```bash
sudo apt update
sudo apt-get install curl
sudo mkdir -m 0755 -p /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-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose -y
sudo usermod -aG docker $USER
newgrp docker
mkdir -p user_data
```
#### 4. docker & container toolkit
```bash
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/stable/ubuntu22.04/amd64 /" | \
sudo tee /etc/apt/sources.list.d/nvidia.list > /dev/null
sudo apt update
sudo apt install nvidia-docker2 nvidia-container-runtime -y
sudo systemctl restart docker
```
This directory is mounted into the container at runtime. You can place a `CMD_FLAGS.txt` inside it to pass persistent flags to the web UI (e.g., `--api`).
#### 5. clone the repo
```
git clone https://github.com/oobabooga/text-generation-webui
cd text-generation-webui
```
#### 6. prepare models
download and place the models inside the models folder. tested with:
4bit
https://github.com/oobabooga/text-generation-webui/pull/530#issuecomment-1483891617
https://github.com/oobabooga/text-generation-webui/pull/530#issuecomment-1483941105
8bit:
https://github.com/oobabooga/text-generation-webui/pull/530#issuecomment-1484235789
#### 7. prepare .env file
edit .env values to your needs.
```bash
cp .env.example .env
nano .env
```
#### 8. startup docker container
```bash
docker compose up --build
```
### Manjaro
manjaro/arch is similar to ubuntu just the dependency installation is more convenient
#### update the drivers
```bash
sudo mhwd -a pci nonfree 0300
```
#### reboot
```bash
reboot
```
#### docker & container toolkit
```bash
yay -S docker docker-compose buildkit gcc nvidia-docker
sudo usermod -aG docker $USER
newgrp docker
sudo systemctl restart docker # required by nvidia-container-runtime
```
#### continue with ubuntu task
continue at [5. clone the repo](#5-clone-the-repo)
### Windows
#### 0. youtube video
A video walking you through the setup can be found here:
[![oobabooga text-generation-webui setup in docker on windows 11](https://img.youtube.com/vi/ejH4w5b5kFQ/0.jpg)](https://www.youtube.com/watch?v=ejH4w5b5kFQ)
#### 1. choco package manager
install package manager (https://chocolatey.org/ )
```
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
```
#### 2. install drivers/dependencies
```
choco install nvidia-display-driver cuda git docker-desktop
```
#### 3. install wsl
wsl --install
#### 4. reboot
after reboot enter username/password in wsl
#### 5. git clone && startup
clone the repo and edit .env values to your needs.
```
cd Desktop
git clone https://github.com/oobabooga/text-generation-webui
cd text-generation-webui
COPY .env.example .env
notepad .env
```
#### 6. prepare models
download and place the models inside the models folder. tested with:
4bit https://github.com/oobabooga/text-generation-webui/pull/530#issuecomment-1483891617 https://github.com/oobabooga/text-generation-webui/pull/530#issuecomment-1483941105
8bit: https://github.com/oobabooga/text-generation-webui/pull/530#issuecomment-1484235789
#### 7. startup
```
docker compose up
```
### notes
on older ubuntus you can manually install the docker compose plugin like this:
```
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.17.2/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
export PATH="$HOME/.docker/cli-plugins:$PATH"
```
Models can be downloaded through the web UI's “Model” tab once it's running, and they will be saved to `user_data/models/`.
## Dedicated docker repository
An external repository maintains a docker wrapper for this project as well as several pre-configured 'one-click' `docker compose` variants (e.g., updated branches of GPTQ). It can be found at: [Atinoda/text-generation-webui-docker](https://github.com/Atinoda/text-generation-webui-docker).
An external repository maintains a docker wrapper for this project as well as several pre-configured 'one-click' `docker compose` variants. It can be found at: [Atinoda/text-generation-webui-docker](https://github.com/Atinoda/text-generation-webui-docker).