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
85 changes: 85 additions & 0 deletions 02.forge.sh
Original file line number Diff line number Diff line change
@@ -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
68 changes: 32 additions & 36 deletions 02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,61 @@
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
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
Expand All @@ -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
Expand Down
16 changes: 16 additions & 0 deletions parameters/02.forge.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion parameters/02.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
#--disable-nan-check
#--update-all-extensions
#--reinstall-xformers
#--reinstall-torch
#--reinstall-torch