ValueError: only one element tensors can be converted to Python scalars

用户在 ComfyUI 中运行 WAN Dancer 相关工作流,工作流在全局组(Global)中可正常执行,但切换到局部组(Local)后,设置 CFG > 1 且 steps = 24 时触发报错。报错回溯显示异常发生在 samplers.py 的采样循环内部,且经过 ComfyUI-Lora-

ValueError: only one element tensors can be converted to Python scalars

ValueError: only one element tensors can be converted to Python scalars

快速结论:该报错通常在使用 ComfyUI 的 WAN(WanVideo/Dancer)节点时,将 CFG 设置为大于 1 且步数为 24 时触发,优先排查自定义节点 ComfyUI-Lora-Manager 是否为最新版本,或尝试在全局组(Global)而非局部组(Local)中运行工作流。

问题场景

用户在 ComfyUI 中运行 WAN Dancer 相关工作流,工作流在全局组(Global)中可正常执行,但切换到局部组(Local)后,设置 CFG > 1steps = 24 时触发报错。报错回溯显示异常发生在 samplers.py 的采样循环内部,且经过 ComfyUI-Lora-Manager 自定义节点的元数据 hook。

报错原文

[ERROR] !!! Exception during processing !!! only one element tensors can be converted to Python scalars
[ERROR] Traceback (most recent call last):
  File "D:\sd-comfyui-aki\execution.py", line 543, in execute
    output_data, output_ui, has_subgraph, has_pending_tasks = await get_output_data(prompt_id, unique_id, obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb, v3_data=v3_data)
  ...
  File "D:\sd-comfyui-aki\comfy_api\latest\_io.py", line 1935, in EXECUTE_NORMALIZED
    to_return = cls.execute(*args, **kwargs)
  File "D:\sd-comfyui-aki\comfy_extras\nodes_custom_sampler.py", line 771, in execute
    samples = comfy.sample.sample_custom(model, noise, cfg, sampler, sigmas, positive, negative, latent_image, noise_mask=noise_mask, callback=callback, disable_pbar=disable_pbar, seed=noise_seed)
  ...
  File "D:\sd-comfyui-aki\comfy\samplers.py", line 1229, in inner_sample

原因分析

可能原因:该问题与局部组(Local group)中的组范围(group scope)机制有关。在局部组中,CFG 和步数参数的传递方式与全局组不同,触发了一个仅允许单个元素张量转换为 Python 标量的操作,导致采样过程异常。该问题很可能由 ComfyUI-Lora-Manager 自定义节点中的元数据收集 hook 在局部组上下文中触发,该 hook 在 async_map_node_over_list_with_metadata 中拦截了节点执行。

环境排查

  • ComfyUI 版本(检查是否为最新版)
  • ComfyUI-Lora-Manager 自定义节点版本(需确认已更新到支持局部组问题修复的最新版)
  • Python 版本(通常为 3.10 或 3.11)
  • 工作流中使用的模型:WAN(WanVideo/Dancer)相关模型
  • CFG 值是否大于 1,步数是否为 24(复现必要条件)

解决步骤

  1. 更新 ComfyUI-Lora-Manager(可优先尝试):根据 Issue 评论区,该问题已被标记为已修复。请将 ComfyUI-Lora-Manager 更新到最新版本。
  2. 切换组(Group):如果在更新后问题仍然存在,尝试将工作流从局部组(Local)移动到全局组(Global)运行。
  3. 调整参数:临时将 CFG 设置为 1 或将步数设置为非 24 的值,看是否能绕过该报错。
  4. 禁用自定义节点:在运行 WAN Dancer 工作流时暂时禁用除 ComfyUI-Lora-Manager 外的其他自定义节点,以排除冲突。

验证方法

以相同的 CFG > 1 且 steps = 24 的设置在局部组(Local)中重新运行工作流,观察是否能正常执行而不触发 ValueError: only one element tensors can be converted to Python scalars 报错。如果执行成功且无异常,问题即已解决。

参考来源

Comfy-Org/ComfyUI #14998 – wan dancer exception error

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 14524

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注