diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ad60b67 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +data/ \ No newline at end of file diff --git a/05.sh b/05.sh index 1cc7cc0..58fe7ea 100755 --- a/05.sh +++ b/05.sh @@ -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 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8ea07d2 --- /dev/null +++ b/Makefile @@ -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 +%: + @: diff --git a/README.md b/README.md index a145ec2..f3a7bca 100644 --- a/README.md +++ b/README.md @@ -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://:9001 +docker compose --profile automatic up # http://:9002 +docker compose --profile forge up # http://:9022 +docker compose --profile invoke-ai up # http://:9003 +docker compose --profile sd-next up # http://:9004 +docker compose --profile comfy-ui up # http://:9005 +docker compose --profile fooocus up # http://:9006 +docker compose --profile stable-swarm up # http://:9007 +docker compose --profile lama-cleaner up # http://:9050 +docker compose --profile face-fusion up # http://:9051 +docker compose --profile kohya up # http://: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 -or substitute them in [docker-compose.yml](/docker-compose.yml) +# will start the service and leave its output attached to the terminal +make up +``` +Here is a complete list for starting services +``` +make start easy-diffusion # http://:9001 +make start automatic # http://:9002 +make start forge # http://:9022 +make start invoke-ai # http://:9003 +make start sd-next # http://:9004 +make start comfy-ui # http://:9005 +make start fooocus # http://:9006 +make start stable-swarm # http://:9007 +make start lama-cleaner # http://:9050 +make start face-fusion # http://:9051 +make start kohya # http://:9070 +``` -### Docker Compose - -Reference [docker-compose.yml](/docker-compose.yml) which uses Easy-Diffusion as an example. ## Directory Structure diff --git a/docker-compose.yml b/docker-compose.yml index 339531b..2a2680d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 \ No newline at end of file + 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 diff --git a/functions.sh b/functions.sh index 2fa2362..3e6aef5 100644 --- a/functions.sh +++ b/functions.sh @@ -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" @@ -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 -} \ No newline at end of file +}