diff --git a/02.forge.sh b/02.forge.sh new file mode 100644 index 0000000..0838c6e --- /dev/null +++ b/02.forge.sh @@ -0,0 +1,85 @@ +#!/bin/bash +source /sl_folder.sh + +export PATH="/home/abc/miniconda3/bin:$PATH" +export active_clean=0 + +# disable the use of a python venv +export venv_dir="-" + +# Install or update Stable-Diffusion-WebUI +mkdir -p ${SD02_DIR} + +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 + +cd ${SD02_DIR}/forge + +# 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 + +#clean conda env +if [ "$active_clean" = "1" ]; then + conda deactivate + conda remove -p ${SD02_DIR}/conda-env --all -y + conda create -p ${SD02_DIR}/conda-env -y + source activate ${SD02_DIR}/conda-env +fi +conda install -c conda-forge git 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 + +pip install --upgrade pip +pip install packaging +pip install onnxruntime-gpu +pip install insightface +pip install protobuf==3.20.3 + +# Merge Models, vae, lora, and hypernetworks, and outputs +# Ignore move errors if they occur +sl_folder ${SD02_DIR}/forge/models Stable-diffusion ${BASE_DIR}/models stable-diffusion +sl_folder ${SD02_DIR}/forge/models hypernetworks ${BASE_DIR}/models hypernetwork +sl_folder ${SD02_DIR}/forge/models Lora ${BASE_DIR}/models lora +sl_folder ${SD02_DIR}/forge/models VAE ${BASE_DIR}/models vae +sl_folder ${SD02_DIR}/forge embeddings ${BASE_DIR}/models embeddings +sl_folder ${SD02_DIR}/forge/models ESRGAN ${BASE_DIR}/models upscale +sl_folder ${SD02_DIR}/forge/models BLIP ${BASE_DIR}/models blip +sl_folder ${SD02_DIR}/forge/models Codeformer ${BASE_DIR}/models codeformer +sl_folder ${SD02_DIR}/forge/models GFPGAN ${BASE_DIR}/models gfpgan +sl_folder ${SD02_DIR}/forge/models LDSR ${BASE_DIR}/models ldsr +sl_folder ${SD02_DIR}/forge/models ControlNet ${BASE_DIR}/models controlnet + +sl_folder ${SD02_DIR}/forge outputs ${BASE_DIR}/outputs 02-sd-webui + +echo "Run Stable-Diffusion-WebUI-forge" +cd ${SD02_DIR}/forge +CMD="bash webui.sh" +while IFS= read -r param; do + if [[ $param != \#* ]]; then + CMD+=" ${param}" + fi +done < "${SD02_DIR}/parameters.txt" +eval $CMD diff --git a/02.sh b/02.sh index d9e7334..cd61e4a 100755 --- a/02.sh +++ b/02.sh @@ -2,21 +2,21 @@ source /sl_folder.sh export PATH="/home/abc/miniconda3/bin:$PATH" +export active_clean=0 -export use_venv=1 +# disable the use of a python venv +export venv_dir="-" # Install or update Stable-Diffusion-WebUI mkdir -p ${SD02_DIR} -if [ ! -d ${SD02_DIR}/env ]; then - conda create -p ${SD02_DIR}/env -y +if [ ! -d ${SD02_DIR}/conda-env ]; then + conda create -p ${SD02_DIR}/conda-env -y fi -source activate ${SD02_DIR}/env +source activate ${SD02_DIR}/conda-env conda install -n base conda-libmamba-solver -y -conda install -c conda-forge git python=3.11 pip gcc gxx libcurand --solver=libmamba -y - - +conda install -c git python=3.11 pip --solver=libmamba -y if [ ! -d ${SD02_DIR}/webui ]; then git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui ${SD02_DIR}/webui @@ -24,40 +24,39 @@ fi cd ${SD02_DIR}/webui -if [ -d "${SD02_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 +# 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" + echo "Forced wiping venv for clean packages install" else - echo "Remote branch is ahead. Wiping venv for clean packages install" + echo "Remote branch is ahead. Wiping venv for clean packages install" fi - rm -rf ${SD02_DIR}/webui/venv - git pull -X ours - fi + export active_clean=1 + git pull -X ours fi +#clean conda env +if [ "$active_clean" = "1" ]; then + conda deactivate + conda remove -p ${SD02_DIR}/conda-env --all -y + conda create -p ${SD02_DIR}/conda-env -y + source activate ${SD02_DIR}/conda-env +fi +conda install -c conda-forge git python=3.11 pip gcc gxx libcurand --solver=libmamba -y + if [ ! -f "$SD02_DIR/parameters.txt" ]; then cp -v "/opt/sd-install/parameters/02.txt" "$SD02_DIR/parameters.txt" fi -# Create venv -if [ ! -d ${SD02_DIR}/webui/venv ]; then - cd ${SD02_DIR}/webui - python -m venv venv - cd ${SD02_DIR}/webui - source venv/bin/activate - pip install --upgrade pip - pip install packaging - pip install onnxruntime-gpu - pip install insightface - pip install protobuf==3.20.3 - deactivate -fi +pip install --upgrade pip +pip install packaging +pip install onnxruntime-gpu +pip install insightface +pip install protobuf==3.20.3 # Merge Models, vae, lora, and hypernetworks, and outputs # Ignore move errors if they occur @@ -71,15 +70,12 @@ sl_folder ${SD02_DIR}/webui/models BLIP ${BASE_DIR}/models blip sl_folder ${SD02_DIR}/webui/models Codeformer ${BASE_DIR}/models codeformer sl_folder ${SD02_DIR}/webui/models GFPGAN ${BASE_DIR}/models gfpgan sl_folder ${SD02_DIR}/webui/models LDSR ${BASE_DIR}/models ldsr +sl_folder ${SD02_DIR}/webui/models ControlNet ${BASE_DIR}/models controlnet sl_folder ${SD02_DIR}/webui outputs ${BASE_DIR}/outputs 02-sd-webui echo "Run Stable-Diffusion-WebUI" cd ${SD02_DIR}/webui -source venv/bin/activate -export PATH="/config/02-sd-webui/webui/venv/lib/python3.11/site-packages/onnxruntime/capi:$PATH" -pip install --upgrade pip - CMD="bash webui.sh" while IFS= read -r param; do if [[ $param != \#* ]]; then diff --git a/parameters/02.forge.txt b/parameters/02.forge.txt new file mode 100644 index 0000000..32fef65 --- /dev/null +++ b/parameters/02.forge.txt @@ -0,0 +1,16 @@ +# Web + Network +--listen +--port 9000 + +# options +--enable-insecure-extension-access +--xformers +--api +--cuda-malloc +--cuda-stream + +#--no-half-vae +#--disable-nan-check +#--update-all-extensions +#--reinstall-xformers +#--reinstall-torch diff --git a/parameters/02.txt b/parameters/02.txt index f7a2a25..cd191ee 100644 --- a/parameters/02.txt +++ b/parameters/02.txt @@ -12,4 +12,4 @@ #--disable-nan-check #--update-all-extensions #--reinstall-xformers -#--reinstall-torch +#--reinstall-torch