报错
064
PyTorch、CUDA 运行库与加速库冲突
含未核实说明
Windows 上 No module named 'triton' / SageAttention 无法导入
报错原文(原样)
ModuleNotFoundError: No module named 'triton' Can't import SageAttention: No module named 'triton'
检索关键词
No module named 'triton'、ModuleNotFoundError: No module named 'triton'、Can't import SageAttention、triton-windows、WanVideoModelLoader triton
先看这一句
启动或执行 WanVideo 等依赖 SageAttention 的节点时报 No module named 'triton';ComfyUI 日志里出现 Can't import SageAttention 的提示,节点自动回退或直接失败。
适用版本 仅 Windows 需要此方案;Linux 上官方 triton 可直接 pip 安装。50 系显卡务必用 Triton >= 3.3;Turing(GTX 16xx / RTX 20xx)自 Triton 3.3 起被官方移除支持,只能用 Triton <= 3.2。
·
核实日期 2026-09-26
·
状态 可能已过期,正在复核
适用环境:Windows 便携版、秋叶/绘世整合包、全部主流环境
现象与触发场景
常见触发场景:
- 在 Windows 上按 Linux 教程 pip install triton(官方 PyPI 的 triton 在 Windows 上没有可用 wheel)
- 只装了 SageAttention 的 wheel 而没有先装 triton-windows
- 把 triton 装到了系统 Python 而不是便携版的 python_embeded
根因
- 官方 Triton 长期不提供 Windows 原生 wheel,Windows 上要用社区维护的 triton-windows(现已迁移到 triton-lang/triton-windows 仓库),SageAttention 等直接调用 triton.jit 的库在 Windows 上必须先装它。
- triton-windows 的 README 明确写了 RTX 50 系(Blackwell,sm120)只能配 Triton >= 3.3、PyTorch >= 2.7、CUDA >= 12.8 使用;同时该 README 列出了 PyTorch 与 Triton 的对应关系(例如 PyTorch 2.7 对应 Triton 3.3,2.10 对应 3.6)。
- 在便携版里直接执行 pip 会装到别的 Python 上,所以必须在 ComfyUI 根目录用完整路径调用 python_embeded\python.exe -m pip。
解决步骤
已按「最可能有效」排序。请从上往下做,每做完一步用「验证」确认,不要一次改五处。
- 用便携版解释器安装 triton-windowstriton-windows 自 3.2.0.post11 起把最小 CUDA 工具链打包进 wheel,自 3.2.0.post13 起打包 TinyCC,所以不需要额外装 CUDA Toolkit 或 Visual Studio 就能用 SageAttention 这类库。为避免以后新版 Triton 与已装 PyTorch 冲突,README 建议限制版本上限。.\python_embeded\python.exe -m pip install -U "triton-windows<3.7".\python_embeded\python.exe -c "import triton; print(triton.__version__)"
- 再安装与当前 torch 版本对应的 SageAttention wheelSageAttention 不能从 PyPI 装(PyPI 不支持同一版本多 PyTorch/CUDA 变体),只能从仓库的 Releases 页手动挑 wheel:按文件名里的 torch 版本挑(近期的 wheel 使用 libtorch stable ABI,文件名带 torch2.10.0andhigher,表示支持 PyTorch >= 2.10),CUDA 小版本(12.8/12.9)不用强求一致,但 CUDA 大版本 12 与 13 之间不能混。wheel 已内置 sm75/80/86/87/89/90 以及 CUDA >= 12.8 的 sm120 kernel。.\python_embeded\python.exe -m pip install <下载下来的 sageattention-*.whl>
- 先用官方测试脚本验证 SageAttention 本身可用,再在 ComfyUI 里启用仓库 README 明确建议:在大项目(如 ComfyUI)里使用之前,先跑 tests/test_sageattn.py 验证 SageAttention 自身是否工作;确认无误后再在启动参数里加 --use-sage-attention。若注意力库不稳定,退回 ComfyUI 自带实现。.\python_embeded\python.exe -s ComfyUI\main.py --use-sage-attention.\python_embeded\python.exe -s ComfyUI\main.py --use-pytorch-cross-attention
验证是否修好
python -c "import triton; import sageattention" 不再报 ModuleNotFoundError;启动 ComfyUI 后日志中 SageAttention 可正常加载,且跑一次大模型(如 Wan 系列)能出图;若输出全黑或噪点,按 README 改用 sageattn_qk_int8_pv_fp16_cuda 等更不易溢出的实现。
补充说明
另有更省事的官方推荐:woct0rdho/SageAttention README 更新说明指出,ComfyUI 用户已经不需要再单独装它的 SageAttention wheel,可以直接用 comfy-kitchen 里的 SageAttention,启动时加 --use-ck-attention 而不是 --use-sage-attention。[未核实] 该 comfy-kitchen 路径在你当前 ComfyUI 版本中的可用性未实测。另外 triton-windows README 提到 Triton 3.1 移除了 triton.ops,若报相关错误通常是某个包(最常见是 bitsandbytes)过旧导致。
来源
按可信度排列:官方 issue / 官方文档 > 节点仓库 issue > 社区帖 > 中文社区文章。
链接以纯文本给出(本站不做站外跳转),需要核对时请自行复制到浏览器打开。
- [153] (节点仓库 issue) Triton fork for Windows support(triton-windows README) https://raw.githubusercontent.com/woct0rdho/triton-windows/master/README.md
- [154] (节点仓库 issue) SageAttention fork for Windows wheels and easy installation https://raw.githubusercontent.com/woct0rdho/SageAttention/master/README.md
- [155] (社区) How do I fix "ModuleNotFoundError: No module named 'triton'" in ComfyU https://forum.smartart.live/topic/526-how-do-i-fix-modulenotfounderror-no-module-named-triton-in-comfyui/
本条的可靠性边界
下面这些位置带
[未核实] 标记,是采集时没找到一手来源的部分,请自行验证:
- 补充说明
这条报错要用到的东西
按本条报错所属的类别(PyTorch、CUDA 运行库与加速库冲突)列出站内相关的下载包与板块入口。 它们不是「必须下载才能修好」,而是这一类问题里最常要动到的东西;具体怎么做,以上面的解决步骤为准。
环境与依赖配置包依赖版本组合清单 / 环境自检脚本说明
待挂载
同一类别的其他条目
【056】启动或首次生成时报 AssertionError: Torch not compiled with CUDA enabled(装成了 CPU 版 torch)
有来源
【057】50 系显卡第一次卷积就崩:CUDA error: no kernel image is available for execution on the device
含未核实
【058】启动直接崩:torch / torchvision / torchaudio 三者 CUDA 版本不一致
含未核实
【059】节点执行时报 Could not run 'torchvision::nms' / operator torchvision::nms does not exist
含未核实
【060】自定义节点装完 / 更新依赖后 torch 被偷换成 CPU 版(依赖漂移)
有来源
这个解法对你有效吗
记录只存在你自己的浏览器里,不需要注册账号。
知仓学习社