知识改变命运! stable duffusion NansException: A tensor with all NaNs was produced in Unet. This could be either because there's not enough pre_天空才是极限-lskyf博客社区

stable duffusion NansException: A tensor with all NaNs was produced in Unet. This could be either because there's not enough pre

天空才是极限 4月前 ⋅ 3072 阅读 ⋅ 0 个赞

这个错误是什么问题?

运行stable duffusion出现这个错误

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

如何解决?

找到stable-diffusion-webui目录下的webui-user.bat文件,使用编辑器打开可以看见配置代码如下:

@echo off

set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=

call webui.bat

添加--no-half --disable-nan-check参数修改如下:

@echo off

set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--no-half --disable-nan-check

call webui.bat


修改完成后重启stable-diffusion-webui即可

错误产生原因

这个错误提示是在Unet代码中产生了全部由NaN组成的张量。这可能有几个原因:

  1. 表示图像所需的精度不够:这意味着正在处理的图片可能包含非常小的值,这些值被舍入为零,从而导致NaN。要解决此问题,可以尝试增加计算中使用的精度。

  2. 视频卡不支持半精度类型:半精度是一种表示浮点数的格式,使用的位数比单精度少一半,可以节省内存和计算时间。如果你的视频卡不支持这种格式,可能会导致产生NaN。要解决此问题,可以尝试设置“将交叉关注层升级为float32”选项在设置>稳定扩散中,或者使用--no-half命令行参数来解决这个问题。使用--disable-nan-check命令行参数可以禁用此检查。

2023年7月5更新

又遇到这个问题了,使用以上的方法没有解决。猜测是模型不支持相应的提示词,附加两种方式解决:

1.修改提示词

2.更换模型


全部评论: 0

    我有话说:

    vue3报错:Uncaught TypeError: this.$refs.demo.$on is not a function

    错误 Uncaught TypeError: this.$refs.demo.$on is not a function 原因 Vue 3 中,$on 方法已经被移除,可能需要使用

    Caused by: java. io.I0Exception:The

    Caused by: java. io.I0Exception:The"/xxxx/xxx" 检查建议: 1. 确保服务器目录和部署的服务是同一台机器 2. 确保此目录针对tomcat有访问

    mysql GROUP BY去重报错,可以外面在套一层查询

    SELECT * FROM ( SELECT s.id, c.NAME FROM tbl_stu s, tbl_city c WHERE s.id = c.stu ) aa GROUP BY s

    微信小程序报错request:fail url not in domain list

    微信小程序报错request:fail url not in domain list 登录小程序后台 https://mp.weixin.qq.com/ 选择开发--开发设置--服务器域名--服务器

    k8s阿里云yum源

    阿里云yum源 cat > /etc/yum.repos.d/kubernetes.repo << EOF [kubernetes] name=Kubernetes baseurl=http://mirrors.aliyun....

    电脑端WPS广告360广告老是弹出怎么办?终极治愈招数有哪些?

    1.痛点 每次打开电脑最烦的就是一眼就看到WPS广告或者360广告,咨询等等的广告呈现在你面前,影响了你一天的好心情!怎么办有什么好治愈心情的方法吗?我不要看广告。 2.终极治愈方案 将WPS广告或

    jenkins 执行maven命令 报错 Caused by: java.io.FileNotFoundException: /var/jenkins_home/jdk/lib/tzdb.dat

    执行jenkins使用maven命令打包的时候报错: Caused by: java.io.FileNotFoundException: /var/jenkins_home/jdk/lib/tzdb

    加入公众号
    加入公众号