aboutsummaryrefslogtreecommitdiff
path: root/webui.sh
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-04-29 13:24:50 +0300
committerGitHub <noreply@github.com>2023-04-29 13:24:50 +0300
commit43dd2378af79d1ac91640e14bf64fa5692bfb74b (patch)
tree3125d896616fda93a766f56c88a7a747d2eefa3d /webui.sh
parent54fd00ff8f6fc1396ce0396772962b45609e7a9c (diff)
parent32c3b97669b873baaccf2070a7a478b9b9a27cef (diff)
Merge branch 'dev' into generation_params_fix
Diffstat (limited to 'webui.sh')
-rwxr-xr-xwebui.sh23
1 files changed, 19 insertions, 4 deletions
diff --git a/webui.sh b/webui.sh
index 8cdad22d..30beac5b 100755
--- a/webui.sh
+++ b/webui.sh
@@ -23,7 +23,7 @@ fi
# Install directory without trailing slash
if [[ -z "${install_dir}" ]]
then
- install_dir="/home/$(whoami)"
+ install_dir="${HOME}"
fi
# Name of the subdirectory (defaults to stable-diffusion-webui)
@@ -113,13 +113,13 @@ case "$gpu_info" in
printf "Experimental support for Renoir: make sure to have at least 4GB of VRAM and 10GB of RAM or enable cpu mode: --use-cpu all --no-half"
printf "\n%s\n" "${delimiter}"
;;
- *)
+ *)
;;
esac
if echo "$gpu_info" | grep -q "AMD" && [[ -z "${TORCH_COMMAND}" ]]
then
export TORCH_COMMAND="pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/rocm5.2"
-fi
+fi
for preq in "${GIT}" "${python_cmd}"
do
@@ -172,15 +172,30 @@ else
exit 1
fi
+# Try using TCMalloc on Linux
+prepare_tcmalloc() {
+ if [[ "${OSTYPE}" == "linux"* ]] && [[ -z "${NO_TCMALLOC}" ]] && [[ -z "${LD_PRELOAD}" ]]; then
+ TCMALLOC="$(ldconfig -p | grep -Po "libtcmalloc.so.\d" | head -n 1)"
+ if [[ ! -z "${TCMALLOC}" ]]; then
+ echo "Using TCMalloc: ${TCMALLOC}"
+ export LD_PRELOAD="${TCMALLOC}"
+ else
+ printf "\e[1m\e[31mCannot locate TCMalloc (improves CPU memory usage)\e[0m\n"
+ fi
+ fi
+}
+
if [[ ! -z "${ACCELERATE}" ]] && [ ${ACCELERATE}="True" ] && [ -x "$(command -v accelerate)" ]
then
printf "\n%s\n" "${delimiter}"
printf "Accelerating launch.py..."
printf "\n%s\n" "${delimiter}"
+ prepare_tcmalloc
exec 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}"
+ printf "\n%s\n" "${delimiter}"
+ prepare_tcmalloc
exec "${python_cmd}" "${LAUNCH_SCRIPT}" "$@"
fi