ubuntu2204 部署 stable-diffusion-webui

vicowong發表於2024-04-08

顯示卡:(一個例項僅能用一張卡)

頂配:rtx 6000 ada 48g,a100 40g,a100 80g ,a100 96g,a800 80g,h100,h200

高階:rtx4090 24g,rtx4090D 24g,rtx a6000 48g,rtx a5000 24g,rtx 5000 ada 32g

魔改:rtx2080ti 22g,rtx3080 20g

價效比:rtx4060ti 16g,rtx2060 12g,rtx3060 12g,rtx3090 24g,rtx titan 24g

其它硬體及系統環境

記憶體32g以上,固態300g以上,rtx之後8G以上顯示卡

ubuntu2204+命令列+N卡+conda

檢查cuda
#ll /sys/bus/pci/devices/
#sudo apt install nvidia-driver-530

nvcc -V
dpkg -l |grep cudnn
watch -n 0.5 nvidia-smi

https://stablediffusionweb.com
https://github.com/Stability-AI/stablediffusion
https://github.com/AUTOMATIC1111/stable-diffusion-webui


sudo apt install bc libgoogle-perftools-dev
ldconfig -p | grep tcmalloc

sudo vim /etc/profile
export LD_PRELOAD=/lib/x86_64-linux-gnu/libtcmalloc.so
source /etc/profile

sudo apt install libgl1 libgl1-mesa-glx libgl1-mesa-dev
ldconfig -p | grep libGL.so.1


安裝 Stable Diffusion web UI
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui

搭建python虛擬環境
conda update conda
conda config --add channels conda-forge
conda config --add channels defaults
conda info
python -m pip install --upgrade pip
conda create -n sd python=3.10.6
conda activate sd

pip install -r requirements_versions.txt
pip install -r requirements.txt

cd models/Stable-diffusion/
wget https://hf-mirror.com/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors

mkdir openai && cd openai
#https://huggingface.co/openai/clip-vit-large-patch14
git clone https://hf-mirror.com/openai/clip-vit-large-patch14.git

vim webui.sh
can_run_as_root=1

vim module/paths_internal.py
commandline_args = os.environ.get('COMMANDLINE_ARGS', "--xformers --share --gradio-auth tuser:pwd")
低4G --medvram --opt-split-attention
低8G --lowvram --opt-split-attention
--listen
webui.sh

git clone https://github.com/VinsonLaro/stable-diffusion-webui-chinese
ll stable-diffusion-webui-chinese/localizations/
cp ll stable-diffusion-webui-chinese/localizations/* localizations

Settings->User interface->Localization(requires restart) 選擇Chinese-ALL 或者 Chinese-English
Apply setting Reload UI


------------------------------------------------------------
臨時使用清華映象
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn

更改預設庫包下載地址為清華映象
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

# 環境出錯時
python3 -m venv venv

# git提示https沒法訪問
git config --global https.sslVerify false
------------------------------------------------------------

更新 sd-webui-controlnet,將 controlnet 外掛升級至最新版本,即

cd extensions/sd-webui-controlnet
git remote -v
# https://ghproxy.com/ 代理已經失效,需要重新設定
git remote set-url origin https://github.com/Mikubill/sd-webui-controlnet.git
git pull origin main


更新 a1111-sd-webui-tagcomplete 外掛:
cd workspace/stable_diffusion_webui/extensions/a1111-sd-webui-tagcomplete
git remote -v
# https://ghproxy.com/ 代理已經失效,需要重新設定
# git remote set-url origin https://github.com/DominikDoom/a1111-sd-webui-tagcomplete.git
git remote set-url origin git@github.com:DominikDoom/a1111-sd-webui-tagcomplete.git
git pull origin main


提示資訊,不需考慮,參考 GitHub - Issues:
"Tag Autocomplete: Could not locate model-keyword extension, Lora trigger word completion will be limited to those added through the extra networks menu."
標籤自動完成:無法定位模型關鍵字擴充套件,Lora 觸發詞補全,將僅限於透過額外網路選單新增的內容。


更新 sd-webui-roop 外掛:
cd workspace/stable_diffusion_webui/extensions/sd-webui-roop
git remote -v
# https://ghproxy.com/ 代理已經失效,需要重新設定
git remote set-url origin git@github.com:s0md3v/sd-webui-roop.git
git pull origin main


Warning 資訊,修復參考 Deprecation Warning,替換檔案 faceswap.py:
workspace/stable_diffusion_webui/extensions/sd-webui-roop/scripts/faceswap.py:38: GradioDeprecationWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components
img = gr.inputs.Image(type="pil")
workspace/stable_diffusion_webui/modules/gradio_extensons.py:25: GradioDeprecationWarning: `optional` parameter is deprecated, and it has no effect
res = original_IOComponent_init(self, *args, **kwargs)
workspace/stable_diffusion_webui/extensions/sd-webui-roop/scripts/faceswap.py:55: GradioDeprecationWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components
upscaler_name = gr.inputs.Dropdown(
workspace/stable_diffusion_webui/extensions/sd-webui-roop/scripts/faceswap.py:74: GradioDeprecationWarning: Usage of gradio.inputs is deprecated, and will not be supported in the future, please import your component from gradio.components
model = gr.inputs.Dropdown(


更新 sdweb-easy-prompt-selector 外掛:
cd workspace/stable_diffusion_webui/extensions
git clone git@github.com:blue-pen5805/sdweb-easy-prompt-selector.git

Warning 資訊,參考 emove style() method:

workspace/stable_diffusion_webui/extensions/sdweb-easy-prompt-selector/scripts/easy_prompt_selector.py:97: GradioDeprecationWarning: The `style` method is deprecated. Please set these arguments in the constructor instead.
reload_button.style(size='sm')
重新啟動 sd-webui 工程:

top
nohup python -u launch.py --listen --port 9301 --xformers --no-half-vae --enable-insecure-extension-access --theme dark --gradio-queue > nohup.62.out &
tail -f nohup.62.out

=========================================
nohup python -u launch.py --listen --port 9301 --xformers --no-half-vae --enable-insecure-extension-access --theme dark --gradio-queue > nohup.62.out &
tail -f nohup.62.out

相關文章