Skip to content
Snippets Groups Projects
Commit 06585134 authored by Jan Grewe's avatar Jan Grewe
Browse files

use data-dir

parent 5ea88603
No related branches found
No related tags found
No related merge requests found
......@@ -10,19 +10,17 @@ RUN apt-get -qq update -y \
&& rm -rf /var/lib/apt/lists/*
RUN git clone --depth 1 --branch v${VERSION} -c advice.detachedHead=false \
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git /stable-diffusion-webui
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git /app
WORKDIR /stable-diffusion-webui
VOLUME /stable-diffusion-webui/models/VAE-approx
WORKDIR /app
ENV PIP_ROOT_USER_ACTION=ignore
RUN sed -i -e 's/ start()/ #start()/g' /stable-diffusion-webui/launch.py \
RUN sed -i -e 's/ start()/ #start()/g' /app/launch.py \
&& python launch.py --skip-torch-cuda-test \
&& sed -i -e 's/ #start()/ start()/g' /stable-diffusion-webui/launch.py
&& sed -i -e 's/ #start()/ start()/g' /app/launch.py
RUN rm -r /root/.cache/pip
EXPOSE 7860
ENTRYPOINT ["python", "webui.py", "--listen", "--disable-console-progressbars", "--enable-insecure-extension-access"]
ENTRYPOINT ["python", "launch.py", "--listen", "--data-dir", "/app/data", "--disable-console-progressbars", "--enable-insecure-extension-access"]
CMD ["--api", "--opt-sdp-no-mem-attention", "--opt-channelslast"]
FROM nvidia/cuda:11.8.0-base-ubuntu22.04
ARG VERSION
ENV VERSION=master
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get -qq update -y \
&& apt-get -qq install -y --no-install-recommends \
git git-lfs libgl1 pkg-config python-is-python3 python3-dev python3-pip \
&& rm -rf /var/lib/apt/lists/*
RUN git clone --depth 1 --branch ${VERSION} -c advice.detachedHead=false \
https://github.com/vladmandic/automatic.git /app
WORKDIR /app
ENV TORCH_COMMAND="torch torchaudio torchvision --index-url https://download.pytorch.org/whl/cu118"
ENV PIP_ROOT_USER_ACTION=ignore
RUN python installer.py
RUN rm -r /root/.cache/pip
EXPOSE 7860
ENTRYPOINT ["python", "launch.py", "--listen", "--data-dir", "/app/data"]
# AUTOMATIC1111
Set the name of the Docker image:
# Stable Diffusion WebUI in Docker
## Available Versions
Set the version of the Docker image you want to build:
#### AUTOMATIC1111:
To build the Stable Diffusion WebUI by AUTOMATIC111 from https://github.com/AUTOMATIC1111/stable-diffusion-webui
```
export DOCKER_IMAGE=dcr.faked.org/stable-diffusion-webui:latest
export IMAGE_VERSION="automatic1111"
```
Build the Docker image:
#### Vlad
To build the Stable Diffusion WebUI by Vlad Mandic from https://github.com/vladmandic/automatic/
```
docker build -f Dockerfile.a1111 -t ${DOCKER_IMAGE} .
export IMAGE_VERSION="vlad"
```
Run the Docker image:
## Build the image (and optionally push it to your registry)
```
docker run --gpus all --rm --name stable-diffusion -p 7860:7860 \
-v /storage/stable-diffusion/extensions:/stable-diffusion-webui/extensions \
-v /storage/stable-diffusion/embeddings:/stable-diffusion-webui/embeddings \
-v /storage/stable-diffusion/models:/stable-diffusion-webui/models \
-v /storage/stable-diffusion/outputs:/stable-diffusion-webui/outputs \
export IMAGE_NAME=registry.example.com/stable-diffusion-webui:${IMAGE_VERSION}
docker build -f Dockerfile.${IMAGE_VERSION} -t ${IMAGE_NAME} .
docker push ${IMAGE_NAME}
```
## Run the container
Run the image without retaining any data or outputs on exit:
```
docker run --gpus all --rm --name stable-diffusion -p 7860:7860 ${IMAGE_NAME}
```
Run the image with persisted models, downloaded data and outputs:
```
docker run --tty --gpus all --rm --name stable-diffusion -p 7860:7860 \
-v /storage/stable-diffusion/data/${IMAGE_VERSION}:/app/data \
-v /storage/stable-diffusion/repositories:/app/repositories \
-v /storage/stable-diffusion/cache:/root/.cache \
${DOCKER_IMAGE}
-v /storage/stable-diffusion/outputs:/app/outputs \
${IMAGE_NAME}
```
# Troubleshooting
* There is no output to the console when starting the AUTOMATIC1111 image until you generate an image.
This can be fixed by adding the `--tty` argument after `docker run`
* The Vlad image asks you to confirm the download of the default model if it doesn't find one (e.g. because you mounted an empty data directory, or ran the image without a mounted data directory).
If that happens, the container will exit with an error, as you can't confirm the download.
To fix this, run the container with the `--interactive` argument after `docker run`, then you can confirm the download.
If you are using a moounted data directory, this should only be necessary for the first run, as it will find the downloaded model the next time you start the image.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment