stablediffsion ubuntu 配置流程

stablediffsion ubuntu 配置流程

1.环境初始化

安装ubuntu server 版本,防止出现很多玄学问题。

安装nvidia 驱动,https://www.nvidia.cn/geforce/drivers,根据自己的显卡选择驱动,下载,sudo chmod +x 驱动名& bash 驱动名,安装完毕以后,nvidia-smi,出现下图极为成功。

安装cuda,https://developer.nvidia.com/cuda-toolkit-archive,选择符合自己系统版本的下载,安装依赖库

sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
sudo sh cuda*linux.run

安装完成以后,配置文件 sudo vim ~/.bashrc,在最后加入

export PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/cuda-12.1/bin"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-12.1/lib64
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-12.1

保存并source 使其生效

安装cudnn https://developer.nvidia.com/rdp/cudnn-download,选择符合自己系统的版本

tar -zxvf cudnn-*.tgz
cp cuda/lib64/* /usr/local/cuda*/lib64/
cp cuda/include/* /usr/local/cuda*/include/

2.安装stablediffusion

拉取代码

 git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
# install torch with CUDA support. See https://pytorch.org/get-started/locally/ for more instructions if this fails.
install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

# check if torch supports GPU; this must output "True". You need CUDA 11. installed for this. You might be able to use
# a different version, but this is what I tested.
python -c "import torch; print(torch.cuda.is_available())"

# clone web ui and go into its directory
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui

# clone repositories for Stable Diffusion and (optionally) CodeFormer
mkdir repositories
git clone https://github.com/CompVis/stable-diffusion.git repositories/stable-diffusion-stability-ai
git clone https://github.com/CompVis/taming-transformers.git repositories/taming-transformers
git clone https://github.com/sczhou/CodeFormer.git repositories/CodeFormer
git clone https://github.com/salesforce/BLIP.git repositories/BLIP
https://github.com/Stability-AI/generative-models.git repositories/generative-models
# install requirements of Stable Diffusion
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env

pip install transformers diffusers invisible-watermark --prefer-binary

# install k-diffusion
pip install git+https://github.com/crowsonkb/k-diffusion.git --prefer-binary

# (optional) install GFPGAN (face restoration)
pip install git+https://github.com/TencentARC/GFPGAN.git --prefer-binary

# (optional) install requirements for CodeFormer (face restoration)
pip install -r repositories/CodeFormer/requirements.txt --prefer-binary


# install requirements of web ui
pip install -r requirements.txt  --prefer-binary

# update numpy to latest version
pip install -U numpy  --prefer-binary

# (outside of command line) put stable diffusion model into web ui directory
# the command below must output something like: 1 File(s) 4,265,380,512 bytes
dir model.ckpt
python launch.py --force-enable-xformers --disable-nan-check --skip-python-version-check --opt-sdp-attention --xformers --api --no-half-vae --listen --port 10001
0

评论0

显示验证码
没有账号?注册  忘记密码?