diff --git a/01.sh b/01.sh index 32f83a6..94643b3 100755 --- a/01.sh +++ b/01.sh @@ -1,13 +1,36 @@ #!/bin/bash source /sl_folder.sh -SD01_DIR="${BASE_DIR}/01-easy-diffusion" +export PATH="/home/abc/miniconda3/bin:$PATH" +export SD01_DIR=${BASE_DIR}/01-easy-diffusion +#clean conda env +if [ "$active_clean" = "1" ]; then + echo "-------------------------------------" + echo "Cleaning venv" + rm -rf ${SD01_DIR}/conda-env + rm -rf ${SD01_DIR}/installer_files + export active_clean=0 + echo "Done!" + echo -e "-------------------------------------\n" +fi + +#Create Conda Env +if [ ! -d ${SD01_DIR}/conda-env ]; then + conda create -p ${SD01_DIR}/conda-env -y +fi + +#active env and install python +source activate ${SD01_DIR}/conda-env +conda install -n base conda-libmamba-solver -y +conda install -c python=3.11 pip --solver=libmamba -y + +#create 'models' folders mkdir -p ${SD01_DIR}/{models,version,plugins/ui,scripts} cd ${SD01_DIR} +#install manager plugin if [ ! -f ${SD01_DIR}/plugins/ui/plugin-manager.plugin.js ]; then - mkdir -p ${SD01_DIR}/plugins/ui/ curl -L https://raw.githubusercontent.com/patriceac/Easy-Diffusion-Plugins/main/plugin-manager.plugin.js --output ${SD01_DIR}/plugins/ui/plugin-manager.plugin.js fi @@ -24,10 +47,12 @@ sl_folder ${SD01_DIR}/models gfpgan ${BASE_DIR}/models gfpgan sl_folder ${HOME} "Stable Diffusion UI" ${BASE_DIR}/outputs 01-Easy-Diffusion +#copy default parameters if they don't exists if [ ! -f "$SD01_DIR/config.yaml" ]; then cp -v "${SD_INSTALL_DIR}/parameters/01.txt" "$SD01_DIR/config.yaml" fi +#download installer if it isn't present if [ ! -f "$SD01_DIR/start.sh" ]; then curl -L https://github.com/easydiffusion/easydiffusion/releases/download/v3.0.2/Easy-Diffusion-Linux.zip --output edui.zip unzip edui.zip @@ -36,7 +61,6 @@ if [ ! -f "$SD01_DIR/start.sh" ]; then rm -f edui.zip fi -#chown -R diffusion:users ${BASE_DIR} - +#run easy-diffusion cd $SD01_DIR bash start.sh diff --git a/02.forge.sh b/02.forge.sh index 1e51274..e0b4de7 100644 --- a/02.forge.sh +++ b/02.forge.sh @@ -2,7 +2,7 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" -export active_clean=0 +export SD02_DIR=${BASE_DIR}/02-sd-webui # disable the use of a python venv export venv_dir="-" @@ -10,14 +10,11 @@ export venv_dir="-" # Install or update Stable-Diffusion-WebUI mkdir -p ${SD02_DIR} +# Create Conda virtual env if [ ! -d ${SD02_DIR}/conda-env ]; then conda create -p ${SD02_DIR}/conda-env -y fi -source activate ${SD02_DIR}/conda-env -conda install -n base conda-libmamba-solver -y -conda install -c git python=3.11 pip --solver=libmamba -y - if [ ! -d ${SD02_DIR}/forge ]; then git clone https://github.com/lllyasviel/stable-diffusion-webui-forge.git ${SD02_DIR}/forge fi @@ -41,24 +38,32 @@ fi #clean conda env if [ "$active_clean" = "1" ]; then + echo "-------------------------------------" + echo "Cleaning venv" conda deactivate - conda remove -p ${SD02_DIR}/conda-env --all -y + rm -rf ${SD02_DIR}/conda-env conda create -p ${SD02_DIR}/conda-env -y - source activate ${SD02_DIR}/conda-env + export active_clean=0 + echo "Done!" + echo -e "-------------------------------------\n" fi -conda install -c conda-forge git python=3.11 pip gcc gxx libcurand --solver=libmamba -y + +#activate conda env + install base tools +source activate ${SD02_DIR}/conda-env +conda install -n base conda-libmamba-solver -y +conda install -c conda-forge python=3.11 pip gcc gxx libcurand --solver=libmamba -y if [ ! -f "$SD02_DIR/parameters.forge.txt" ]; then cp -v "/opt/sd-install/parameters/02.forge.txt" "$SD02_DIR/parameters.forge.txt" fi +#install dependencies pip install --upgrade pip pip install coloredlogs flatbuffers numpy packaging protobuf==3.20.3 sympy pip install packaging pip install onnxruntime-gpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ pip install insightface pip install basicsr -pip install torch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 --index-url https://download.pytorch.org/whl/cu121 pip install xformers --index-url https://download.pytorch.org/whl/cu121 # Merge Models, vae, lora, and hypernetworks, and outputs @@ -77,6 +82,7 @@ sl_folder ${SD02_DIR}/forge/models ControlNet ${BASE_DIR}/models controlnet sl_folder ${SD02_DIR}/forge output ${BASE_DIR}/outputs 02-sd-webui +# Run webUI echo "Run Stable-Diffusion-WebUI-forge" cd ${SD02_DIR}/forge CMD="bash webui.sh" diff --git a/02.sh b/02.sh index 35e1305..ed35e57 100755 --- a/02.sh +++ b/02.sh @@ -2,7 +2,7 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" -export active_clean=0 +export SD02_DIR=${BASE_DIR}/02-sd-webui # disable the use of a python venv export venv_dir="-" @@ -10,16 +10,14 @@ export venv_dir="-" # Install or update Stable-Diffusion-WebUI mkdir -p ${SD02_DIR} +# create conda env if needed if [ ! -d ${SD02_DIR}/conda-env ]; then conda create -p ${SD02_DIR}/conda-env -y fi -source activate ${SD02_DIR}/conda-env -conda install -n base conda-libmamba-solver -y -conda install -c git python=3.11 pip --solver=libmamba -y - +# clone repository if [ ! -d ${SD02_DIR}/webui ]; then - git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui ${SD02_DIR}/webui + git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git ${SD02_DIR}/webui fi cd ${SD02_DIR}/webui @@ -41,24 +39,33 @@ fi #clean conda env if [ "$active_clean" = "1" ]; then + echo "-------------------------------------" + echo "Cleaning venv" conda deactivate - conda remove -p ${SD02_DIR}/conda-env --all -y + rm -rf ${SD02_DIR}/conda-env conda create -p ${SD02_DIR}/conda-env -y - source activate ${SD02_DIR}/conda-env + export active_clean=0 + echo "Done!" + echo -e "-------------------------------------\n" fi -conda install -c conda-forge git python=3.11 pip gcc gxx libcurand --solver=libmamba -y +# activate conda env and install base tools +source activate ${SD02_DIR}/conda-env +conda install -n base conda-libmamba-solver -y +conda install -c conda-forge python=3.11 pip gcc gxx libcurand --solver=libmamba -y + +#copy default parameters if absent if [ ! -f "$SD02_DIR/parameters.txt" ]; then cp -v "/opt/sd-install/parameters/02.txt" "$SD02_DIR/parameters.txt" fi +# install dependencies pip install --upgrade pip pip install coloredlogs flatbuffers numpy packaging protobuf==3.20.3 sympy pip install packaging pip install onnxruntime-gpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ pip install insightface pip install basicsr -pip install torch==2.2.0 torchvision==0.17.0 torchaudio==2.2.0 --index-url https://download.pytorch.org/whl/cu121 pip install xformers --index-url https://download.pytorch.org/whl/cu121 @@ -78,6 +85,7 @@ sl_folder ${SD02_DIR}/webui/models ControlNet ${BASE_DIR}/models controlnet sl_folder ${SD02_DIR}/webui outputs ${BASE_DIR}/outputs 02-sd-webui +# run webUI echo "Run Stable-Diffusion-WebUI" cd ${SD02_DIR}/webui CMD="bash webui.sh" diff --git a/03.sh b/03.sh index 3489e03..e8262bd 100755 --- a/03.sh +++ b/03.sh @@ -3,21 +3,35 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" export use_venv=0 +export SD03_DIR=${BASE_DIR}/03-invokeai mkdir -p "$SD03_DIR" mkdir -p /config/outputs/03-InvokeAI +# copy default parameters if absent if [ ! -f "$SD03_DIR/parameters.txt" ]; then cp -v "${SD_INSTALL_DIR}/parameters/03.txt" "$SD03_DIR/parameters.txt" fi +#clean conda env +if [ "$active_clean" = "1" ]; then + echo "-------------------------------------" + echo "Cleaning venv" + rm -rf ${SD03_DIR}/env + export active_clean=0 + echo "Done!" + echo -e "-------------------------------------\n" +fi + +# create conda env if absent if [ ! -d ${SD03_DIR}/env ]; then conda create -p ${SD03_DIR}/env -y fi +# activate conda env and install basic tools source activate ${SD03_DIR}/env conda install -n base conda-libmamba-solver -y -conda install -c conda-forge git python=3.10 --solver=libmamba -y +conda install -c conda-forge python=3.10 --solver=libmamba -y cd ${SD03_DIR} @@ -31,8 +45,7 @@ fi pip install --use-pep517 --upgrade InvokeAI invokeai-configure --yes --root ${SD03_DIR}/invokeai --skip-sd-weights -# pip install ruamel.yaml==0.17.40 pillow==10.0.1 pypatchmatch - +# launch WebUI CMD="invokeai-web" while IFS= read -r param; do if [[ $param != \#* ]]; then diff --git a/04.sh b/04.sh index 537a995..ca454a8 100755 --- a/04.sh +++ b/04.sh @@ -2,71 +2,77 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" +export SD04_DIR=${BASE_DIR}/04-SD-Next export use_venv=1 echo "Install and run SD-Next" mkdir -p ${SD04_DIR} -if [ ! -d ${SD04_DIR}/env ]; then - conda create -p ${SD04_DIR}/env -y -fi - -source activate ${SD04_DIR}/env -conda install -n base conda-libmamba-solver -y -conda install -c conda-forge git python=3.11 pip gxx libcurand gcc gxx onnx --solver=libmamba -y -conda install -c nvidia cuda-cudart --solver=libmamba -y - +#clone main repository if [ ! -d ${SD04_DIR}/webui ]; then git clone https://github.com/vladmandic/automatic ${SD04_DIR}/webui fi cd ${SD04_DIR}/webui -if [ -d "${SD04_DIR}/webui/venv" ]; then - # check if remote is ahead of local - # https://stackoverflow.com/a/25109122/1469797 - if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ - sed 's/\// /g') | cut -f1) ]; then - echo "Local branch up-to-date, keeping existing venv" - else - if [ "$CLEAN_ENV" = "true" ]; then - echo "Forced wiping venv for clean packages install" - else - echo "Remote branch is ahead. Wiping venv for clean packages install" - fi - rm -rf ${SD04_DIR}/webui/venv - git pull -X ours +# check if remote is ahead of local +# https://stackoverflow.com/a/25109122/1469797 +if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ + sed 's/\// /g') | cut -f1) ]; then + echo "Local branch up-to-date, keeping existing venv" + else + if [ "$CLEAN_ENV" = "true" ]; then + echo "Forced wiping venv for clean packages install" + else + echo "Remote branch is ahead. Wiping venv for clean packages install" fi + export active_clean=1 + git pull -X ours fi -if [ ! -f "$SD04_DIR/parameters.txt" ]; then - cp -v "${SD_INSTALL_DIR}/parameters/04.txt" "$SD04_DIR/parameters.txt" +#clean virtual env +if [ "$active_clean" = "1" ]; then + echo "-------------------------------------" + echo "Cleaning venv" + rm -rf ${SD04_DIR}/env + rm -rf ${SD04_DIR}/webui/venv + export active_clean=0 + echo "Done!" + echo -e "-------------------------------------\n" fi -# Load updated malloc to fix memory leak -# https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/6850#issuecomment-1432435503 -# 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 + +#create conda env if needed +if [ ! -d ${SD04_DIR}/env ]; then + conda create -p ${SD04_DIR}/env -y fi +#activate and install basic tools +source activate ${SD04_DIR}/env +conda install -n base conda-libmamba-solver -y +conda install -c conda-forge python=3.11 pip gcc gxx --solver=libmamba -y + # Create venv if [ ! -d ${SD04_DIR}/webui/venv ]; then - echo "Activating venv" + echo "create venv" cd ${SD04_DIR}/webui python -m venv venv +fi + +# install dependencies cd ${SD04_DIR}/webui source venv/bin/activate pip install --upgrade pip - pip install onnxruntime-gpu + pip install coloredlogs flatbuffers numpy packaging protobuf==3.20.3 sympy + pip install onnxruntime-gpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ pip install insightface - pip install protobuf==3.20.3 + pip install basicsr + pip install sqlalchemy deactivate + +#copy default parameters if absent +if [ ! -f "$SD04_DIR/parameters.txt" ]; then + cp -v "${SD_INSTALL_DIR}/parameters/04.txt" "$SD04_DIR/parameters.txt" fi # Merge Models, vae, lora, hypernetworks, and outputs @@ -84,10 +90,8 @@ sl_folder ${SD04_DIR}/webui/models ControlNet ${BASE_DIR}/models controlnet sl_folder ${SD04_DIR}/webui outputs ${BASE_DIR}/outputs 04-SD-Next cd ${SD04_DIR}/webui/ -source venv/bin/activate -export PATH="/config/04-SD-Next/env/lib/python3.11/site-packages/onnxruntime/capi:$PATH" -pip install typing-extensions==4.8.0 numpy==1.24.4 huggingface_hub==0.18.0 sqlalchemy --upgrade +#Launch WebUI CMD="bash webui.sh" while IFS= read -r param; do if [[ $param != \#* ]]; then diff --git a/05.sh b/05.sh index 03c47a0..5a9ef59 100755 --- a/05.sh +++ b/05.sh @@ -2,28 +2,20 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" +export SD05_DIR=${BASE_DIR}/05-comfy-ui echo "Install and run Comfy-UI" mkdir -p ${SD05_DIR} mkdir -p /config/outputs/05-comfy-ui -if [ ! -d ${SD05_DIR}/env ]; then - conda create -p ${SD05_DIR}/env -y -fi -source activate ${SD05_DIR}/env -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 if [ ! -f "$SD05_DIR/parameters.txt" ]; then cp -v "${SD_INSTALL_DIR}/parameters/05.txt" "$SD05_DIR/parameters.txt" fi if [ ! -d ${SD05_DIR}/ComfyUI ]; then - git clone https://github.com/comfyanonymous/ComfyUI ${SD05_DIR}/ComfyUI + git clone https://github.com/comfyanonymous/ComfyUI.git ${SD05_DIR}/ComfyUI fi if [ ! -d ${SD05_DIR}/ComfyUI/custom_nodes/ComfyUI-Manager ]; then @@ -31,10 +23,24 @@ if [ ! -d ${SD05_DIR}/ComfyUI/custom_nodes/ComfyUI-Manager ]; then fi cd ${SD05_DIR}/ComfyUI/custom_nodes/ComfyUI-Manager +#git reset --hard HEAD git pull -X ours -cd ${SD05_DIR}/ComfyUI -git pull -X ours +# check if remote is ahead of local +# https://stackoverflow.com/a/25109122/1469797 +if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ +sed 's/\// /g') | cut -f1) ]; then + echo "Local branch up-to-date, keeping existing venv" + else + if [ "$CLEAN_ENV" = "true" ]; then + echo "Forced wiping venv for clean packages install" + else + echo "Remote branch is ahead. Wiping venv for clean packages install" + fi + export active_clean=1 +# git reset --hard HEAD + git pull -X ours +fi # Merge Models, vae, lora, hypernetworks, and outputs sl_folder ${SD05_DIR}/ComfyUI/models checkpoints ${BASE_DIR}/models stable-diffusion @@ -48,13 +54,39 @@ 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 +#clean conda env +if [ "$active_clean" = "1" ]; then + echo "-------------------------------------" + echo "Cleaning venv" + rm -rf ${SD01_DIR}/env + export active_clean=0 + echo "Done!" + echo -e "-------------------------------------\n" +fi + +#create conda env if needed +if [ ! -d ${SD05_DIR}/env ]; then + conda create -p ${SD05_DIR}/env -y +fi + +#activate env and install basic dependencies +source activate ${SD05_DIR}/env +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 + +#clean old venv if it still exists if [ -d ${SD05_DIR}/venv ]; then rm -rf ${SD05_DIR}/venv fi +#install requirements cd ${SD05_DIR}/ComfyUI pip install -r requirements.txt +#run webui CMD="python3 main.py" while IFS= read -r param; do if [[ $param != \#* ]]; then diff --git a/06.sh b/06.sh index efc1b8b..f8cce08 100755 --- a/06.sh +++ b/06.sh @@ -2,30 +2,63 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" +export SD06_DIR=${BASE_DIR}/06-Fooocus mkdir -p ${SD06_DIR} mkdir -p $BASE_DIR/outputs/06-Fooocus -if [ ! -d ${SD06_DIR}/env ]; then - conda create -p ${SD06_DIR}/env -y +#remove old venv if still present +if [ -d ${SD06_DIR}/venv ]; then + rm -rf ${SD06_DIR}/venv fi -source activate ${SD06_DIR}/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 - +#copy parameters if absent if [ ! -f "$SD06_DIR/parameters.txt" ]; then cp -v "${SD_INSTALL_DIR}/parameters/06.txt" "$SD06_DIR/parameters.txt" fi +#clone Fooocus repository if new install if [ ! -d ${SD06_DIR}/Fooocus ]; then cd "${SD06_DIR}" && git clone https://github.com/lllyasviel/Fooocus.git fi +# check if remote is ahead of local +# https://stackoverflow.com/a/25109122/1469797 cd ${SD06_DIR}/Fooocus -git pull -X ours +if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ +sed 's/\// /g') | cut -f1) ]; then + echo "Local branch up-to-date, keeping existing venv" + else + if [ "$CLEAN_ENV" = "true" ]; then + echo "Forced wiping venv for clean packages install" + else + echo "Remote branch is ahead. Wiping venv for clean packages install" + fi + export active_clean=1 +# git reset --hard HEAD + git pull -X ours +fi +#clean conda env if needed +if [ "$active_clean" = "1" ]; then + echo "-------------------------------------" + echo "Cleaning venv" + rm -rf ${SD06_DIR}/env + export active_clean=0 + echo "Done!" + echo -e "-------------------------------------\n" +fi + +#create env if missing +if [ ! -d ${SD06_DIR}/env ]; then + conda create -p ${SD06_DIR}/env -y +fi + +#activate env and install packages +source activate ${SD06_DIR}/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 sl_folder ${SD06_DIR}/Fooocus/models checkpoints ${BASE_DIR}/models stable-diffusion sl_folder ${SD06_DIR}/Fooocus/models loras ${BASE_DIR}/models lora @@ -38,12 +71,11 @@ sl_folder ${SD06_DIR}/Fooocus/models controlnet ${BASE_DIR}/models controlnet sl_folder ${SD06_DIR}/Fooocus outputs ${BASE_DIR}/outputs 06-Fooocus -if [ -d ${SD06_DIR}/venv ]; then - rm -rf ${SD06_DIR}/venv -fi - +#install requirements cd ${SD06_DIR}/Fooocus pip install -r requirements_versions.txt + +#Launch webUI CMD="python launch.py" while IFS= read -r param; do if [[ $param != \#* ]]; then diff --git a/07.sh b/07.sh index 701d99d..6a978fd 100755 --- a/07.sh +++ b/07.sh @@ -2,33 +2,64 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" +export SD07_DIR=${BASE_DIR}/07-StableSwarm mkdir -p ${SD07_DIR} mkdir -p /config/outputs/07-StableSwarm -if [ ! -d ${SD07_DIR}/env ]; then - conda create -p ${SD07_DIR}/env -y -fi - -source activate ${SD07_DIR}/env -conda install -n base conda-libmamba-solver -y -conda install -c conda-forge git python=3.11 pip --solver=libmamba -y - +#remove old venv if still exists if [ -d ${SD07_DIR}/venv ]; then rm -rf ${SD07_DIR}/venv fi +#copy default parameters if missing if [ ! -f "$SD07_DIR/parameters.txt" ]; then cp -v "${SD_INSTALL_DIR}/parameters/07.txt" "$SD07_DIR/parameters.txt" fi +#clone repository if new install if [ ! -d ${SD07_DIR}/StableSwarmUI ]; then - cd "${SD07_DIR}" && git clone https://github.com/Stability-AI/StableSwarmUI + cd "${SD07_DIR}" && git clone https://github.com/Stability-AI/StableSwarmUI.git fi +# check if remote is ahead of local +# https://stackoverflow.com/a/25109122/1469797 cd ${SD07_DIR}/StableSwarmUI -git pull -X ours +if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ +sed 's/\// /g') | cut -f1) ]; then + echo "Local branch up-to-date, keeping existing venv" + else + if [ "$CLEAN_ENV" = "true" ]; then + echo "Forced wiping venv for clean packages install" + else + echo "Remote branch is ahead. Wiping venv for clean packages install" + fi + export active_clean=1 +# git reset --hard HEAD + git pull -X ours +fi + +#clean conda env if needed +if [ "$active_clean" = "1" ]; then + echo "-------------------------------------" + echo "Cleaning venv" + rm -rf ${SD07_DIR}/env + export active_clean=0 + echo "Done!" + echo -e "-------------------------------------\n" +fi + +#create env if missing +if [ ! -d ${SD07_DIR}/env ]; then + conda create -p ${SD07_DIR}/env -y +fi + +#activate env and install packages +source activate ${SD07_DIR}/env +conda install -n base conda-libmamba-solver -y +conda install -c conda-forge git python=3.11 pip --solver=libmamba -y +#move models to common folder and create symlinks mkdir -p ${SD07_DIR}/StableSwarmUI/Models sl_folder ${SD07_DIR}/StableSwarmUI/Models Stable-Diffusion ${BASE_DIR}/models stable-diffusion @@ -40,6 +71,7 @@ sl_folder ${SD07_DIR}/StableSwarmUI/Models controlnet ${BASE_DIR}/models control sl_folder ${SD07_DIR}/StableSwarmUI Output ${BASE_DIR}/outputs 07-StableSwarm +#launch Stable Swarm cd ${SD07_DIR}/StableSwarmUI CMD="./launch-linux.sh" while IFS= read -r param; do diff --git a/08.sh b/08.sh.old old mode 100755 new mode 100644 similarity index 55% rename from 08.sh rename to 08.sh.old index 5076871..e262a26 --- a/08.sh +++ b/08.sh.old @@ -2,32 +2,59 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" +export SD08_DIR=${BASE_DIR}/08-voltaML mkdir -p ${SD08_DIR} mkdir -p /config/outputs/08-voltaML -if [ ! -d ${SD08_DIR}/env ]; then - conda create -p ${SD08_DIR}/env -y -fi - -source activate ${SD08_DIR}/env -conda install -n base conda-libmamba-solver -y -conda install -c conda-forge git python=3.10 pip=22.3.1 gcc gxx --solver=libmamba -y -conda install pytorch torchvision torchaudio -c pytorch --solver=libmamba -y - - - if [ ! -f "$SD08_DIR/parameters.txt" ]; then cp -v "${SD_INSTALL_DIR}/parameters/08.txt" "$SD08_DIR/parameters.txt" fi if [ ! -d "${SD08_DIR}/voltaML-fast-stable-diffusion" ]; then - cd "${SD08_DIR}" && git clone https://github.com/VoltaML/voltaML-fast-stable-diffusion + cd "${SD08_DIR}" && git clone https://github.com/VoltaML/voltaML-fast-stable-diffusion.git fi +# check if remote is ahead of local +# https://stackoverflow.com/a/25109122/1469797 cd ${SD08_DIR}/voltaML-fast-stable-diffusion -git pull -X ours +if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ +sed 's/\// /g') | cut -f1) ]; then + echo "Local branch up-to-date, keeping existing venv" + else + if [ "$CLEAN_ENV" = "true" ]; then + echo "Forced wiping venv for clean packages install" + else + echo "Remote branch is ahead. Wiping venv for clean packages install" + fi + export active_clean=1 +# git reset --hard HEAD + git pull -X ours +fi +#clean conda env if needed +if [ "$active_clean" = "1" ]; then + echo "-------------------------------------" + echo "Cleaning venv" + rm -rf ${SD08_DIR}/env + rm -rf ${SD08_DIR}/voltaML-fast-stable-diffusion/venv + export active_clean=0 + echo "Done!" + echo -e "-------------------------------------\n" +fi + +#create conda env if missing +if [ ! -d ${SD08_DIR}/env ]; then + conda create -p ${SD08_DIR}/env -y +fi + +#activate conda env and install packages +source activate ${SD08_DIR}/env +conda install -n base conda-libmamba-solver -y +conda install -c conda-forge git python=3.10 pip=22.3.1 gcc gxx --solver=libmamba -y +conda install pytorch torchvision torchaudio -c pytorch --solver=libmamba -y + +#create python venv if missing if [ ! -d ${SD08_DIR}/voltaML-fast-stable-diffusion/venv ]; then cd ${SD08_DIR}/voltaML-fast-stable-diffusion python -m venv venv @@ -35,14 +62,21 @@ fi cd ${SD08_DIR}/voltaML-fast-stable-diffusion source venv/bin/activate -#pip install --upgrade pip -pip install onnxruntime-gpu for fichier in ${SD08_DIR}/voltaML-fast-stable-diffusion/requirements/*.txt; do echo "installation of requirements" pip install -r $fichier done +pip install --upgrade pip +pip install coloredlogs flatbuffers numpy packaging protobuf==3.20.3 sympy +pip install packaging +pip install onnxruntime-gpu --extra-index-url https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/onnxruntime-cuda-12/pypi/simple/ +pip install insightface +pip install basicsr +pip install xformers --index-url https://download.pytorch.org/whl/cu121 + +#move models to common folders and create symlinks sl_folder ${SD08_DIR}/voltaML-fast-stable-diffusion/data models ${BASE_DIR}/models stable-diffusion sl_folder ${SD08_DIR}/voltaML-fast-stable-diffusion/data lora ${BASE_DIR}/models lora sl_folder ${SD08_DIR}/voltaML-fast-stable-diffusion/data vae ${BASE_DIR}/models vae @@ -50,16 +84,8 @@ sl_folder ${SD08_DIR}/voltaML-fast-stable-diffusion/data textual-inversion ${BAS sl_folder ${SD08_DIR}/voltaML-fast-stable-diffusion/data upscaler ${BASE_DIR}/models upscale sl_folder ${SD08_DIR}/voltaML-fast-stable-diffusion/data outputs /config/outputs 08-voltaML -# cd ${SD08_DIR} -# conda install -c conda-forge pytorch torchvis --solver=libmamba -y -# pip install -v -U git+https://github.com/chengzeyi/stable-fast.git@main#egg=stable-fast -# su -w SD08_DIR - diffusion -c 'cd ${SD08_DIR} && source venv/bin/activate && pip install torch==2.1.0+cu118 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 ' -# su -w SD08_DIR - diffusion -c 'cd ${SD08_DIR} && source venv/bin/activate && pip install diffusers xformers ninja ' -# su -w SD08_DIR - diffusion -c 'cd ${SD08_DIR} && source venv/bin/activate && pip install -v -U git+https://github.com/chengzeyi/stable-fast.git@main#egg=stable-fast ' - -# Boucle pour parcourir tous les fichiers requirements.txt cd ${SD08_DIR}/voltaML-fast-stable-diffusion -# source venv/bin/activate +# launch Volta ML CMD="python3 main.py" while IFS= read -r param; do if [[ $param != \#* ]]; then diff --git a/20.sh b/20.sh.old old mode 100755 new mode 100644 similarity index 95% rename from 20.sh rename to 20.sh.old index ffff9dc..9f3781f --- a/20.sh +++ b/20.sh.old @@ -3,6 +3,7 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" +export SD20_DIR=${BASE_DIR}/20-kubin mkdir -p "${SD20_DIR}" mkdir -p /config/outputs/20-kubin @@ -21,7 +22,7 @@ if [ ! -f "$SD20_DIR/parameters.txt" ]; then fi if [ ! -d ${SD20_DIR}/kuby ]; then - cd "${SD20_DIR}" && git clone https://github.com/seruva19/kubin + cd "${SD20_DIR}" && git clone https://github.com/seruva19/kubin.git fi cd ${SD20_DIR}/kubin diff --git a/50.sh b/50.sh index 5d834c6..7c02b99 100755 --- a/50.sh +++ b/50.sh @@ -2,6 +2,7 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" +export SD50_DIR=${BASE_DIR}/50-IOPaint mkdir -p "${SD50_DIR}/IOPaint" mkdir -p /config/outputs/50-IOPaint diff --git a/51.sh b/51.sh index 95e0a0a..3a5f8a4 100755 --- a/51.sh +++ b/51.sh @@ -2,6 +2,7 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" +export SD51_DIR=${BASE_DIR}/51-facefusion mkdir -p ${SD51_DIR} mkdir -p /config/outputs/51-facefusion diff --git a/70.sh b/70.sh index f373cdd..e794a43 100755 --- a/70.sh +++ b/70.sh @@ -2,25 +2,11 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" +export SD70_DIR=${BASE_DIR}/70-kohya mkdir -p ${SD70_DIR} mkdir -p /config/outputs/70-kohya -if [ ! -d ${SD70_DIR}/env ]; then - conda create -p ${SD70_DIR}/env -y -fi - -source activate ${SD70_DIR}/env -conda install -n base conda-libmamba-solver -y -conda install -c conda-forge git python=3.10 pip --solver=libmamba -y - -# Create venv -if [ ! -d ${SD70_DIR}/venv ]; then - cd ${SD70_DIR} - python -m venv venv - cd ${SD70_DIR} -fi - if [ ! -f "$SD70_DIR/parameters.txt" ]; then cp -v "${SD_INSTALL_DIR}/parameters/70.txt" "$SD70_DIR/parameters.txt" fi @@ -29,21 +15,51 @@ if [ ! -d ${SD70_DIR}/kohya_ss ]; then cd "${SD70_DIR}" && git clone https://github.com/bmaltais/kohya_ss fi - cd ${SD70_DIR}/kohya_ss - git config --global --add safe.directory ${SD70_DIR}/kohya_ss +# check if remote is ahead of local +# https://stackoverflow.com/a/25109122/1469797 +cd ${SD70_DIR}/kohya_ss +if [ "$CLEAN_ENV" != "true" ] && [ $(git rev-parse HEAD) = $(git ls-remote $(git rev-parse --abbrev-ref @{u} | \ +sed 's/\// /g') | cut -f1) ]; then + echo "Local branch up-to-date, keeping existing venv" + else + if [ "$CLEAN_ENV" = "true" ]; then + echo "Forced wiping venv for clean packages install" + else + echo "Remote branch is ahead. Wiping venv for clean packages install" + fi + export active_clean=1 +# git reset --hard HEAD git pull -X ours +fi + +#clean conda env if needed +if [ "$active_clean" = "1" ]; then + echo "-------------------------------------" + echo "Cleaning venv" + rm -rf ${SD70_DIR}/env + export active_clean=0 + echo "Done!" + echo -e "-------------------------------------\n" +fi + +#create conda env +if [ ! -d ${SD70_DIR}/env ]; then + conda create -p ${SD70_DIR}/env -y +fi -# if [ ! -d ${SD70_DIR}/venv ]; then -# su -w SD70_DIR - diffusion -c 'cd ${SD70_DIR} && python3 -m venv venv' -# fi +source activate ${SD70_DIR}/env +conda install -n base conda-libmamba-solver -y +conda install -c conda-forge python=3.10 pip --solver=libmamba -y -cd ${SD70_DIR} -source venv/bin/activate +#install dependencies pip install --upgrade pip cd ${SD70_DIR}/kohya_ss -pip install -r requirements.txt +python ./setup/setup_linux.py cd ${SD70_DIR}/kohya_ss -CMD="bash gui.sh"; while IFS= read -r param; do if [[ $param != \#* ]]; then CMD+=" ${param}"; fi; done < "${SD70_DIR}/parameters.txt"; eval $CMD + +#launch Kohya +echo LAUNCHING KOHYA_SS ! +CMD="python kohya_gui.py"; while IFS= read -r param; do if [[ $param != \#* ]]; then CMD+=" ${param}"; fi; done < "${SD70_DIR}/parameters.txt"; eval $CMD diff --git a/Dockerfile b/Dockerfile index d2b7f99..02edaec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,18 +6,6 @@ ENV DEBIAN_FRONTEND=noninteractive ENV WEBUI_VERSION=01 ENV BASE_DIR=/config \ SD_INSTALL_DIR=/opt/sd-install \ - SD01_DIR=/config/01-easy-diffusion \ - SD02_DIR=/config/02-sd-webui \ - SD03_DIR=/config/03-invokeai \ - SD04_DIR=/config/04-SD-Next \ - SD05_DIR=/config/05-comfy-ui \ - SD06_DIR=/config/06-Fooocus \ - SD07_DIR=/config/07-StableSwarm \ - SD08_DIR=/config/08-voltaML \ - SD20_DIR=/config/20-kubin \ - SD50_DIR=/config/50-IOPaint \ - SD51_DIR=/config/51-facefusion \ - SD70_DIR=/config/70-kohya \ XDG_CACHE_HOME=/config/temp RUN apt-get update -y -q=2 && \ @@ -39,9 +27,9 @@ RUN apt-get update -y -q=2 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -RUN mkdir -p ${BASE_DIR}\temp ${SD_INSTALL_DIR} /config/outputs +RUN mkdir -p ${BASE_DIR}\temp ${SD_INSTALL_DIR} ${BASE_DIR}/outputs -ADD parameters/* /opt/sd-install/parameters/ +ADD parameters/* ${SD_INSTALL_DIR}/parameters/ COPY --chown=abc:abc *.sh ./ @@ -57,7 +45,7 @@ RUN cd /tmp && \ bash Miniconda3-latest-Linux-x86_64.sh -b && \ rm Miniconda3-latest-Linux-x86_64.sh && \ chown -R abc:abc /root && \ - chown -R abc:abc /opt/sd-install + chown -R abc:abc ${SD_INSTALL_DIR} EXPOSE 9000/tcp diff --git a/docker/root/etc/s6-overlay/s6-rc.d/init-chown/run b/docker/root/etc/s6-overlay/s6-rc.d/init-chown/run index d932cef..bb56287 100755 --- a/docker/root/etc/s6-overlay/s6-rc.d/init-chown/run +++ b/docker/root/etc/s6-overlay/s6-rc.d/init-chown/run @@ -1,9 +1,22 @@ #!/usr/bin/with-contenv bash -echo "-------------------------------------" +#echo "-------------------------------------" # permissions -echo "chown'ing directory to ensure correct permissions." +#echo "chown'ing home directory to ensure correct permissions." chown -R abc:abc /home/abc -chown -R abc:abc /config +#echo "Done!" +#echo -e "-------------------------------------\n" + +# reset rights if file "Delete this file to reset access rights at next launch" isn't present +if [ ! -f "$BASE_DIR/Delete this file to reset access rights at next launch" ]; then +echo "-------------------------------------" +echo "chown'ing directory to ensure correct permissions." +chown -R abc:users $BASE_DIR +chmod -R 774 $BASE_DIR +chmod -R 664 $BASE_DIR/models +chmod -R 664 $BASE_DIR/outputs +find $BASE_DIR -type d -exec chmod 777 {} + +echo Delete this file to reset access rights at next launch > $BASE_DIR/'Delete this file to reset access rights at next launch' echo "Done!" echo -e "-------------------------------------\n" +fi \ No newline at end of file diff --git a/entry.sh b/entry.sh index 5cd4093..6ae3aef 100644 --- a/entry.sh +++ b/entry.sh @@ -7,8 +7,16 @@ if [ ! -f "$BASE_DIR/scripts/custom-sample.sh" ]; then cp -v "/custom-sample.sh" "$BASE_DIR/scripts/custom-sample.sh" fi +# if file "Delete this file to clean virtual env and dependencies at next launch" isn't present +if [ -f "$BASE_DIR/Delete this file to clean virtual env and dependencies at next launch" ]; then +export active_clean=0 +else +export active_clean=1 +echo Delete this file to clean virtual env and dependencies at next launch > $BASE_DIR/'Delete this file to clean virtual env and dependencies at next launch' +fi + . /$WEBUI_VERSION.sh . /$WEBUI_VERSION . $BASE_DIR/scripts/$WEBUI_VERSION . $BASE_DIR/scripts/$WEBUI_VERSION.sh -echo error in webui selection variable \ No newline at end of file +echo error when launching WebUI \ No newline at end of file diff --git a/parameters/04.txt b/parameters/04.txt index 7670d9d..660f931 100644 --- a/parameters/04.txt +++ b/parameters/04.txt @@ -5,4 +5,4 @@ # SD-Next options --insecure --medvram ---allow-code +--allow-code \ No newline at end of file