ccruiの博客

ccruiの博客

Linux 部署 Stable Diffusion WebUI

164
2024-05-19

Linux 部署 Stable Diffusion WebUI

安装 CUDA

https://developer.nvidia.com/cuda-downloads

配置环境变量

export PATH=/usr/local/cuda-12.3/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

测试环境变量

root@zgccrui:/usr/local# nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Wed_Nov_22_10:17:15_PST_2023
Cuda compilation tools, release 12.3, V12.3.107
Build cuda_12.3.r12.3/compiler.33567101_0

安装 Anaconda

https://www.anaconda.com/products/distribution#download-section

wget https://repo.anaconda.com/archive/Anaconda3-2023.09-0-Linux-x86_64.sh
bash Anaconda3-2023.09-0-Linux-x86_64.sh

重新激活 shell

source ~/.bashrc

验证 Anaconda 安装

conda --version

创建虚拟环境

conda create -n sd-webui python=3.10.6
conda activate sd-webui

pip 换源(可选)

pip config set global.index-url <http://mirrors.aliyun.com/pypi/simple/>

或者

pip config set global.trusted-host mirrors.aliyun.com

安装 Stable Diffusion WebUI

从 github 上下载源码

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

下载模型文件(可选,正常Webui.sh会自动下载)

https://huggingface.co/stabilityai/stable-diffusion-2-1

将下载好的模型文件放到 stable-diffusion-webui/models/Stable-diffusion/ 目录下

加入 Github 代理(可选)

修改stable-diffusion-webui/modules/launch_utils.py文件中全部 Github 链接,在前面加上https://ghproxy.com/,或加入自建代理。

启动 WebUI

bash webui.sh