stable-diffusion-webui 安装指北(其一)
想安装stable-diffusion-webui的小伙伴,快来看看我都遇到哪些坑,按照顺序应该可以完成第一步,话不多说,上干货!
安装python 3.10.6-3.10.9(3.11会报错)
安装anaconda
安装git
配置环境变量
cmd 输入 where python 根据显示的python位置配置变量
D:\Program Files\anaconda3
D:\Program Files\anaconda3\Library\bin
D:\Program Files\anaconda3\Library\mingw-w64
D:\Program Files\anaconda3\Scripts
D:\Program Files\Python310

更改anaconda清华源
修改.condarc
C:\Users\xxxx\.condarc
内容
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
在Anaconda Prompt (anaconda3)里运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引。
下载CUDA(要与驱动版本对应,以pytorch最高支持版本为准)
版本对应网址:https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html

pytorch 下载地址:https://pytorch.org/get-started/locally/ (里面的命令安装的是CPU版本非GPU版本,要先执行命令安装CPU版本再安装GPU版本)

pytorch GPU 下载地址:https://download.pytorch.org/whl/ (选择里面的torch和torchvision文件夹里对应的版本eg.torch-1.13.1+cu117-cp310-cp310-win_amd64.whl)

执行命令:git clone https://github.com/TencentARC/GFPGAN.git
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
git clone https://github.com/openai/CLIP.git
git clone https://github.com/mlfoundations/open_clip.git
从github将GFPGAN/CLIP/open_clip的源文件下载到本地,这一步可以使用git clone也可以直接下载zip文件。下载后,解压(如果用git clone就不需要)到d:\\stable-diffusion-webui\venv\Scripts目录下(stable-diffusion-webui是你stable diffusion webui的根目录,这个地址只是我电脑中的,请根据自己放的位置调整)。
打开cmd,cd到d:\\stable-diffusion-webui\venv\Scripts\GFPGAN-master下。
使用命令d:\\stable-diffusion-webui\venv\Scripts\python.exe -m pip install basicsr facexlib安装GFPGAN的依赖。
再使用d:\\stable-diffusion-webui\venv\Scripts\python.exe -m pip install -r requirements.txt安装GFPGAN的依赖。
使用d:\\stable-diffusion-webui\venv\Scripts\python.exe setup.py develop安装GFPGAN。
打开cmd,cd到d:\\stable-diffusion-webui\venv\Scripts\CLIP(or open_clip)下。
卸载clip:d:\\stable-diffusion-webui\venv\Scripts\python.exe -m pip uninstall clip
使用d:\\stable-diffusion-webui\venv\Scripts\python.exe setup.py build install安装open_clip。
安装完毕后,再打开stable diffusion根目录的webui-user.bat会发现不再要求安装GFPGAN。如果遇到其他github上的模块无法安装也可以用同样的方法。

conda常用命令
创建环境 conda create -n environment_name (environment_name环境名)
创建指定python版本下包含某些包的环境 conda create -n environment_name python=3.7
进入环境 conda activate environment_name
退出环境 conda deactivate
删除环境 conda remove -n yourname --all
列出环境 conda env list / conda info -e