ComfyUI-WanVideoWrapper icon indicating copy to clipboard operation
ComfyUI-WanVideoWrapper copied to clipboard

DLL load failed while importing flashattn_hopper_cuda

Open GDUT-HM opened this issue 1 year ago • 3 comments

Error message occurred while importing the 'ComfyUI-WanVideoWrapper' module.

Traceback (most recent call last): File "C:\Users\Administrator\Desktop\ComfyUI-aki-v1.4\nodes.py", line 2147, in load_custom_node module_spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in call_with_frames_removed File "C:\Users\Administrator\Desktop\ComfyUI-aki-v1.4\custom_nodes\ComfyUI-WanVideoWrapper_init.py", line 1, in from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS File "C:\Users\Administrator\Desktop\ComfyUI-aki-v1.4\custom_nodes\ComfyUI-WanVideoWrapper\nodes.py", line 9, in from .wanvideo.modules.clip import CLIPModel File "C:\Users\Administrator\Desktop\ComfyUI-aki-v1.4\custom_nodes\ComfyUI-WanVideoWrapper\wanvideo\modules_init_.py", line 1, in from .model import WanModel File "C:\Users\Administrator\Desktop\ComfyUI-aki-v1.4\custom_nodes\ComfyUI-WanVideoWrapper\wanvideo\modules\model.py", line 12, in from .attention import attention File "C:\Users\Administrator\Desktop\ComfyUI-aki-v1.4\custom_nodes\ComfyUI-WanVideoWrapper\wanvideo\modules\attention.py", line 5, in import flash_attn_interface File "C:\Users\Administrator\Desktop\ComfyUI-aki-v1.4\python\lib\site-packages\flashattn_hopper-3.0.0b1-py3.10-win-amd64.egg\flash_attn_interface.py", line 7, in import flashattn_hopper_cuda ImportError: DLL load failed while importing flashattn_hopper_cuda: 找不到指定的程序。

GDUT-HM avatar Mar 07 '25 08:03 GDUT-HM

Your flash_attn module cannot find the DLL dependencies for its pyd module. I wrote about that at https://github.com/3dluvr/windows-flux-lora-training-notes#flash-attention-with-cuda although I did not add a final solution yet. Right now I'm hardcoding a path to suit my (embedded python) environment.

Edit your flash_attn_interface.py, and before line 7 add:

import os
os.add_dll_directory(r'C:\Users\Administrator\Desktop\ComfyUI-aki-v1.4\python\lib\site-packages\torch\lib')

Presuming your torch module is installed in the above location and you have CUDA toolkit installed and environment vars set.

Hope this helps.

3dluvr avatar Mar 10 '25 14:03 3dluvr

您的 flash_attn 模块找不到其 pyd 模块的 DLL 依赖项。我在https://github.com/3dluvr/windows-flux-lora-training-notes#flash-attention-with-cuda上写了相关内容,尽管我尚未添加最终解决方案。现在,我正在硬编码一条路径以适合我的(嵌入式 Python)环境。

编辑您的flash_attn_interface.py,并在第 7 行之前添加:

import os
os.add_dll_directory(r'C:\Users\Administrator\Desktop\ComfyUI-aki-v1.4\python\lib\site-packages\torch\lib')

假设您的 torch 模块安装在上述位置,并且您已安装 CUDA 工具包并设置了环境变量。

希望这有帮助。

感谢您的flash_attn window wheel,但我目前还处于这个报错,非常感谢你!

GDUT-HM avatar Mar 14 '25 01:03 GDUT-HM

You could try installing dll-diagnostics module and run it against the flash_attn...pyd file in your \lib\site-packages\ folder.

It will show you whether it's finding the dependent DLLs or not and which ones are missing.

In example for me, when I run python_embedded\dlldiag deps python_embedded\Lib\site-packages\flash_attn_2_cuda.cp312-win_amd64.pyd with an unpatched flash_attn_interface.py I get the following:

api-ms-win-crt-heap-l1-1-0.dll       Loaded successfully
api-ms-win-crt-math-l1-1-0.dll       Loaded successfully
api-ms-win-crt-runtime-l1-1-0.dll    Loaded successfully
api-ms-win-crt-stdio-l1-1-0.dll      Loaded successfully
api-ms-win-crt-string-l1-1-0.dll     Loaded successfully
c10.dll                              Error 126: The specified module could not be found.
c10_cuda.dll                         Error 126: The specified module could not be found.
cudart64_12.dll                      Loaded successfully
KERNEL32.dll                         Loaded successfully
MSVCP140.dll                         Loaded successfully
python312.dll                        Loaded successfully
torch_cpu.dll                        Error 126: The specified module could not be found.
torch_cuda.dll                       Error 126: The specified module could not be found.
torch_python.dll                     Error 126: The specified module could not be found.
VCRUNTIME140.dll                     Loaded successfully
VCRUNTIME140_1.dll                   Loaded successfully

The missing files are in the python_embedded\Lib\site-packages\torch\lib folder so that's why we need to tell flash_attn_interface where to find them. You could try adding full path to python_embedded\Lib\site-packages\torch\lib to your PATH environment and see if that maybe fixes it but as far as I'm aware, modules now want that os.add_dll_directory instead of env PATH.

3dluvr avatar Mar 14 '25 02:03 3dluvr