diff options
author | gk <gkpyon@gmail.com> | 2023-04-12 23:46:59 +0000 |
---|---|---|
committer | gk <gkpyon@gmail.com> | 2023-04-13 01:19:03 +0000 |
commit | 8af4b3bbe46dcb7f701d3650b6e4d31d6dd268a7 (patch) | |
tree | 5a845479c1cd13155f89d4753f2d8822221ab05b | |
parent | 22bcc7be428c94e9408f589966c2040187245d81 (diff) | |
download | stable-diffusion-webui-gfx803-8af4b3bbe46dcb7f701d3650b6e4d31d6dd268a7.tar.gz stable-diffusion-webui-gfx803-8af4b3bbe46dcb7f701d3650b6e4d31d6dd268a7.tar.bz2 stable-diffusion-webui-gfx803-8af4b3bbe46dcb7f701d3650b6e4d31d6dd268a7.zip |
Try using TCMalloc on Linux by default
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | webui-user.sh | 3 | ||||
-rwxr-xr-x | webui.sh | 21 |
3 files changed, 22 insertions, 3 deletions
@@ -120,6 +120,7 @@ sudo pacman -S wget git python3 bash <(wget -qO- https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh)
```
3. Run `webui.sh`.
+4. Check `webui-user.sh` for options.
### Installation on Apple Silicon
Find the instructions [here](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Installation-on-Apple-Silicon).
diff --git a/webui-user.sh b/webui-user.sh index bfa53cb7..49a426ff 100644 --- a/webui-user.sh +++ b/webui-user.sh @@ -43,4 +43,7 @@ # Uncomment to enable accelerated launch #export ACCELERATE="True" +# Uncomment to disable TCMalloc +#export NO_TCMALLOC="True" + ########################################### @@ -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 |