Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9a1e6f9
Merge pull request #12 from grokuku/test
grokuku Dec 24, 2023
2dee638
fix: Re-add memory leak fix
FoxxMD Dec 28, 2023
ead42ad
fix(sdnext): Fix embeddings source location
FoxxMD Dec 28, 2023
829a881
refactor: Make folder symlinking safer
FoxxMD Dec 28, 2023
52ebda0
docs: Improve readme and doc examples
FoxxMD Dec 28, 2023
ada4ee7
fix(sdnext): Use more robust memory fix solution
FoxxMD Dec 28, 2023
ab3269a
docs: Update sd.next memory leak documentation
FoxxMD Dec 28, 2023
0ea0566
Add ComfyUI-Manager
Webifi Dec 29, 2023
c9ef454
Merge pull request #13 from FoxxMD/refixSDNextMemory
grokuku Dec 30, 2023
3eb5df6
Merge pull request #14 from FoxxMD/sdEmbeddingsFix
grokuku Dec 30, 2023
9e3a6de
Merge pull request #17 from Webifi/main
grokuku Dec 30, 2023
80b7dec
Merge pull request #16 from FoxxMD/docsUpdate
grokuku Dec 30, 2023
294fc23
Merge pull request #19 from grokuku/main
grokuku Dec 30, 2023
8859c10
Change config file
grokuku Dec 31, 2023
7808d2f
Update 01.txt
grokuku Dec 31, 2023
d5d8fec
Merge pull request #20 from FoxxMD/symlinkImprovement
grokuku Jan 8, 2024
aefe570
allow custom script
grokuku Jan 20, 2024
5410289
test custom script
grokuku Jan 21, 2024
da1f9f4
custom script modifications+ fooocus fix (hopefully)
grokuku Jan 21, 2024
ce85a3f
fix sample filename
grokuku Jan 21, 2024
d77c17a
easier custom script selection
grokuku Jan 21, 2024
ae7ad51
remove fooocus output path in parameters file
grokuku Jan 21, 2024
fb6befd
Merge pull request #15 from FoxxMD/symlinkImprovement
grokuku Jan 21, 2024
30de5a9
Merge pull request #21 from grokuku/main
grokuku Jan 21, 2024
65d043c
fix Easy-Diffusion settings + update install to version 3.0.2
grokuku Jan 21, 2024
91066f9
Merge pull request #22 from grokuku/Holaf_tests
grokuku Jan 21, 2024
a228c76
fix(sdnext): Remove invalid arg
FoxxMD Feb 8, 2024
bc1f3c7
Merge pull request #23 from FoxxMD/removeSDArg
grokuku Feb 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ sl_folder ${SD01_DIR}/models gfpgan ${BASE_DIR}/models gfpgan

sl_folder ${HOME} "Stable Diffusion UI" ${BASE_DIR}/outputs 01-Easy-Diffusion

if [ ! -f "$SD01_DIR/scripts/config.json" ]; then
cp -v "${SD_INSTALL_DIR}/parameters/01.txt" "$SD01_DIR/scripts/config.json"
if [ ! -f "$SD01_DIR/config.yaml" ]; then
cp -v "${SD_INSTALL_DIR}/parameters/01.txt" "$SD01_DIR/config.yaml"
fi

if [ ! -f "$SD01_DIR/start.sh" ]; then
curl -L https://github.com/easydiffusion/easydiffusion/releases/download/v2.5.41a/Easy-Diffusion-Linux.zip --output edui.zip
curl -L https://github.com/easydiffusion/easydiffusion/releases/download/v3.0.2/Easy-Diffusion-Linux.zip --output edui.zip
unzip edui.zip
cp -rf easy-diffusion/* .
rm -rf easy-diffusion
Expand Down
15 changes: 9 additions & 6 deletions 04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ if [ ! -f "$SD04_DIR/parameters.txt" ]; then
fi
# Load updated malloc to fix memory leak
# https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/6850#issuecomment-1432435503
if [ ! -f "$SD04_DIR/webui/webui-user.sh" ]; then
cat >"$SD04_DIR/webui/webui-user.sh" <<EOL
export LD_PRELOAD=libtcmalloc.so
echo "libtcmalloc loaded"
EOL
# https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/6722
# https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/6722#discussioncomment-6161333
if [[ "${OSTYPE}" == "linux"* ]] && [[ -z "${NO_TCMALLOC}" ]] && [[ -z "${LD_PRELOAD}" ]]; then
TCMALLOC="$(ldconfig -p | grep -Po "libtcmalloc_minimal.so.\d" | head -n 1)"
if [[ ! -z "${TCMALLOC}" ]]; then
echo "Using TCMalloc: ${TCMALLOC}"
export LD_PRELOAD="${TCMALLOC}"
fi
fi

# Create venv
Expand All @@ -71,7 +74,7 @@ sl_folder ${SD04_DIR}/webui/models Stable-diffusion ${BASE_DIR}/models stable-di
sl_folder ${SD04_DIR}/webui/models hypernetworks ${BASE_DIR}/models hypernetwork
sl_folder ${SD04_DIR}/webui/models Lora ${BASE_DIR}/models lora
sl_folder ${SD04_DIR}/webui/models VAE ${BASE_DIR}/models vae
sl_folder ${SD04_DIR}/webui embeddings ${BASE_DIR}/models embeddings
sl_folder ${SD04_DIR}/webui/models embeddings ${BASE_DIR}/models embeddings
sl_folder ${SD04_DIR}/webui/models ESRGAN ${BASE_DIR}/models upscale
sl_folder ${SD04_DIR}/webui/models Codeformer ${BASE_DIR}/models codeformer
sl_folder ${SD04_DIR}/webui/models GFPGAN ${BASE_DIR}/models gfpgan
Expand Down
9 changes: 9 additions & 0 deletions 05.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ if [ ! -d ${SD05_DIR}/ComfyUI ]; then
git clone https://github.com/comfyanonymous/ComfyUI ${SD05_DIR}/ComfyUI
fi

if [ ! -d ${SD05_DIR}/ComfyUI/custom_nodes/ComfyUI-Manager ]; then
git clone https://github.com/ltdrdata/ComfyUI-Manager.git ${SD05_DIR}/ComfyUI/custom_nodes/ComfyUI-Manager
fi

cd ${SD05_DIR}/ComfyUI/custom_nodes/ComfyUI-Manager
git pull -X ours

cd ${SD05_DIR}/ComfyUI
git pull -X ours

Expand All @@ -34,9 +41,11 @@ sl_folder ${SD05_DIR}/ComfyUI/models checkpoints ${BASE_DIR}/models stable-diffu
sl_folder ${SD05_DIR}/ComfyUI/models hypernetworks ${BASE_DIR}/models hypernetwork
sl_folder ${SD05_DIR}/ComfyUI/models loras ${BASE_DIR}/models lora
sl_folder ${SD05_DIR}/ComfyUI/models vae ${BASE_DIR}/models vae
sl_folder ${SD05_DIR}/ComfyUI/models vae_approx ${BASE_DIR}/models vae_approx
sl_folder ${SD05_DIR}/ComfyUI/models embeddings ${BASE_DIR}/models embeddings
sl_folder ${SD05_DIR}/ComfyUI/models upscale_models ${BASE_DIR}/models upscale
sl_folder ${SD05_DIR}/ComfyUI/models clip_vision ${BASE_DIR}/models clip_vision
sl_folder ${SD05_DIR}/ComfyUI/models clip ${BASE_DIR}/models clip
sl_folder ${SD05_DIR}/ComfyUI/models controlnet ${BASE_DIR}/models controlnet

if [ -d ${SD05_DIR}/venv ]; then
Expand Down
2 changes: 1 addition & 1 deletion 06.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source /sl_folder.sh
export PATH="/home/abc/miniconda3/bin:$PATH"

mkdir -p ${SD06_DIR}
mkdir -p /config/outputs/06-Fooocus
mkdir -p $BASE_DIR/outputs/06-Fooocus

if [ ! -d ${SD06_DIR}/env ]; then
conda create -p ${SD06_DIR}/env -y
Expand Down
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
**Subsequent changelog history can be found in Releases**

- **Version 2.0.2** :
move .cache folder to stable-diffusion/temp to avoid filling unraid's docker.img file.
(hopefully) fix all the things I broke in the last update :)

- **Version 2.0.0** :
Utilize Conda to manage dependencies efficiently.
Prepared for Reactor in Auto1111, SD-Next, and ComfyUI.
More common folders merged in the models folder.
Split install scripts for easier maintenance.
Implemented various fixes.

- **Version 1.5.1** :
Added a fix for Automatic1111/dreambooth

- **Version 1.5.0** :
Added StableSwarm and VoltaML

- **Version 1.4.0** :
Added FaceFusion

- **Version 1.3.0** :
Added Kubin (Kubin is only for testing, not production ready)
Corrected update of ComfyUI at startup not working

- **Version 1.2.0** :
Added Lama-cleaner and Kohya

- **Version 1.1.0** :
Added Focus as interface 06
Small Fixes

- **Version 1.0.0** :
Lots of modifications on directory structure.
Before using this version it's best to do a backup, do a clean install and restore models,loras, ect from the backup.
123 changes: 52 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

[![Docker Pulls](https://img.shields.io/docker/pulls/holaflenain/stable-diffusion)](https://hub.docker.com/r/holaflenain/stable-diffusion)

The goal of this docker container is to provide an easy way to run different WebUI and other tools related to Image Generation (mostly stable-diffusion).

The goal of this docker container is to provide an easy way to run different WebUI/projects and other tools related to Image Generation (mostly stable-diffusion).

# Projects

Please consult each respective website for a comprehensive description and usage guidelines.
| WEBUI | Name | | |
|-------|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
Expand All @@ -21,9 +23,23 @@ Please consult each respective website for a comprehensive description and usage
| 70 | Kohya | Kohya's GUI provides a Windows-focused Gradio GUI for Kohya's Stable Diffusion trainers | https://github.com/bmaltais/kohya_ss |


## Usage
# Usage

Unraid template available on [superboki's Repository](https://github.com/superboki/UNRAID-FR/tree/main/stable-diffusion-advanced) (search stable-diffusion in community apps)

## Choosing a Project

Unraid template available on superboki's Repository (search diffusion in community apps)
Use the environmental variable `WEBUI_VERSION` to choose which [project](#projects) to install and use based on the number in the **WEBUI** column. [easy diffusion](https://github.com/easydiffusion/easydiffusion) (`01`) is installed if none is specified.

Example: To use SD.Next => `WEBUI_VERSION=04`

```
docker run ... -e WEBUI_VERSION=04 ... holaflenain/stable-diffusion
```

or modify `WEBUI_VERSION` in [docker-compose.yml](/docker-compose.yml)

## Docker Notes

### Using PUID and PGID

Expand All @@ -45,36 +61,11 @@ Then add to your docker command like so:
docker run -d ... -e "PUID=1000" -e "PGID=1000" ... holaflenain/stable-diffusion
```

or substitute them in the docker-compose examples below.

#### Docker Compose Example
or substitute them in [docker-compose.yml](/docker-compose.yml)

### Docker Compose

Using Easy-Diffusion as an example:

```yaml
version: '3.1'
services:
stable-diffusion-test:
image: holaflenain/stable-diffusion:latest
container_name: stable-diffusion
environment:
- WEBUI_VERSION=01
- NVIDIA_VISIBLE_DEVICES=all
- TZ=Europe/Paris
- PUID=1000
- PGID=1000
ports:
- '9000:9000/tcp'
volumes:
- '/my/own/datadir:/config:rw'
# or specify individual dirs
#- '/my/own/datadir:/config:rw' # config/program dir
#- '/my/own/datadir/outputs:/config/outputs:rw'
#- '/my/own/datadir/cache:/config/cache:rw'
runtime: nvidia

```
Reference [docker-compose.yml](/docker-compose.yml) which uses Easy-Diffusion as an example.

## Directory Structure

Expand Down Expand Up @@ -105,46 +96,36 @@ By default, each user interface will save data in its own directory, which is au
├── 50-lama-cleaner
└── 51-facefusion

## Project Notes

Some projects have modified install/startup changes to address performance or suggested fixes.

General changes are listed below and **specified in notes if they apply.** Specific project modifications are listed below these.

###### Clean Environment

When the container starts if the installed project is outdated compared to the _upstream project_ then the latest code is pulled and dependencies for installation are wiped and re-installed. Subsequent container starts will be much faster since the project will not be re-installed. This behavior can be **forced** by setting the docker environmental variable `CLEAN_ENV=true`.

## History
- **Version 2.0.2** :
move .cache folder to stable-diffusion/temp to avoid filling unraid's docker.img file.
(hopefully) fix all the things I broke in the last update :)

- **Version 2.0.0** :
Utilize Conda to manage dependencies efficiently.
Prepared for Reactor in Auto1111, SD-Next, and ComfyUI.
More common folders merged in the models folder.
Split install scripts for easier maintenance.
Implemented various fixes.

- **Version 1.5.1** :
Added a fix for Automatic1111/dreambooth

- **Version 1.5.0** :
Added StableSwarm and VoltaML

- **Version 1.4.0** :
Added FaceFusion

- **Version 1.3.0** :
Added Kubin (Kubin is only for testing, not production ready)
Corrected update of ComfyUI at startup not working

- **Version 1.2.0** :
Added Lama-cleaner and Kohya

- **Version 1.1.0** :
Added Focus as interface 06
Small Fixes

- **Version 1.0.0** :
Lots of modifications on directory structure.
Before using this version it's best to do a backup, do a clean install and restore models,loras, ect from the backup.

## Troubleshoot :
First thing to try when a UI refuse to launch, remove the cache and the numbered folder (ex :02-sd-webui ) then relaunch the container
#### Stable Diffusion WebUI (02) Notes

* Uses [Clean Environment](#clean-environment) performance improvement

#### SD.Next (04) Notes

* Uses [Clean Environment](#clean-environment) performance improvement
* Uses an updated `malloc` library to fix a [memory leak](https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/6722)
* This can be turned off by adding the docker environmental variable `NO_TCMALLOC=true`

# History

See [**Changelog**](/CHANGELOG.md)

## Support :
# Support

Support for the container available here : https://forums.unraid.net/topic/143645-support-stable-diffusion-advanced/
Support for the WebUIs available on their respective pages.
Support for the WebUIs available on their respective pages.

## Troubleshooting

First thing to try when a UI refuse to launch, remove the cache and the numbered folder (ex :02-sd-webui ) then relaunch the container
57 changes: 57 additions & 0 deletions custom-sample.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
source /sl_folder.sh

export PATH="/home/abc/miniconda3/bin:$PATH"

# Set Variables and parameters

# Name of the custom WebUI (will be used for the program itself and the output directory)
export CustomNAME="FooocusMRE"

# Name of the base folder for custom WebUIs
export CustomBASE="00-custom"

# Complete Path for the program files
export CustomPATH="/config/$CustomBASE/$CustomNAME"

# Parameters to pass at launch
export CustomPARAMETERS="--listen 0.0.0.0 --port 9000"

# Folders creation (Program files and output)
mkdir -p ${CustomPATH}
mkdir -p $BASE_DIR/outputs/$CustomBASE/$CustomNAME

# Creation and Activation on the Conda Virtual Env
if [ ! -d ${CustomPATH}/env ]; then
conda create -p ${CustomPATH}/env -y
fi
source activate ${CustomPATH}/env
conda install -n base conda-libmamba-solver -y
conda install -c conda-forge git python=3.10 pip --solver=libmamba -y
conda install -c nvidia cuda-cudart --solver=libmamba -y

# Clone/update program files
if [ ! -d ${CustomPATH}/Fooocus-MRE ]; then
cd "${CustomPATH}" && git clone https://github.com/MoonRide303/Fooocus-MRE.git
fi
cd ${CustomPATH}/Fooocus-MRE
git pull -X ours

# Using the sl_folder to create symlinks needed to use the common models folder
sl_folder ${CustomPATH}/Fooocus-MRE/models checkpoints ${BASE_DIR}/models stable-diffusion
sl_folder ${CustomPATH}/Fooocus-MRE/models loras ${BASE_DIR}/models lora
sl_folder ${CustomPATH}/Fooocus-MRE/models vae ${BASE_DIR}/models vae
sl_folder ${CustomPATH}/Fooocus-MRE/models embeddings ${BASE_DIR}/models embeddings
sl_folder ${CustomPATH}/Fooocus-MRE/models hypernetworks ${BASE_DIR}/models hypernetwork
sl_folder ${CustomPATH}/Fooocus-MRE/models upscale_models ${BASE_DIR}/models upscale
sl_folder ${CustomPATH}/Fooocus-MRE/models clip_vision ${BASE_DIR}/models clip_vision
sl_folder ${CustomPATH}/Fooocus-MRE/models controlnet ${BASE_DIR}/models controlnet

sl_folder ${CustomPATH}/Fooocus-MRE outputs ${BASE_DIR}/outputs/$CustomBASE $CustomNAME

# installation of requirements
cd ${CustomPATH}/Fooocus-MRE
pip install -r requirements_versions.txt

# Launch Fooocus-MRE
python launch.py ${CustomPARAMETERS}
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3.1'
services:
stable-diffusion-test:
image: holaflenain/stable-diffusion:latest
container_name: stable-diffusion
environment:
- WEBUI_VERSION=01
- NVIDIA_VISIBLE_DEVICES=all
- TZ=Europe/Paris
- PUID=1000
- PGID=1000
ports:
- '9000:9000/tcp'
volumes:
- '/my/own/datadir:/config:rw'
# or specify individual dirs
#- '/my/own/datadir:/config:rw' # config/program dir
#- '/my/own/datadir/outputs:/config/outputs:rw'
#- '/my/own/datadir/cache:/config/cache:rw'
runtime: nvidia
8 changes: 8 additions & 0 deletions entry.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/bash

# Copy sample custom script in user folder if it doesn't exists

if [ ! -f "$BASE_DIR/scripts/custom-sample.sh" ]; then
mkdir -p $BASE_DIR/scripts
cp -v "/custom-sample.sh" "$BASE_DIR/scripts/custom-sample.sh"
fi

case $WEBUI_VERSION in
01)
. /01.sh
Expand Down Expand Up @@ -38,6 +45,7 @@ case $WEBUI_VERSION in
. /70.sh
;;
*)
. $BASE_DIR/scripts/$WEBUI_VERSION
echo error in webui selection variable
;;
esac
Loading