当前位置: 首页 > news >正文

解决2080Ti使用节点ComfyUI-PuLID-Flux-Enhanced中遇到的问题

使用蓝大的工作流《一键同时换头、换脸、发型、发色之双pulid技巧》 

刚开始遇到的是不支持bf16的错误

根据《bf16 is only supported on A100+ GPUs #33》中提到,修改pulidflux.py中的dtype 为

dtype = torch.float16 后,出现新的错误,这个新错误可能是由于加载模型的节点改变而造成的(见后面模型加载节点对模型dtype的转换可知):

KSampler

expected scalar type Float but found Half

 问chatgpt结果如下:

 然后发现flux类的模型dtype如下:

flux1-dev-fp8-e4m3fn.safetensors 
dtype is ---->torch.float8_e4m3fn

flux1-fill-dev_fp8.safetensors
dtype is ---->torch.float8_e4m3fn
 

flux1-fill-dev.safetensors
dtype is ---->torch.bfloat16

flux1-dev.safetensors
dtype is ---->torch.float16

flux1-fill-dev-Q4_1.gguf
dtype is ---->torch.bfloat16

因为在加载模型时,进行了dtype转换:

Loading PuLID-Flux model.
model weight dtype torch.float8_e4m3fn, manual cast: torch.float32
model_type FLUX 

Loading PuLID-Flux model.
model weight dtype torch.float16, manual cast: None
model_type FLUX

gguf qtypes: F32 (471), Q4_1 (304), F16 (5)
model weight dtype torch.bfloat16, manual cast: torch.float32
model_type FLUX 

上面加载模型的节点输出信息,在comfyui核心代码 D:\AI\ComfyUI\comfy\model_base.py 中的语句如下:

   logging.info("model weight dtype {}, manual cast: {}".format(self.get_dtype(), self.manual_cast_dtype))

所以数据类型torch.float8_e4m3fn, torch.float8_e5m2, torch.bfloat16只能适配fp32,于是修改pulidflux.py中相关代码如下,问题解决,运行正常,结果正常:

    def apply_pulid_flux(self, model,.....):.......# For 8bit use bfloat16 (because ufunc_add_CUDA is not implemented)# For 2080Ti use float16 or float32 (because 2080ti not support bf16)if dtype in [torch.float8_e4m3fn, torch.float8_e5m2, torch.bfloat16]:#dtype = torch.bfloat16dtype = torch.float32

当然,由bf16变为fp32后,显存占用肯定就大了。 

注意,当第2次运行时,依然会出现错误:KSampler expected scalar type Float but found Half,需要卸载模型及释放节点缓存,重新运行,蓝大的工作流,使用了2次Apply PuLID Flux节点而且加载的模型不一样,如果只使用1个Apply PuLID Flux节点,估计没有这个问题。


http://www.mrgr.cn/news/98101.html

相关文章:

  • 2019年计算机真题
  • 小刚说C语言刷题——第22讲 二维数组
  • 【学习笔记】两个类之间的数据交互方式
  • 可配置多功能门芯片的12种用法推导——基于74LVC1G97芯片(附1G98、1G57、1G58、1G99用法)
  • 470用 Rand7() 实现 Rand10()
  • leetcode572 另一棵树的子树
  • 每天学一个 Linux 命令(14):cat
  • Linux进程概念
  • 【MQTT-协议原理】
  • 2025蓝桥杯算法竞赛深度突破:创新题型与高阶策略全解析
  • IIC通信协议
  • 基于 Maven 构建的 Thingsboard 3.8.1 项目结构
  • 部署NFS版StorageClass(存储类)
  • 文献总结:AAAI2025-UniV2X-End-to-end autonomous driving through V2X cooperation
  • SAP系统客户可回收包材库存管理
  • 强化学习系统在复杂推理模型中的应用——以AReaL系统为例
  • RPA VS AI Agent
  • 解决VS2022中scanf报错C4996
  • 第十六届蓝桥杯 省赛C/C++ 大学B组
  • 前端工程化-包管理NPM-package.json 和 package-lock.json 详解