From 2a5d7ad6767958325edb59d0da38aeee44bcdd0e Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Tue, 24 Jan 2023 09:05:52 -0500 Subject: [PATCH] new startup script --- README.md | 45 +++++++++++++++++++++++------- automatic.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++++++---- install.sh | 8 ------ secure.sh | 7 ----- train.sh | 9 ------ 5 files changed, 107 insertions(+), 39 deletions(-) delete mode 100755 install.sh delete mode 100755 secure.sh delete mode 100755 train.sh diff --git a/README.md b/README.md index 71063d887..91193d9a0 100644 --- a/README.md +++ b/README.md @@ -18,17 +18,42 @@ Fork adds extra functionality: e.g. `generate`, `train`, `bench`, etc. [Full list]() -Fork does differ in few things: +Simplified start script: `automatic.sh` +*Existing `webui.sh` still exists for backward compatibility, fresh installs to auto-install dependencies, etc.* -- Additional simplified start script - > ./automatic.sh - > ./secure.sh - - Use `secure.sh` if you want to startup with username/password auth enabled and listen on global IP - Existing `webui.sh` still exists for fresh installs to auto-install dependencies, etc. -- Additional simplified install script - > ./install.sh -- Drops compatibility with `python` **3.7** and requires **3.10** +> ./automatic.sh + +- Start in default mode with optimizations enabled + +> ./automatic.sh env + +- Print env info and exit + Example: + + Version: c07487a Tue Jan 24 08:04:31 2023 -0500 + Platform: Ubuntu 22.04.1 LTS 5.15.79.1-microsoft-standard-WSL2 x86_64 + Python 3.10.6 + Torch: 2.0.0.dev20230118+cu118 CUDA: 11.8 cuDNN: 8700 GPU: NVIDIA GeForce RTX 3060 Arch: (8, 6) + +> ./automatic.sh install + +- Install requirements and exit + +> ./automatic.sh public + +- Start with listen on public IP with authentication enabled + +> ./automatic.sh clean + +- Start with all optimizations disabled + Use this for troubleshooting + +
+ +## Differences + +Fork does differ in few things: +- Drops compatibility with `python` **3.7** and requires **3.9** - Updated **Python** libraries to latest known compatible versions e.g. `accelerate`, `transformers`, `numpy`, etc. - Includes opinionated **System** and **Options** configuration diff --git a/automatic.sh b/automatic.sh index c54ba3dde..ccb49f4db 100755 --- a/automatic.sh +++ b/automatic.sh @@ -1,8 +1,75 @@ #/bin/env bash -export TF_CPP_MIN_LOG_LEVEL=2 -export FORCE_CUDA="1" -export ATTN_PRECISION=fp16 -export PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512 -exec accelerate launch --num_cpu_threads_per_process=6 launch.py --api --xformers --disable-console-progressbars "$@" +TF_CPP_MIN_LOG_LEVEL=2 +FORCE_CUDA="1" +ATTN_PRECISION=fp16 +PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512 +# TORCH_CUDA_ARCH_LIST="8.6" +ARGS="--num_cpu_threads_per_process=6 launch.py --api --xformers --disable-console-progressbars" # --opt-channelslast +MODE=optimized + +if [[ $(id -u) -eq 0 ]]; then + echo "Running as root, aborting" + exit 1 +fi + +for i in "$@"; do + case $i in + install) + MODE=install + ;; + public) + MODE=public + ;; + clean) + MODE=clean + ;; + env) + MODE=env + ;; + *) + ARGS="$ARGS $i" + ;; + esac + shift +done + +echo "SD server: $MODE" + +if [ $MODE == install ]; then + python --version + pip3 --version + echo "Installing general requirements" + pip3 install --disable-pip-version-check --quiet --no-warn-conflicts --requirement requirements.txt + echo "Installing versioned requirements" + pip3 install --disable-pip-version-check --quiet --no-warn-conflicts --requirement requirements_versions.txt + exit 0 +fi + +if [ $MODE == env ]; then + VER=`git log -1 --pretty=format:"%h %ad"` + LSB=`lsb_release -ds 2>/dev/null` + UN=`uname -rm 2>/dev/null` + echo "Version: $VER" + echo "Platform: $LSB $UN" + python --version + python -c 'import torch; print("Torch:", torch.__version__, "CUDA:", torch.version.cuda, "cuDNN:", torch.backends.cudnn.version(), "GPU:", torch.cuda.get_device_name(torch.cuda.current_device()), "Arch:", torch.cuda.get_device_capability());' + exit 0 +fi + +if [ $MODE == clean ]; then + ARGS="$ARGS ----disable-opt-split-attention" + python launch.py "$ARGS" + exit 0 +fi + +if [ $MODE == public ]; then + ARGS="$ARGS --port 8000 --gradio-auth admin:pwd --listen --enable-insecure-extension-access" +fi + +if [ $MODE == optimized ]; then + ARGS="$ARGS --xformers" +fi + +exec accelerate launch "$ARGS" diff --git a/install.sh b/install.sh deleted file mode 100755 index 77947bc4f..000000000 --- a/install.sh +++ /dev/null @@ -1,8 +0,0 @@ -#/bin/env bash - -python --version -pip3 --version -echo "installing general requirements" -pip3 install --disable-pip-version-check --quiet --no-warn-conflicts --requirement requirements.txt -echo "installing versioned requirements" -pip3 install --disable-pip-version-check --quiet --no-warn-conflicts --requirement requirements_versions.txt diff --git a/secure.sh b/secure.sh deleted file mode 100755 index 47b853f06..000000000 --- a/secure.sh +++ /dev/null @@ -1,7 +0,0 @@ -#/bin/env bash - -export TF_CPP_MIN_LOG_LEVEL=2 -export FORCE_CUDA="1" -export ATTN_PRECISION=fp16 -export PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512 -exec accelerate launch --num_cpu_threads_per_process=6 launch.py --api --xformers --disable-console-progressbars --port 8000 --gradio-auth admin:pwd --listen --enable-insecure-extension-access "$@" diff --git a/train.sh b/train.sh deleted file mode 100755 index 015542bf0..000000000 --- a/train.sh +++ /dev/null @@ -1,9 +0,0 @@ -#/bin/env bash -echo "Running without optimizations" - -export TF_CPP_MIN_LOG_LEVEL=2 -export FORCE_CUDA="1" -export ATTN_PRECISION=fp16 -export PYTORCH_CUDA_ALLOC_CONF=garbage_collection_threshold:0.9,max_split_size_mb:512 -python launch.py --api --disable-opt-split-attention --disable-console-progressbars "$@" -# --opt-channelslast