Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
data/
13 changes: 10 additions & 3 deletions 05.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,16 @@ conda install -n base conda-libmamba-solver -y
conda install -c conda-forge git python=3.11 pip gxx libcurand --solver=libmamba -y
conda install -c nvidia cuda-cudart --solver=libmamba -y
pip install onnxruntime-gpu
pip install insightface torch torchvision

install_requirements ${SD05_DIR}/ComfyUI/custom_nodes
pip install insightface torch>=2.2.2 torchvision opencv-python-headless>=4.9.0.80 huggingface-hub>=0.20.2 numpy>=1.24.4

#Install custom nodes dependencies if a clean Venv has been done
if [ "$active_clean" = "1" ]; then
echo "-------------------------------------"
echo "Install Custom Nodes Dependencies"
install_requirements ${SD05_DIR}/ComfyUI/custom_nodes
echo "Done!"
echo -e "-------------------------------------\n"
fi

#clean old venv if it still exists
if [ -d ${SD05_DIR}/venv ]; then
Expand Down
44 changes: 44 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# get the current machines
export HOSTIP := $(shell ip route get 1.1.1.1 | grep -oP 'src \K\S+')
export PUID := $(shell id -u)
export PGID := $(shell id -g)

# Parse the available profiles from the docker-compose.yml
AVAILABLE_PROFILES := $(shell grep -oP 'profiles:\s*\[\K[^\]]+' docker-compose.yml | sed 's/\s*//g' | tr '\n' ' ')

# Include .env variable in the current environment
ifneq (,$(wildcard ./.env))
include .env
export
endif

# Default target
.DEFAULT_GOAL := help
.PHONY: help up down start stop logs

# Help target
help:
@echo "Available targets:"
@echo " up [profile] Start the specified profile (e.g., make up fooocus)"
@echo " down [profile] Stop the specified profile (e.g., make down fooocus)"
@echo " help Show this help message"

# up target
up:
docker compose --profile $(filter-out $@,$(MAKECMDGOALS)) up

# down/stop target
down: stop
stop:
docker compose --profile $(filter-out $@,$(MAKECMDGOALS)) down

# start target
start:
docker compose --profile $(filter-out $@,$(MAKECMDGOALS)) up -d

logs:
docker compose --profile $(filter-out $@,$(MAKECMDGOALS)) logs -f

# Allow extra arguments for the up and down targets
%:
@:
65 changes: 39 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,43 +28,56 @@ Unraid template available on [superboki's Repository](https://github.com/superbo

## Choosing a Project

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 compose --profile easy-diffusion up # http://<server_ip>:9001
docker compose --profile automatic up # http://<server_ip>:9002
docker compose --profile forge up # http://<server_ip>:9022
docker compose --profile invoke-ai up # http://<server_ip>:9003
docker compose --profile sd-next up # http://<server_ip>:9004
docker compose --profile comfy-ui up # http://<server_ip>:9005
docker compose --profile fooocus up # http://<server_ip>:9006
docker compose --profile stable-swarm up # http://<server_ip>:9007
docker compose --profile lama-cleaner up # http://<server_ip>:9050
docker compose --profile face-fusion up # http://<server_ip>:9051
docker compose --profile kohya up # http://<server_ip>:9070

## Docker Notes

### Using PUID and PGID

If you are
```

* running on a **linux host** (ie unraid) and
* **not** using [rootless containers with Podman](https://developers.redhat.com/blog/2020/09/25/rootless-containers-with-podman-the-basics#why_podman_)
or
( Although not recommended as it will requires significant system resources, 64GB+ system memory and at bare minimum 16GB VRAM card, you have been warned! )

then you must set the [environmental variables **PUID** and **PGID**.](https://docs.linuxserver.io/general/understanding-puid-and-pgid) in the container in order for it to generate files/folders your normal user can interact it.
```
docker compose up # to run all the services at once
```

Run these commands from your terminal
## Make

* `id -u` -- prints UID for **PUID**
* `id -g` -- prints GID for **PGID**
alternatively you can use make to start and stop the services

Then add to your docker command like so:
there are two variations

```shell
docker run -d ... -e "PUID=1000" -e "PGID=1000" ... holaflenain/stable-diffusion
```
# will start the service detached from the terminal (running in the background)
make start <profile_name>

or substitute them in [docker-compose.yml](/docker-compose.yml)
# will start the service and leave its output attached to the terminal
make up <profile_name>
```
Here is a complete list for starting services
```
make start easy-diffusion # http://<server_ip>:9001
make start automatic # http://<server_ip>:9002
make start forge # http://<server_ip>:9022
make start invoke-ai # http://<server_ip>:9003
make start sd-next # http://<server_ip>:9004
make start comfy-ui # http://<server_ip>:9005
make start fooocus # http://<server_ip>:9006
make start stable-swarm # http://<server_ip>:9007
make start lama-cleaner # http://<server_ip>:9050
make start face-fusion # http://<server_ip>:9051
make start kohya # http://<server_ip>:9070
```

### Docker Compose

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

## Directory Structure

Expand Down
140 changes: 121 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,122 @@
version: '3.1'
x-service: &default-service
image: holaflenain/stable-diffusion:latest
runtime: nvidia
volumes:
- "${STABLE_DIFFUSION_DATA_DIRECTORY:-./data/stable-diffusion}:/config:rw"

x-environment: &default-environment
NVIDIA_VISIBLE_DEVICES: ${NVIDIA_VISIBLE_DEVICES:-all}
TZ: ${TZ:-America/New_York}
PUID: ${PUID:-1000}
PGID: ${PGID:-1000}

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
stable-diffusion-easy-diffusion:
<<: *default-service
profiles: [easy-diffusion]
container_name: stable-diffusion-easy-diffusion
environment:
<<: *default-environment
WEBUI_VERSION: '01'
ports:
- ${EASY_DIFFUSION_PORT:-9001}:9000/tcp

stable-diffusion-automatic:
<<: *default-service
profiles: [automatic]
container_name: stable-diffusion-automatic
environment:
<<: *default-environment
WEBUI_VERSION: '02'
ports:
- ${AUTOMATIC_PORT:-9002}:9000/tcp

stable-diffusion-forge:
<<: *default-service
profiles: [forge]
container_name: stable-diffusion-forge
environment:
<<: *default-environment
WEBUI_VERSION: '02.forge'
ports:
- ${FORGE_PORT:-9022}:9000/tcp

stable-diffusion-invoke-ai:
<<: *default-service
profiles: [invoke-ai]
container_name: stable-diffusion-invoke-ai
environment:
<<: *default-environment
WEBUI_VERSION: '03'
ports:
- ${INVOKE_AI_PORT:-9003}:9000/tcp

stable-diffusion-sd-next:
<<: *default-service
profiles: [sd-next]
container_name: stable-diffusion-sd-next
environment:
<<: *default-environment
WEBUI_VERSION: '04'
ports:
- ${SD_NEXT_PORT:-9004}:9000/tcp

stable-diffusion-comfy-ui:
<<: *default-service
profiles: [comfy-ui]
container_name: stable-diffusion-comfy-ui
environment:
<<: *default-environment
WEBUI_VERSION: '05'
ports:
- ${COMFY_UI_PORT:-}9005:9000/tcp

stable-diffusion-fooocus:
<<: *default-service
profiles: [fooocus]
container_name: stable-diffusion-fooocus
environment:
<<: *default-environment
WEBUI_VERSION: '06'
ports:
- ${FOOOCUS_PORT:-9006}:9000/tcp

stable-diffusion-stable-swarm:
<<: *default-service
profiles: [stable-swarm]
container_name: stable-diffusion-stable-swarm
environment:
<<: *default-environment
WEBUI_VERSION: '07'
ports:
- ${STABLE_SWARM_PORT:-9007}:9000/tcp

stable-diffusion-lama-cleaner:
<<: *default-service
profiles: [lama-cleaner]
container_name: stable-diffusion-lama-cleaner
environment:
<<: *default-environment
WEBUI_VERSION: '50'
ports:
- ${LAMA_CLEANER_PORT:-9050}:9000/tcp

stable-diffusion-face-fusion:
<<: *default-service
profiles: [face-fusion]
container_name: stable-diffusion-face-fusion
environment:
<<: *default-environment
WEBUI_VERSION: '51'
ports:
- ${FACE_FUSION_PORT:-9051}:9000/tcp

stable-diffusion-kohya:
<<: *default-service
profiles: [kohya]
container_name: stable-diffusion-kohya
environment:
<<: *default-environment
WEBUI_VERSION: '70'
ports:
- ${KOHYA_PORT:-9070}:9000/tcp
28 changes: 25 additions & 3 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ fi
}

# Fonction récursive pour installer les requirements.txt
#install_requirements() {
# local directory="$1"
# local requirements_file="$directory/requirements.txt"

# if [ -f "$requirements_file" ]; then
# echo "Installation des dépendances dans $directory ..."
# pip install -r "$requirements_file"
# echo "Dépendances installées avec succès dans $directory."
# fi

# # Parcours récursif des sous-dossiers
# for subdir in "$directory"/*; do
# if [ -d "$subdir" ]; then
# install_requirements "$subdir"
# fi
# done
#}
install_requirements() {
local directory="$1"
local requirements_file="$directory/requirements.txt"
Expand All @@ -65,10 +82,15 @@ install_requirements() {
echo "Dépendances installées avec succès dans $directory."
fi

# Parcours récursif des sous-dossiers
# Parcours des sous-dossiers du premier niveau uniquement
for subdir in "$directory"/*; do
if [ -d "$subdir" ]; then
install_requirements "$subdir"
local subdir_requirements_file="$subdir/requirements.txt"
if [ -f "$subdir_requirements_file" ]; then
echo "Installation des dépendances dans $subdir ..."
pip install -r "$subdir_requirements_file"
echo "Dépendances installées avec succès dans $subdir."
fi
fi
done
}
}