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"))
相关推荐
ucancode12 小时前
AI --> Mermaid --> 图形可视化 (UI)
人工智能·ui·ai·mermaid
小李AI飞刀^_^12 小时前
AlphaEarth Foundations:面向全球尺度的嵌入场模型
人工智能
KmBase12 小时前
【AI】从同构到多态:AGI的可能之路
人工智能·agi
翱翔的苍鹰12 小时前
完整的“RNN + jieba 中文情感分析”项目之一:需要添加添加 JWT 认证
人工智能·python·rnn
minhuan12 小时前
大模型应用:拆解大模型算力需求:算力是什么?怎么衡量?如何匹配?.64
人工智能·gpu算力·大模型应用·算力评估·算力优化
凤希AI伴侣12 小时前
凤希AI伴侣功能修复与积分系统上线-2026年1月23日
人工智能·凤希ai伴侣
Cherry的跨界思维12 小时前
【AI测试全栈:质量】40、数据平权之路:Python+Java+Vue全栈实战偏见检测与公平性测试
java·人工智能·python·机器学习·ai测试·ai全栈·ai测试全栈
北京盟通科技官方账号12 小时前
从“人机交互”到“数字预演”:详解 HMI、SCADA 与虚拟调试的闭环架构
人工智能·人机交互·数字孪生·scada·系统集成·hmi·虚拟调试
工程师老罗12 小时前
Pycharm下新建一个conda环境后,如何在该环境下安装包?
人工智能·python
飞Link12 小时前
Spatiotemporal Filtering(时空滤波)详解:从理论到实战
人工智能·深度学习·机器学习·计算机视觉