stable diffusion 1.5版本windows本地部署遇到的问题


本人在本地部署时,主要参考了知乎上的这篇文章: Stable Diffusion安装教程(有问题可留言),将自己部署中遇到的问题记录下来,以供参考。

部署前准备

我这里没有使用windows的cmd,用的是Anaconda,因为1.5版本需要Python 3.10.6,而我又不想卸载之前的版本,创建一个conda虚拟环境即可解决。另外,我选择将其安装在D盘。

(base) PS C:\Users\David> conda create -n sd python==3.10.6
(base) PS C:\Users\David> conda activate sd
(sd) PS C:\Users\David> D:
(sd) PS D:\>

部署

克隆github上的sd仓库

(sd) PS D:\> git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

下载模型

直接点下方链接即可进入hugging face下载模型
v1-5-pruned-emaonly.ckpt
下载完的模型放入stable-diffusion-webui文件夹中的指定位置
在这里插入图片描述

安装依赖包

放入模型后,返回至stable-diffusion-webui目录下,运行以下文件即可
在这里插入图片描述

(sd) PS D:\> cd .\stable-diffusion-webui
(sd) PS D:\stable-diffusion-webui> webui.bat

被迫手动安装

可能在自动安装过程中,会出现stablediffusion仓库下载不下来的情况,这个时候,可以手动下载

(sd) PS D:\stable-diffusion-webui> cd .\repositories
(sd) PS D:\stable-diffusion-webui\repositories> mkdir stable-diffusion-stability-ai
(sd) PS D:\stable-diffusion-webui\repositories> git clone https://github.com/Stability-AI/stablediffusion.git

若继续运行webui.bat时,出现以下错误

Traceback (most recent call last):
  File "D:\stable-diffusion-webui\launch.py", line 38, in <module>
    main()
  File "D:\stable-diffusion-webui\launch.py", line 29, in main
    prepare_environment()
  File "D:\stable-diffusion-webui\modules\launch_utils.py", line 299, in prepare_environment
    git_clone(stable_diffusion_repo, repo_dir('stable-diffusion-stability-ai'), "Stable Diffusion", stable_diffusion_commit_hash)
  File "D:\stable-diffusion-webui\modules\launch_utils.py", line 150, in git_clone
    run(f'"{git}" -C "{dir}" checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}")
  File "D:\stable-diffusion-webui\modules\launch_utils.py", line 107, in run
    raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't checkout commit cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf for Stable Diffusion.
Command: "git" -C "D:\stable-diffusion-webui\repositories\stable-diffusion-stability-ai" checkout cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf
Error code: 128
stderr: fatal: reference is not a tree: cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf

把克隆后的stablediffusion文件夹中的所有内容直接放到stable-diffusion-stability-ai文件夹下
在这里插入图片描述
在这里插入图片描述

启动

不出意外的话,等到以下界面
在这里插入图片描述

就可以在浏览器输入http://127.0.0.1:7860,开始AI绘图了
在这里插入图片描述
如果进入web界面,prompt以后没反应,可以尝试重启,再运行webui.bat文件就行了。

第一次写文章,若有纰漏,请谅解

猜你喜欢

转载自blog.csdn.net/a1112315165/article/details/131920595