1 机器准备
GPU至少选Tesla T4、操作系统Ubuntu 20.04,硬盘30GB
2 安装cuda驱动
参考GCP的官方文档:https://cloud.google.com/compute/docs/gpus/install-drivers-gpu
可以使用自动安装脚本(注意提前安装python 3)
curl https://raw.githubusercontent.com/GoogleCloudPlatform/compute-gpu-installation/main/linux/install_gpu_driver.py --output install_gpu_driver.py sudo python3 install_gpu_driver.py
3 安装git lfs
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash sudo apt-get install git-lfs
4 安装webui和chilloutmix模型
我这里用的是一个给colab用的fork版
#!/bin/bash mkdir /content cd /content env TF_CPP_MIN_LOG_LEVEL=1 apt -y update -qq wget http://launchpadlibrarian.net/367274644/libgoogle-perftools-dev_2.5-2.2ubuntu3_amd64.deb wget https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/google-perftools_2.5-2.2ubuntu3_all.deb wget https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libtcmalloc-minimal4_2.5-2.2ubuntu3_amd64.deb wget https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libgoogle-perftools4_2.5-2.2ubuntu3_amd64.deb apt install -y -qq libunwind8-dev python-is-python3 pip dpkg -i *.deb env LD_PRELOAD=libtcmalloc.so rm *.deb apt -y install -qq aria2 libcairo2-dev pkg-config python3-dev pip install -q torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 torchtext==0.14.1 torchdata==0.5.1 --extra-index-url https://download.pytorch.org/whl/cu116 -U pip install -q xformers==0.0.16 triton==2.0.0 -U git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui git clone https://huggingface.co/embed/negative /content/stable-diffusion-webui/embeddings/negative git clone https://huggingface.co/embed/lora /content/stable-diffusion-webui/models/Lora/positive aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/embed/upscale/resolve/main/4x-UltraSharp.pth -d /content/stable-diffusion-webui/models/ESRGAN -o 4x-UltraSharp.pth wget https://raw.githubusercontent.com/camenduru/stable-diffusion-webui-scripts/main/run_n_times.py -O /content/stable-diffusion-webui/scripts/run_n_times.py git clone -b v2.1 https://github.com/camenduru/deforum-for-automatic1111-webui /content/stable-diffusion-webui/extensions/deforum-for-automatic1111-webui git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui-images-browser /content/stable-diffusion-webui/extensions/stable-diffusion-webui-images-browser git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui-huggingface /content/stable-diffusion-webui/extensions/stable-diffusion-webui-huggingface git clone -b v2.1 https://github.com/camenduru/sd-civitai-browser /content/stable-diffusion-webui/extensions/sd-civitai-browser git clone -b v2.1 https://github.com/camenduru/sd-webui-additional-networks /content/stable-diffusion-webui/extensions/sd-webui-additional-networks git clone -b v2.1 https://github.com/camenduru/sd-webui-tunnels /content/stable-diffusion-webui/extensions/sd-webui-tunnels git clone -b v2.1 https://github.com/camenduru/batchlinks-webui /content/stable-diffusion-webui/extensions/batchlinks-webui git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui-catppuccin /content/stable-diffusion-webui/extensions/stable-diffusion-webui-catppuccin git clone -b v2.1 https://github.com/camenduru/a1111-sd-webui-locon /content/stable-diffusion-webui/extensions/a1111-sd-webui-locon git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui-rembg /content/stable-diffusion-webui/extensions/stable-diffusion-webui-rembg git clone -b v2.1 https://github.com/camenduru/stable-diffusion-webui-two-shot /content/stable-diffusion-webui/extensions/stable-diffusion-webui-two-shot git clone -b v2.1 https://github.com/camenduru/sd_webui_stealth_pnginfo /content/stable-diffusion-webui/extensions/sd_webui_stealth_pnginfo git clone -b v2.1 https://github.com/camenduru/sd-webui-aspect-ratio-helper /content/stable-diffusion-webui/extensions/sd-webui-aspect-ratio-helper cd /content/stable-diffusion-webui git reset --hard git -C /content/stable-diffusion-webui/repositories/stable-diffusion-stability-ai reset --hard aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/ckpt/chilloutmix/resolve/main/chilloutmix_NiPrunedFp32Fix.safetensors -d /content/stable-diffusion-webui/models/Stable-diffusion -o chilloutmix_NiPrunedFp32Fix.safetensors sed -i -e '''/ prepare_environment()/a\ os.system\(f\"""sed -i -e ''\"s/dict()))/dict())).cuda()/g\"'' /content/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/util.py""")''' /content/stable-diffusion-webui/launch.py sed -i -e 's/\"sd_model_checkpoint\"\,/\"sd_model_checkpoint\,sd_vae\,CLIP_stop_at_last_layers\"\,/g' /content/stable-diffusion-webui/modules/shared.py python launch.py --listen --xformers --enable-insecure-extension-access --theme dark --gradio-queue --multiple
4 一些小修改
WebUI的bug,做一些小修改,参考这个
还有这个也要改下
https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg/issues/10
文件是./extensions/stable-diffusion-webui-rembg/scripts/postprocessing_rembg.py
5 只启动UI和API
python launch.py --listen