stable diffusion本地部署@win10

发布于:2024-04-26 ⋅ 阅读:(23) ⋅ 点赞:(0)

一键无脑安装stable-diffusion-webui

stable diffusion是当前非常出色的文生图模型,要优于以前gan文生图模型。现在有了stable-diffusion-webui软件,可以一键安装,大大简化了操作难度。本文档就是stable-diffusion-webui在windows 10上的安装实践。

首先安装conda和git

git安装参考:windows下如何安装git-CSDN博客

比如可以去阿里镜像:CNPM Binaries Mirror (npmmirror.com) 或Git for Windows 下载安装。

conda可以去官网下载anaconda或者miniconda安装,国内一般习惯去清华大学镜像下载:Index of /anaconda/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

选择自己习惯的版本即可,比如py310版本:https://mirrors4.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py310_24.3.0-0-Windows-x86_64.exe。安装完成后,可以用conda env list 列出当前的虚拟环境,可以使用conda activate e:\miniconda3 来激活虚拟环境。当然这些可有都不去操作,就用默认就行。有问题再手工调试。

安装stable-diffusion-webui

https://github.com/AUTOMATIC1111/stable-diffusion-webui 官网下载代码,使用git 命令:

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

进入目录一键执行:

cd stable-diffusion-webui
webui.bat

一键安装会自动安装pytorch等相关库。当然中间有可能会碰到有些报错,根据报错解决问题即可。比如gpu计算卡没有的话,就要加上--skip-torch-cuda-test参数。

模型下载

如果报没有模型的错误,可以手工下载模型:

比如可以从hf-mirrot.com这个镜像下载:https://hf-mirror.com/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt 

下载这个文件:v1-5-pruned-emaonly.ckpt ,改名成model.ckpt并放入指定目录:stable-diffusion-webui/models/Stable-diffusion/model.ckpt

最终采用执行webui-user.bat文件

1 先修改webui-user.bat 文件如下:

@echo off

set PYTHON=e:\py310\python.exe
set GIT=
set VENV_DIR=E:\py310_1
set COMMANDLINE_ARGS=

call webui.bat --skip-torch-cuda-test  --precision full --no-half

2 执行  webui-user.bat 启动服务!

启动后会自动打开链接:http://127.0.0.1:7860/

然后我们就可以开始画画拉!

比如画一幅happy new year!

再来个我爱北京天安门

调试

报错not implemented for 'Half

RuntimeError: "addmm_impl_cpu_" not implemented for 'Half' *** Error completing request *** Arguments: ('task(y9m3370qpz0xxl5)', <gradio.routes.Request object at 0x000002DB45B10910>, 'hello', '', [], 1, 1, 7, 512, 512, False, 0.7, 2, 'Latent', 0, 0, 0, 'U

 在webui-user.bat文件中加入这个参数:--precision full --no-half