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"))
相关推荐
晨非辰几秒前
算法闯关日记 Episode :解锁链表「环形」迷局与「相交」奥秘
数据结构·c++·人工智能·后端·python·深度学习·神经网络
老蒋新思维1 分钟前
创客匠人 2025 峰会深度解析:AI 赋能垂直领域,创始人 IP 变现的差异化路径
大数据·网络·人工智能·网络协议·tcp/ip·重构·知识付费
沛沛老爹2 分钟前
AI入门之LangChain Agent工具链组合设计:从理论到产业落地的AI智能体架构指南
人工智能·架构·langchain·agent·ai入门
摘星编程5 分钟前
解构CANN图编译技术:打造高吞吐、低延迟的实时AI质检系统
人工智能
8个贝壳35 分钟前
开发者福音!一键聚合GPT-5.1、Claude 4.5:我的高性价比AI模型中转站实战分享
人工智能
liliangcsdn37 分钟前
如何从二项分布中抽取样本 - binomial
大数据·人工智能
北京耐用通信41 分钟前
耐达讯自动化Profibus光纤转换器为您的水处理系统装上“光纤高速路”,数据从此畅通无阻!
网络·人工智能·科技·网络协议·自动化·信息与通信
老蒋新思维42 分钟前
创客匠人 2025 峰会深度解析:AI 激活创始人 IP 变现的核心价值
网络·人工智能·网络协议·tcp/ip·创始人ip·创客匠人·知识变现
仙女修炼史1 小时前
目标分割学习之U_net
人工智能·深度学习·学习
nix.gnehc1 小时前
PyTorch自动求导
人工智能·pytorch·python