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"))
相关推荐
秦先生在广东3 分钟前
多智能体统一架构:拆解 wshobson/agents 的跨工具插件适配机制
人工智能
秦先生在广东9 分钟前
Graphify:基于本地确定性 AST 解析的代码知识图谱探索
人工智能
阿里云大数据AI技术37 分钟前
【云栖实录】一切数据,皆可计算:MaxCompute 升级为AI Native全模态计算服务
大数据·人工智能·agent
面壁的熊猫1 小时前
agent-team 与 Multica 差异分析,以及 2026 年多 Agent 编码编排最新相关工作
人工智能·开源项目·ai agent
云淡风轻~窗明几净1 小时前
角谷猜想最接近严格证明的测试 Version1.1.1
人工智能·算法·机器学习·图论
武子康1 小时前
撤回发生在重建途中,旧索引还能切回来吗
人工智能·后端·agent
新知图书1 小时前
10.3 本地生活与商业服务:信任构建的差异化路径
人工智能
博谷1 小时前
2026年AI搜索监测平台的问题库怎么搭建?BUGOOAI布谷GEO用五域问题模型拆解决策变量
人工智能
珠海西格电力1 小时前
物联网(IoT)在零碳园区中的关键作用:万物互联与数据采集
大数据·人工智能·物联网·安全·系统架构·能源
蒲公英内测分发1 小时前
智能门锁量产时,工厂测试 App 一直在更新,产线怎么避免装错 APK?
服务器·人工智能·github·智能硬件·智能手表