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"))
相关推荐
LiFileHub12 小时前
2025 AI驱动产业转型全景手册:从技术破局到价值重生(附8大转型案例)
人工智能
python机器学习ML12 小时前
论文复现-以动物图像分类为例进行多模型性能对比分析
人工智能·python·神经网络·机器学习·计算机视觉·scikit-learn·sklearn
YANQ66212 小时前
14.1 人脸的三维重构(PRNet算法)
人工智能·重构
风途知识百科12 小时前
并网/分布式光伏气象站
人工智能·分布式
诸葛务农12 小时前
神经网络信息编码技术:与人脑信息处理的差距及超越的替在优势和可能(下)
人工智能·神经网络
m0_7048878912 小时前
Day44
人工智能·深度学习·机器学习
cici1587412 小时前
模式识别,非监督聚类分析分类方法
人工智能·机器学习·分类
自己的九又四分之三站台13 小时前
基于OpenCV扶正扫描文件
人工智能·opencv·计算机视觉·c#
IT_陈寒13 小时前
Python性能翻倍的5个隐藏技巧:让你的代码跑得比同事快50%
前端·人工智能·后端