Skip to content

Commit

Permalink
Fixed docker documentation to use the new repo from dockerhub as the …
Browse files Browse the repository at this point in the history
…previous one does not exist anymore or is outdated.
  • Loading branch information
ZeroCool940711 committed Aug 3, 2023
1 parent 93f4806 commit 853ff4a
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions docs/1.Installation/4.docker-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
The easiest way to run Stable Diffusion WebUI is to use the prebuilt image from Docker Hub.

```bash
docker pull hlky/sd-webui:runpod
```
This image has all the necessary models baked in. It is quite large but streamlines the process of managing the various models and simplifies the user experience.

Alternatively you can pull:
```bash
docker pull hlky/sd-webui:latest
docker pull tukirito/sygil-webui:latest
```
This image includes the babrebones environment to run the Web UI. The models will be downloaded during the installation process. You will have to take care of the volume for the `sd/models` directory.


It is recommended that you run the `runpod` version.
You can run the image using the following command:
```bash
docker container run --rm -d -p 8501:8501 -e STREAMLIT_SERVER_HEADLESS=true -e "WEBUI_SCRIPT=webui_streamlit.py" -e "VALIDATE_MODELS=false" -v "${PWD}/outputs:/sd/outputs" --gpus all hlky/sd-webui:runpod
docker container run --rm -d -p 8501:8501 -e STREAMLIT_SERVER_HEADLESS=true -e "WEBUI_SCRIPT=webui_streamlit.py" -e "VALIDATE_MODELS=false" -v "${PWD}/outputs:/sd/outputs" --gpus all tukirito/sygil-webui:latest
```

> Note: if you are running it on runpod it only supports one volume mount which is used for your outputs.
> Note: if you are running it on your local machine the output directory will be created in the current directory from where you run this command.
## Building the image
Expand Down Expand Up @@ -90,31 +81,34 @@ in your `.profile` or through a tool like `direnv`
## First-Time Startup Instructions

### Clone Repository

* Clone this repository to your host machine:
* `git clone https://github.com/Sygil-Dev/sygil-webui.git`
* `git clone https://github.com/Sygil-Dev/sygil-webui.git`
* If you plan to use Docker Compose to run the image in a container (most users), create an `.env_docker` file using the example file:
* `cp .env_docker.example .env_docker`
* Edit `.env_docker` using the text editor of your choice.
* Ensure `VALIDATE_MODELS` is set to `true`
> Options available in `.env_docker` allow you to control automatic model file checking/download during startup, and to select the Stable Diffusion WebUI implementation to run (Gradio vs Streamlit). You may the set `VALIDATE_MODELS` option to `false` after the initial run (once models are downloaded) to speed up startup time.
* `cp .env_docker.example .env_docker`
* Edit `.env_docker` using the text editor of your choice.
* Ensure `VALIDATE_MODELS` is set to `true`
> Options available in `.env_docker` allow you to control automatic model file checking/download during startup, and to select the Stable Diffusion WebUI implementation to run (Gradio vs Streamlit). You may the set `VALIDATE_MODELS` option to `false` after the initial run (once models are downloaded) to speed up startup time.
### Create a Container Instance Using Docker Compose

The default `docker-compose.yml` file will create a Docker container instance named `sd-webui`

* Create an instance of the Stable Diffusion WebUI image as a Docker container:
* `docker compose up`
* `docker compose up`
* During the first run, the container image will be build containing all of the dependencies necessary to run Stable Diffusion. This build process will take several minutes to complete
* After the image build has completed, you will have a docker image for running the Stable Diffusion WebUI tagged `sygil-webui:dev`
* After the image build has completed, you will have a docker image for running the Stable Diffusion WebUI tagged `sygil-webui:dev`

(Optional) Daemon mode:

* You can start the container in "daemon" mode by applying the `-d` option: `docker compose up -d`. This will run the server in the background so you can close your console window without losing your work.
* When running in daemon mode, you can view logging output from your container by running `docker logs sd-webui`

> Note: Depending on your version of Docker/Docker Compose installed, the command may be `docker-compose` (older versions) or `docker compose` (newer versions)

### Accessing your Stable Diffusion WebUI Instance

The container may take several minutes to start up if model weights/checkpoints need to be downloaded. You can view progress via `docker compose ps` to see the current status or by checking the logs using `docker compose logs`.

Depending on the WebUI implementation you selected in `.env_docker`, you can access the WebUI at the following URLs:
Expand All @@ -124,49 +118,54 @@ Depending on the WebUI implementation you selected in `.env_docker`, you can acc

You can expose and access your WebUI to/from remote hosts by the machine's IP address:
(note: This generally does not apply to Windows/WSL2 users due to WSL's implementation)

* Gradio: http://\<host-ip-address\>:7860
* Streamlit: http://\<host-ip-address\>:8501


### Where is ___ stored?

By default, model weights/checkpoint files will be stored at the following path:

* `./model_cache/`

Output files generated by Stable Diffusion will be stored at the following path:

* `./output/`

The above paths will be accessible directly from your Docker container's host.


### Shutting down your Docker container

You can stop your Docker container by pressing the `CTRL+C` key combination in the terminal where the container was started..

If you started the container using `docker compose`, you can stop the container with the command:

* `docker compose down`

Using the default configuration, your Stable Diffusion output, cached model weights/files, etc will persist between Docker container starts.

---

## Resetting your Docker environment

Should you need to do so, the included `docker-reset.sh` script will remove all docker images, stopped containers, and cached model weights/checkpoints.

You will need to re-download all associated model files/weights used by Stable Diffusion WebUI, which total to several gigabytes of data. This will occur automatically upon the next startup.


## Misc Related How-to

* You can obtain shell access to a running Stable Diffusion WebUI container started with Docker Compose with either of the following commands:
* `docker exec -it st-webui /bin/bash`
* `docker compose exec stable-diffusion bash`
* `docker exec -it st-webui /bin/bash`
* `docker compose exec stable-diffusion bash`
* To start a container using the Stable Diffusion WebUI Docker image without Docker Compose, you can do so with the following command:
* `docker run --rm -it --entrypoint /bin/bash sygil-webui:dev`
* `docker run --rm -it --entrypoint /bin/bash sygil-webui:dev`
* To start a container, with mapped ports, GPU resource access, and a local directory bound as a container volume, you can do so with the following command:
* `docker run --rm -it -p 8501:8501 -p 7860:7860 --gpus all -v $(pwd):/sd --entrypoint /bin/bash sygil-webui:dev`
* `docker run --rm -it -p 8501:8501 -p 7860:7860 --gpus all -v $(pwd):/sd --entrypoint /bin/bash sygil-webui:dev`

---

## Dockerfile Implementation Notes

Compared to base Stable Diffusion distribution, Conda-based package management was removed.

The Pytorch base image with Nvidia CUDA support is used as the base Docker image to simplify dependencies.
Expand All @@ -185,4 +184,4 @@ Python package dependencies have been version-pinned where possible.
### Other Notes

* The `root_profile` Docker Volume
* The `huggingface/transformers` package will download files to a cache located at `/root/.cache/huggingface/transformers` totalling nearly ~1.6 GB
* The `huggingface/transformers` package will download files to a cache located at `/root/.cache/huggingface/transformers` totalling nearly ~1.6 GB

0 comments on commit 853ff4a

Please sign in to comment.