
Stable Diffusion安装CPU版本
1、安装python3.10.6
mac系统可以使用pyenv安装多个版本的python
1、brew install pyenv 2、将下面这段添加进 ~/.bashrc 或 ~/.bash_profile 或 ~/.zprofile 或 ~/.zshrc export PYENV_ROOT="$HOME/.pyenv" command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" 3、安装pyhton3.10.6 pyenv install 3.10.6 4、当前终端临时切换python版本 pyenv shell 3.10.6
2、从git clone(一定要是clone,如果是下载zip包,后面执行webui.sh时又会clone一遍)下来 https://github.com/AUTOMATIC1111/stable-diffusion-webui
3、进入 stable-diffusion-webui,用python3.10.6创建python虚拟环境,虚拟环境的文件夹名一定要是 venv,不然后面执行webui.sh时又会创建一个名为 venv的虚拟环境
4、安装依赖
pip install torch torchvision torchaudio cython
pip install -r requirements.txt
pip install -r requirements_versions.txt
5、下载一个模型放到 models/Stable-diffusion/ 目录下
模型地址:
https://civitai.com/
https://huggingface.co/
6、修改些参数
mac或linunx,修改webui-user.sh
#export COMMANDLINE_ARGS 改成 export COMMANDLINE_ARGS="--skip-torch-cuda-test --lowvram --autolaunch --always-batch-cond-uncond --precision full --no-half --opt-split-attention-v1 --use-cpu sd"
windows修改 webui-user.bat
set COMMANDLINE_ARGS= 改成 set COMMANDLINE_ARGS=--skip-torch-cuda-test --lowvram --autolaunch --always-batch-cond-uncond --precision full --no-half --opt-split-attention-v1 --use-cpu sd
7、启动,linux/mac执行 ./webui.sh,windows执行 ./webui-user.bat
可能出现的问题:
缺少httpx、socksio,pip安装即可
缺少 cython,pip安装即可
缺少_lzma模块,安装backports.lzma然后将 lzma.py文件 import _lzma 改成 import backports.lzma
安装gfpgan、clip、open_clip失败,手动安装,比如gfpgan,在launch.py找到gfpgan_package变量,使用pip install安装,如
pip install git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379
如果访问github失败,那就开自己想办法开代理吧,或者自行在github下载对应提交的代码包到本地,使用 pip install xxx.zip 安装
linux/mac在shell开代理:
export https_proxy=http://127.0.0.1:123 http_proxy=http://127.0.0.1:123 all_proxy=socks5://127.0.0.1:123
windows在cmd开代理:
set http_proxy=http://127.0.0.1:123 & set https_proxy=http://127.0.0.1:123
windows在power shell开代理:
$Env:http_proxy="http://127.0.0.1:123";$Env:https_proxy="http://127.0.0.1:123"