diff options
| author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-05-08 09:01:25 +0300 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-08 09:01:25 +0300 | 
| commit | 73d956454f0111ffdbebc0285033ca3dd630346b (patch) | |
| tree | 4396fd0dfed3e0a7a5aac04a159619cec1b2f535 /webui.sh | |
| parent | 57a3d146e3e193904c1c5e148f7244b9d045f157 (diff) | |
| parent | b15bbef798f5aba047f0e6955ce94fe589071b44 (diff) | |
| download | stable-diffusion-webui-gfx803-73d956454f0111ffdbebc0285033ca3dd630346b.tar.gz | |
Merge branch 'dev' into tooltip
Diffstat (limited to 'webui.sh')
| -rwxr-xr-x | webui.sh | 59 | 
1 files changed, 41 insertions, 18 deletions
| @@ -23,7 +23,7 @@ fi  # Install directory without trailing slash  if [[ -z "${install_dir}" ]]  then -    install_dir="/home/$(whoami)" +    install_dir="$(pwd)"  fi  # Name of the subdirectory (defaults to stable-diffusion-webui) @@ -113,12 +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" +    # AMD users will still use torch 1.13 because 2.0 does not seem to work. +    export TORCH_COMMAND="pip install torch==1.13.1+rocm5.2 torchvision==0.14.1+rocm5.2 --index-url https://download.pytorch.org/whl/rocm5.2"  fi    for preq in "${GIT}" "${python_cmd}" @@ -152,35 +153,57 @@ else      cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; }  fi -printf "\n%s\n" "${delimiter}" -printf "Create and activate python venv" -printf "\n%s\n" "${delimiter}" -cd "${install_dir}"/"${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } -if [[ ! -d "${venv_dir}" ]] -then -    "${python_cmd}" -m venv "${venv_dir}" -    first_launch=1 -fi -# shellcheck source=/dev/null -if [[ -f "${venv_dir}"/bin/activate ]] +if [[ -z "${VIRTUAL_ENV}" ]];  then -    source "${venv_dir}"/bin/activate +    printf "\n%s\n" "${delimiter}" +    printf "Create and activate python venv" +    printf "\n%s\n" "${delimiter}" +    cd "${install_dir}"/"${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; } +    if [[ ! -d "${venv_dir}" ]] +    then +        "${python_cmd}" -m venv "${venv_dir}" +        first_launch=1 +    fi +    # shellcheck source=/dev/null +    if [[ -f "${venv_dir}"/bin/activate ]] +    then +        source "${venv_dir}"/bin/activate +    else +        printf "\n%s\n" "${delimiter}" +        printf "\e[1m\e[31mERROR: Cannot activate python venv, aborting...\e[0m" +        printf "\n%s\n" "${delimiter}" +        exit 1 +    fi  else      printf "\n%s\n" "${delimiter}" -    printf "\e[1m\e[31mERROR: Cannot activate python venv, aborting...\e[0m" +    printf "python venv already activate: ${VIRTUAL_ENV}"      printf "\n%s\n" "${delimiter}" -    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 | 
