ComfyUI ModuleNotFoundError: No module named 'sageattention' 修復
判斷 ComfyUI No module named 'sageattention' 是可忽略的啟動 warning,還是 Wan、HunyuanVideo、LTX、Qwen Image 工作流阻塞;先切回 SDPA/Comfy,再檢查正確的 Python、Triton 與 SageAttention。
ComfyUI ModuleNotFoundError: No module named 'sageattention' 修復
No module named 'sageattention' 不一定代表你應該立刻安裝 SageAttention。
很多時候它只是可選加速後端的 warning;但在 WanVideoWrapper、HunyuanVideo、LTX、Qwen Image 等影片工作流中,它也可能是 queue 時真正阻塞的錯誤。這篇先幫你判斷是哪一種,再決定要不要動 Python 套件。
30 秒判斷你該走哪條路
| 你看到的情況 | 通常代表 | 先做什麼 |
|---|---|---|
| 啟動時 warning,但 ComfyUI 能開、工作流能跑 | 可選後端不可用 | 先忽略,或保持 SageAttention 關閉 |
| WanVideoWrapper / HunyuanVideo / LTX / Qwen Image queue 時失敗 | 工作流真的請求 SageAttention | 先把節點後端改成 sdpa、comfy、torch 或 auto |
你加過 --use-sage-attention | ComfyUI 被強制全域使用 SageAttention | 移除參數後重啟 |
同時出現 No module named 'triton' | Triton 層缺失或版本錯誤 | 先修 Triton,不要先重裝 SageAttention |
DLL load failed while importing _fused | wheel 已裝入,但和 Python/Torch/CUDA/GPU 不匹配 | 停止反覆重裝,回退或找完全匹配的版本 |
unsupported head_dim: 256, using pytorch attention instead | ComfyUI 回退到 PyTorch attention | 工作流沒有中斷時通常不是致命錯誤 |
第 1 步:先判斷是啟動 warning 還是工作流失敗
如果日誌只是:
[WARNING] Warning: Could not load sageattention: No module named 'sageattention'
[WARNING] sageattention package is not installed, sageattention will not be available而 ComfyUI 仍然能進入瀏覽器介面,這通常不是緊急故障。
SageAttention 是可選的 attention 加速後端。很多工作流可以用 sdpa、comfy、torch 或 auto 正常執行。
只有當工作流真的停止,特別是 traceback 出現在影片或 attention 節點附近時,才繼續往下修。
第 2 步:安裝前先關掉 SageAttention
多數使用者應該先取消強制 SageAttention,而不是先安裝套件。
如果你加過啟動參數
移除:
--use-sage-attention然後重啟 ComfyUI。
如果工作流節點有 attention backend 下拉選單
把模型載入器、影片 wrapper 或 attention 相關節點中的:
sageattn
sageattention
SageAttention改成:
sdpa
comfy
torch
auto再重新 queue。
WanVideoWrapper 和影片工作流
很多 Wan/Hunyuan/LTX/Qwen 影片工作流都有 attention backend 選項。如果改成 sdpa 或 comfy 後工作流能跑,你就不需要為了當前任務安裝 SageAttention。
第 3 步:確認 ComfyUI 實際使用哪個 Python
這個錯誤反覆出現,最常見原因是套件裝進了錯的 Python。
Windows Portable
在 ComfyUI_windows_portable 資料夾開 PowerShell:
.\python_embeded\python.exe -s -c "import sys; print(sys.executable)"
.\python_embeded\python.exe -s --version輸出路徑應該指向目前免安裝版資料夾:
ComfyUI_windows_portable\python_embeded\python.exe後面所有 pip show、安裝、解除安裝與驗證,都要用同一個解譯器。
手動 venv
啟用真正用來啟動 ComfyUI 的 venv,然後執行:
python -c "import sys; print(sys.executable)"
python --version確認它不是系統 Python、Conda 或 Windows Store Python。
用 Wonderful Launcher 找 Python 路徑
如果你用 Wonderful Launcher 管理 ComfyUI,通常可以在目前實例的啟動日誌開頭找到啟動命令或 Python 路徑。搜尋 python.exe、python_embeded 或啟動命令;如果日誌沒有完整路徑,就在實際 ComfyUI 資料夾執行上面的命令確認。
第 4 步:檢查 Triton,但不要混淆套件名和匯入名
Windows 上的 SageAttention 常常卡在 Triton。
Windows 發行套件通常叫:
triton-windows但 Python 裡的匯入名稱仍然是:
import tritonWindows Portable
.\python_embeded\python.exe -s -m pip show triton-windows
.\python_embeded\python.exe -s -c "import triton; print(triton.__version__)"手動 venv
python -m pip show triton-windows
python -c "import triton; print(triton.__version__)"如果 import triton 失敗,先不要繼續重裝 SageAttention。先處理 Triton:
第 5 步:決定是否真的值得安裝 SageAttention
只有符合下面情況時才安裝:
- 工作流沒有
sdpa、comfy、torch或auto替代選項; - 節點或工作流作者明確要求 SageAttention;
- 你是在刻意最佳化影片工作流,且願意處理 Python/Torch/CUDA/Triton 相容性。
不要因為一條啟動 warning 就安裝。
如果 torch.cuda.is_available() 是 false、你不知道 ComfyUI 用哪個 Python、找不到完全匹配的建置版本,或工作流改成 sdpa / comfy 後已經能跑,就先不要裝。
第 6 步:必須安裝時,先記錄環境並進入安裝指南
Windows 沒有一條適合所有 ComfyUI 的 SageAttention 萬用命令。
安裝前至少記錄:
nvidia-smiWindows Portable
.\python_embeded\python.exe -s --version
.\python_embeded\python.exe -s -m pip freeze > sageattention-before.txt
.\python_embeded\python.exe -s -c "import torch; print(torch.__version__); print(torch.version.cuda); print(torch.cuda.is_available())"手動 venv
python --version
python -m pip freeze > sageattention-before.txt
python -c "import torch; print(torch.__version__); print(torch.version.cuda); print(torch.cuda.is_available())"選擇 wheel 時以 torch.version.cuda 為準,不要只看 nvidia-smi 頂部的 CUDA Version。
接著看:
在 Windows ComfyUI 中安裝 SageAttention
安裝指南通過後,再回到本頁做第 7 步驗證。
第 7 步:完成安裝後,回到這裡驗證
不要只看 Successfully installed。
Windows Portable
.\python_embeded\python.exe -s -m pip show sageattention
.\python_embeded\python.exe -s -c "from sageattention import sageattn; print('SageAttention OK')"手動 venv
python -m pip show sageattention
python -c "from sageattention import sageattn; print('SageAttention OK')"接著重啟 ComfyUI,重新 queue 原本工作流。
如果錯誤從 No module named 'sageattention' 變成 DLL load failed while importing _fused,表示安裝的 build 和目前執行環境不匹配。不要繼續疊加安裝,請回退或換成相容版本。
如果修復仍然失敗
| 新症狀 | 常見原因 | 下一步 |
|---|---|---|
pip install 成功但 ComfyUI 仍說缺少 | 裝到錯的 Python | 重做第 3 步,用正確解譯器安裝 |
No module named 'triton' | Triton 缺失或版本錯 | 先修 Triton |
DLL load failed while importing libtriton | Triton 二進位或 runtime 問題 | 看 Triton 指南 |
DLL load failed while importing _fused | SageAttention wheel 不匹配 | 卸載該版本,回到 SDPA/Comfy |
unsupported head_dim | 目前模型形狀不支援該後端 | 改用 PyTorch/SDPA/Comfy attention |
| 黑圖或 CUDA error | kernel/runtime 不相容 | 關閉 SageAttention 並回退 |
安全回退
先移除:
--use-sage-attention把節點後端改回:
sdpa
comfy
torch
auto再用同一個 Python 卸載 SageAttention:
Windows Portable
.\python_embeded\python.exe -s -m pip uninstall sageattention -y手動 venv
python -m pip uninstall sageattention -y如果 triton-windows 在這次修復前就已存在,不要盲目卸載。先對照 sageattention-before.txt。
為什麼重裝 ComfyUI 通常沒用
這類問題通常在執行環境套件層,不是工作流 JSON 本身。
重裝 ComfyUI 仍可能留下:
- 錯的 Python 環境;
- 缺失或錯誤的 Triton;
- 不相容的 wheel;
- 工作流仍強制 SageAttention;
- GPU / PyTorch / CUDA 不匹配。
先把判斷鏈走完:warning 還是致命、強制還是可選、Python 是否正確、Triton 是否能匯入、是否真的需要安裝。
SageAttention 是什麼
SageAttention 是某些大型圖片和影片工作流使用的最佳化 attention 後端。在 ComfyUI 裡,它不是通用必備相依性。
如果工作流能用 SDPA、Comfy 或 PyTorch attention 執行,通常可以不裝 SageAttention。只有特定節點強制要求時,才把它當成一組必須匹配 Python、PyTorch、CUDA、Triton、Windows 和 GPU 架構的原生加速堆疊處理。
相關指南
- 在 Windows ComfyUI 中安裝 SageAttention
- ComfyUI 中 Triton 缺失或不可用
- ComfyUI 插件匯入失敗
- ComfyUI 相依性衝突
- ComfyUI 啟動失敗
來源參考
- SageAttention 官方 GitHub 倉庫
- SageAttention PyPI 頁面
- ComfyUI 命令列參數
- ComfyUI issue:SageAttention 安裝到錯誤 Python 的案例
- WanVideoWrapper issue:模型載入時找不到 SageAttention
- ComfyUI issue:SageAttention DLL load failed
- triton-windows PyPI 頁面
- Triton Windows 目前專案
- Triton Windows 歷史倉庫
- NVIDIA CUDA Toolkit、Driver 和 Architecture Matrix
先按上面的步驟定位根因。還卡住時,可以下載 Wonderful Launcher 檢查目前機器;啟動器原生修復、任務日誌和執行階段檢查會集中在一起。credits 只用於圖片生成和按量工具。
下載 Wonderful Launcher查看 credits 方案這篇文件解決了你的問題嗎?
你的回饋會幫助我們優先補強真實 ComfyUI 排障文件。