Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't import SageAttention: DLL load failed while importing libtriton: 动态链接库(DLL)初始化例程失败。 #71

Open
dys2017 opened this issue Mar 3, 2025 · 11 comments

Comments

@dys2017
Copy link

dys2017 commented Mar 3, 2025

你好,我的环境是cuda11.8,torch2.3.0,python3.11.
尝试安装的您的triton3.1.0,3.0.0,3.2.0 这几个版本的轮子后;
在调用sageattnd跑wan2模型的时候都提示:Can't import SageAttention: DLL load failed while importing libtriton: 动态链接库(DLL)初始化例程失败。

请问有什么建议吗?这个和cuda的版本有关系吗?

@dys2017
Copy link
Author

dys2017 commented Mar 3, 2025

如果跟cuda版本有关系的话,我在考虑要不要装cuda 12.1,但有些节点好像会冲突,纠结ing...

@woct0rdho
Copy link
Owner

woct0rdho commented Mar 3, 2025

你可以先把这里的教程看一遍 https://github.com/woct0rdho/triton-windows#install-from-wheel

目前一般来说推荐的是CUDA 12.6,PyTorch 2.6,Triton 3.2,如果有节点冲突那就是那些节点太旧了,应该有办法给它们更新

@usadaddy
Copy link

usadaddy commented Mar 3, 2025

I get 'DLL load failed while importing libtriton' when running the test_triton.py script even after implementing suggested fixes. Do you think its a version issue? Running Python 3.10.14, CUDA 12.4, PyTorch 2.6, Triton 3.2 in venv.

@woct0rdho
Copy link
Owner

@usadaddy You can use dlltracer: https://github.com/woct0rdho/triton-windows#dlltracer , and paste the results here

Also please run Get-Command -All python in PowerShell in the same environment (or where python in cmd) and paste the results here

@usadaddy
Copy link

usadaddy commented Mar 3, 2025

dlltracer result:

D:\ComfyUI\venv\lib\site-packages\torch\utils_pytree.py:185: FutureWarning: optree is installed but the version is too old to support PyTorch Dynamo in C++ pytree. C++ pytree support is disabled. Please consider upgrading optree using python3 -m pip install --upgrade 'optree>=0.13.0'.
warnings.warn(
LoadLibrary C:\Windows\System32\kernel.appcore.dll
LoadLibrary C:\Windows\System32\apphelp.dll
LoadLibrary D:\ComfyUI\venv\Lib\site-packages\triton_C\libtriton.pyd
Failed \Device\HarddiskVolume7\ComfyUI\venv\Lib\site-packages\triton_C\libtriton.pyd
Traceback (most recent call last):
File "D:\ComfyUI\dlltracer_test.py", line 6, in
import triton
File "D:\ComfyUI\venv\lib\site-packages\triton_init_.py", line 20, in
from .runtime import (
File "D:\ComfyUI\venv\lib\site-packages\triton\runtime_init_.py", line 1, in
from .autotuner import (Autotuner, Config, Heuristics, autotune, heuristics)
File "D:\ComfyUI\venv\lib\site-packages\triton\runtime\autotuner.py", line 9, in
from .jit import KernelInterface
File "D:\ComfyUI\venv\lib\site-packages\triton\runtime\jit.py", line 12, in
from ..runtime.driver import driver
File "D:\ComfyUI\venv\lib\site-packages\triton\runtime\driver.py", line 1, in
from ..backends import backends
File "D:\ComfyUI\venv\lib\site-packages\triton\backends_init_.py", line 50, in
backends = discover_backends()
File "D:\ComfyUI\venv\lib\site-packages\triton\backends_init
.py", line 43, in _discover_backends
compiler = load_module(name, os.path.join(root, name, 'compiler.py'))
File "D:\ComfyUI\venv\lib\site-packages\triton\backends_init
.py", line 12, in _load_module
spec.loader.exec_module(module)
File "D:\ComfyUI\venv\lib\site-packages\triton\backends\amd\compiler.py", line 2, in
from triton._C.libtriton import ir, passes, llvm, amd
ImportError: DLL load failed while importing libtriton: A dynamic link library (DLL) initialization routine failed.

Python (3.10.81* is the venv version I'm trying to install triton under):

CommandType Name Version Source


Application python.exe 3.10.81... D:\ComfyUI\venv\scripts\python.exe
Application python.exe 3.10.14... C:\ProgramData\miniconda3\python.exe
Application python.exe 3.12.61... C:\Python312\python.exe

@JanisCircenis
Copy link

Getting exactly the same error as above.

@woct0rdho
Copy link
Owner

@usadaddy Did you create the venv using the Python at C:\Python312\python.exe, or using the Python in conda?

If it's the Python in conda, did you use the conda command, or use the Python venv or virtualenv command?

Also, what is the command you used to install triton?

@usadaddy
Copy link

usadaddy commented Mar 4, 2025

Pretty sure the venv was created using (base) conda env so the python for that was 3.10.14.

The command was Python venv.

Command used to install triton was the one given in your guide, but with the appropriate python version, and in the activated venv:

pip install https://github.com/woct0rdho/triton-windows/releases/download/v3.2.0-windows.post10/triton-3.2.0-cp310-cp310-win_amd64.whl

@woct0rdho
Copy link
Owner

Don't mix conda and Python venv, because it's known to cause problems, such as failing to find the correct vcruntime140.dll . As you're already using conda, you can just create a new conda env

@usadaddy
Copy link

usadaddy commented Mar 4, 2025

Theyre not mixed. The entire triton install process was conducted inside the activated venv for ComfyUI.

Isn't that where it needs to be installed for Comfyui nodes to use it?

@woct0rdho
Copy link
Owner

woct0rdho commented Mar 4, 2025

If you use the venv command in a conda env to create a new venv, then the venv will only encapsulate the 'Python side' of things, such as site-packages, while the 'non-Python side' of things, such as vcredist and CUDA libraries are not managed by the venv. From the past experience of people here, the most problematic thing is to link against the correct vcredist

That's not how conda is designed to work, and that will make things over-complicated. Please don't do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants