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"))
相关推荐
winrisef10 分钟前
YOLOv11实时目标检测 | 摄像头视频图片文件检测
人工智能·python·深度学习·yolo·目标检测·音视频
爱研究的小牛11 分钟前
Deepseek技术浅析(四):专家选择与推理机制
人工智能·深度学习·aigc
weixin_3077791322 分钟前
在AWS上设计与实现个人财务助理的Web应用程序
人工智能·python·flask·云计算·aws
weixin_3077791329 分钟前
AWS上设计可图形化创建处理逻辑的智能电话语音客服程序的流程和关键代码
人工智能·python·自然语言处理·音视频·aws
szxinmai主板定制专家30 分钟前
基于RK3588+算能BM1684X的云电脑/云手机系统设计与实现
大数据·人工智能·fpga开发·边缘计算
圣心42 分钟前
模型蒸馏(ChatGPT文档)
人工智能·chatgpt
大模型任我行1 小时前
国防科大:双目标优化防止LLM灾难性遗忘
人工智能·语言模型·自然语言处理·论文笔记
沐欣工作室_lvyiyi1 小时前
语音识别播报人工智能分类垃圾桶(论文+源码)
人工智能·单片机·毕业设计·语音识别·plc·单片机毕业设计
程序猿阿伟1 小时前
《深度揭秘LDA:开启人工智能降维与分类优化的大门》
人工智能·分类·数据挖掘
X_taiyang182 小时前
深入理解浮点数:单精度、双精度、半精度和BFloat16详解
人工智能