diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-04-29 10:02:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-29 10:02:00 +0000 |
commit | 1ffb44b0b2c9cb5fb379274515772741a9c1dbaf (patch) | |
tree | 04386811ecd778e79d11971e1dc1a5732e064e79 /webui.sh | |
parent | e847df7ee937c41d2d8e9ad586570637b69a9e00 (diff) | |
parent | 8af4b3bbe46dcb7f701d3650b6e4d31d6dd268a7 (diff) | |
download | stable-diffusion-webui-gfx803-1ffb44b0b2c9cb5fb379274515772741a9c1dbaf.tar.gz stable-diffusion-webui-gfx803-1ffb44b0b2c9cb5fb379274515772741a9c1dbaf.tar.bz2 stable-diffusion-webui-gfx803-1ffb44b0b2c9cb5fb379274515772741a9c1dbaf.zip |
Merge pull request #9593 from gakada/tcmalloc
Try using TCMalloc on Linux by default
Diffstat (limited to 'webui.sh')
-rwxr-xr-x | webui.sh | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -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 |