Mac M1 ComfyUI 中 AnyText插件安装问题汇总?

Q1:NameError: name 'PreTrainedTokenizer' is not defined ?

该项目最近更新日期为2024年12月,该时间段的transformers 版本由PyPI 上的 transformers 页面可知为4.47.1.

A1: transformers 版本不满足要求,必须降级transformors ?

(1)查看 transformers 版本
bash 复制代码
pip index versions transformers 

发现是最新版4.48.2,降级到4.46.2

bash 复制代码
pip install transformers==4.46.2

Q2:"ComfyUI/custom_nodes/ComfyUI_Anytext/Image_Generation_AnyText/Site_Packages/AnyTextControlDiffusion/ldm/modules/encoders/modules.py" AssertionError: Torch not compiled with CUDA enabled". ?

A2: 将modules.py文件里下面这行代码:

bash 复制代码
tokens = tokens.to(self.device)

修改为如下内容:

bash 复制代码
self.device = torch.device("mps" if torch.backends.mps.is_available() else "cpu")
tokens = tokens.to(self.device)

Q3:'ComfyUI_Anytext/Image_Generation_AnyText/Site_Packages/AnyTextControlDiffusion/cldm/ddim_hacked.py' AssertionError: Torch not compiled with CUDA enabled?

A3:

在 ddim_hacked.py 文件中,将 register_buffer 方法里这行代码
bash 复制代码
attr = attr.to(torch.device("cuda"))

修改为

bash 复制代码
if torch.backends.mps.is_available():
  attr = attr.to(torch.device("mps"))
else:
  attr = attr.to(torch.device("cpu"))

Q4: ComfyUI/custom_nodes/ComfyUI_Anytext/Image_Generation_AnyText/Site_Packages/AnyTextControlDiffusion/cldm/ddim_hacked.py", line 22, in register_buffer attr = attr.to(torch.device("mps")) TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead?

A4:

在 ddim_hacked.py 文件中,将 register_buffer 方法里这行代码
bash 复制代码
if torch.backends.mps.is_available():
  attr = attr.to(torch.device("mps"))
else:
  attr = attr.to(torch.device("cpu"))

修改为:

bash 复制代码
if attr.dtype == torch.float64:
  attr = attr.to(torch.float32)
if torch.backends.mps.is_available():
  attr = attr.to(torch.device("mps"))
else:
  attr = attr.to(torch.device("cpu"))
相关推荐
AI技术增长2 分钟前
Pytorch图像去噪实战(八):Noise2Void盲点网络图像去噪实战,只有单张带噪图也能训练
人工智能·pytorch·python
梦想很大很大7 分钟前
让 AI 成为“报表配置员”:BI 低代码平台的 Schema 实践路径
前端·人工智能·低代码
隔壁大炮13 分钟前
Day07-RNN层(循环网络层)
人工智能·pytorch·python·rnn·深度学习·神经网络·计算机视觉
小饕18 分钟前
从 Word2Vec 到多模态:词嵌入技术的演进全景
人工智能·算法·机器学习
上海云盾第一敬业销售19 分钟前
生成式AI催生深度伪造攻击,WAF如何识别“假流量“?
人工智能
ykjhr_3d20 分钟前
数字工具AI智能学伴,助力教育数字化转型
大数据·人工智能·ai·ai人工智能·华锐视点·华锐云空间
LIUAWEIO22 分钟前
鸽鸽工具网:免费在线工具大全,打开网页即用
人工智能·安全·ai·json
动恰客流管家26 分钟前
动恰3DV3丨客流统计系统:旺季人手不够淡季闲人太多?客流统计帮你科学优化人力成本
大数据·运维·人工智能·3d
吻等离子29 分钟前
机器学习基本概念篇(含思维导图)
人工智能·机器学习
乐维_lwops30 分钟前
智变2026:中国IT运维管理软件行业全景洞察——从AI重塑到信创深水区
运维·人工智能