本地开启stable diffusion web-ui体验AIGC文生图,图生图

目录

准备工作

主机电脑配置检查

安装以下软件

Python

Git

下载stable-diffusion-webui仓库

根据显卡属性安装CUDA

2.下载stable diffusion的训练模型

启动

问题处理

模型加载问题

这是启动后界面

以下是运行时的系统状态截图


准备工作

主机电脑配置检查

需要16G内存,8G显存(网上说是6G就够,不过跑出来图片像素会低,显存越大画质也越好)

CPU要求不高,我的配置是 i5-8400

显卡,咱用的是 2060s ,一千多点买的二手显卡

内存是32G (16G就可以)

电源600W (400W也能跑,不过怕功率不够)[电源功率= (显卡功率+CPU+100) * 1.5]

主板是 微星B360M

系统是win10

安装以下软件

Python

从官网下载Python,选择Windows Installer (64-bit)版本并安装(python 3.10 (必须是这个版本))

以下命令查看python是否安装成功

python --version

Git

.下载Git for Windows并安装

下载stable-diffusion-webui仓库

打开git bash  选择合适的文件夹路径拉取项目代码

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

根据显卡属性安装CUDA

3167e19e214842a8841420bd53ebcdd5.pngb232a677886d462a8278fcf09508b341.png

进入 PyTorch

根据自己cuda版本 找到pytorch下载版本的pip命令,比如我的是 11.7

45c78f515ef944ff9e151a63ee73b30f.png

以前版本的torch下载命令地址

Previous PyTorch Versions | PyTorch

2.下载stable diffusion的训练模型

4. 从Hugging Face下载v2-1_768-ema-pruned.ckpt。 文件很大,因此需要一段时间才能下载完成

地址:https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/tree/main

下载好之后,请把模型放置在sd-webui的models/stable-diffusion目录下

25538978acd64ce2974d2da7c690d1e1.png

启动

点击stable-diffusion-webui文件夹下的webui.bat启动程序

问题处理

启动问题

9ac86ee8658649dd8fadb545720a25c7.png

以上问题的原因是pytorch没安装好,或是版本不对应,获取不到GPU

安装适合CUDA版本的torch

Previous PyTorch Versions | PyTorch

安装正确的torch后,可以用以下代码测试是否torch能用上GPU

import torch

print(torch.__version__)

print(torch.cuda.is_available())

模型加载问题

异常内容:

Stable diffusion model failed to load

Loading weights [ad2a33c361] from D:\learnAndTrain\AI\project\stable-diffusion-webui\models\Stable-diffusion\v2-1_768-ema-pruned.ckpt

NansException: A tensor with all NaNs was produced in Unet. This could be either because there's not enough precision to represent the picture, or because your video card does not support half type. Try setting the "Upcast cross attention layer to float32" option in Settings > Stable Diffusion or using the --no-half commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check.

Time taken: 0.35s

Torch active/reserved: 3241/3642 MiB, Sys VRAM: 5970/8192 MiB (72.88%)

现以上问题需要加启动参数

用记事本打开webui.bat,找到这一行

%PYTHON% launch.py %*

加三个参数,按我的改

%PYTHON% launch.py %* --disable-nan-check --precision full --no-half

第1个参数不改,stable diffusion跑不起来,第二个参数和第三个参数不加,图像生成后就是黑屏。

改完,再运行webui.bat,出现这个就对了:(划重点:127.0.0.1:7860,在浏览器里跑)

这是启动后界面

f373aa4fc6b048619455fe15a6115244.png

以下是运行时的系统状态截图

a90719be0be84f7e8b58e71b9728f618.png

附几张生成的图片(咒语还不太会,图片略丑):

bf59be3f886645d0af05f2c750f237c9.pnge792e6e5aa2a475fb7c5bf74aa0dd929.png836d351e75e14cd59b0dfd8a5eac9fdb.png10c3f542c75846e4a685f9ded82dedc5.png08b90876cbed48aa8d85c2a3119646c1.png1c13b536f255477dafa116b0cbbc5c18.png9a2ab12cbbeb4e9b93e1bee27de2e11f.png

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

HELLO XF

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值