aboutsummaryrefslogtreecommitdiffstats
path: root/webui.sh
diff options
context:
space:
mode:
authorpapuSpartan <30642826+papuSpartan@users.noreply.github.com>2022-12-10 08:02:39 +0000
committerGitHub <noreply@github.com>2022-12-10 08:02:39 +0000
commit6387043fd2c3311d66690ff27d7da0e030b29cd8 (patch)
tree075559ce3e52511cdd459da2b4cc33360d6eb258 /webui.sh
parent00ebc26c4e2962a31e067539d89cd695d999539a (diff)
parent1d01404c5615debfca24f7fbe429ddd2f5b11eb9 (diff)
downloadstable-diffusion-webui-gfx803-6387043fd2c3311d66690ff27d7da0e030b29cd8.tar.gz
stable-diffusion-webui-gfx803-6387043fd2c3311d66690ff27d7da0e030b29cd8.tar.bz2
stable-diffusion-webui-gfx803-6387043fd2c3311d66690ff27d7da0e030b29cd8.zip
Merge branch 'AUTOMATIC1111:master' into master
Diffstat (limited to 'webui.sh')
-rwxr-xr-xwebui.sh39
1 files changed, 34 insertions, 5 deletions
diff --git a/webui.sh b/webui.sh
index cc06f344..683c97d3 100755
--- a/webui.sh
+++ b/webui.sh
@@ -3,6 +3,15 @@
# Please do not make any changes to this file, #
# change the variables in webui-user.sh instead #
#################################################
+
+# If run from macOS, load defaults from webui-macos-env.sh
+if [[ "$OSTYPE" == "darwin"* ]]; then
+ if [[ -f webui-macos-env.sh ]]
+ then
+ source ./webui-macos-env.sh
+ fi
+fi
+
# Read variables from webui-user.sh
# shellcheck source=/dev/null
if [[ -f webui-user.sh ]]
@@ -46,6 +55,18 @@ then
LAUNCH_SCRIPT="launch.py"
fi
+# this script cannot be run as root by default
+can_run_as_root=0
+
+# read any command line flags to the webui.sh script
+while getopts "f" flag > /dev/null 2>&1
+do
+ case ${flag} in
+ f) can_run_as_root=1;;
+ *) break;;
+ esac
+done
+
# Disable sentry logging
export ERROR_REPORTING=FALSE
@@ -61,7 +82,7 @@ printf "\e[1m\e[34mTested on Debian 11 (Bullseye)\e[0m"
printf "\n%s\n" "${delimiter}"
# Do not run as root
-if [[ $(id -u) -eq 0 ]]
+if [[ $(id -u) -eq 0 && can_run_as_root -eq 0 ]]
then
printf "\n%s\n" "${delimiter}"
printf "\e[1m\e[31mERROR: This script must not be launched as root, aborting...\e[0m"
@@ -134,7 +155,15 @@ else
exit 1
fi
-printf "\n%s\n" "${delimiter}"
-printf "Launching launch.py..."
-printf "\n%s\n" "${delimiter}"
-"${python_cmd}" "${LAUNCH_SCRIPT}" "$@"
+if [[ ! -z "${ACCELERATE}" ]] && [ ${ACCELERATE}="True" ] && [ -x "$(command -v accelerate)" ]
+then
+ printf "\n%s\n" "${delimiter}"
+ printf "Accelerating launch.py..."
+ printf "\n%s\n" "${delimiter}"
+ accelerate launch --num_cpu_threads_per_process=6 "${LAUNCH_SCRIPT}" "$@"
+else
+ printf "\n%s\n" "${delimiter}"
+ printf "Launching launch.py..."
+ printf "\n%s\n" "${delimiter}"
+ "${python_cmd}" "${LAUNCH_SCRIPT}" "$@"
+fi