[GH-ISSUE #94] ImportError: DLL load failed while importing KTransformersOps: The specified module was not found. #49

Closed
opened 2026-10-29 14:33:02 +00:00 by bsakaguchi · 16 comments
Owner

Originally created by @SCP12rs on GitHub (Sep 21, 2024).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/94

Error during model run
image

Originally created by @SCP12rs on GitHub (Sep 21, 2024). Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/94 Error during model run ![image](https://github.com/user-attachments/assets/0dd297a9-1bec-408d-a6c0-1a90e60a1aea)
bsakaguchi 2026-10-29 14:33:02 +00:00
  • closed this issue
  • added the
    stale
    label
Author
Owner

@SCP12rs commented on GitHub (Sep 21, 2024):

image

image

Everything seems to be in place, but the error won't go away.

I use ktransformers-0.1.1+cu125torch24avx2-cp311-cp311-win_amd64.whl

<!-- gh-comment-id:2365053696 --> @SCP12rs commented on GitHub (Sep 21, 2024): ![image](https://github.com/user-attachments/assets/452f395f-7599-4a62-b15c-a6ca988a18e0) ![image](https://github.com/user-attachments/assets/0859e245-5aea-4f2a-9380-77b87d70736d) Everything seems to be in place, but the error won't go away. I use ktransformers-0.1.1+cu125torch24avx2-cp311-cp311-win_amd64.whl
Author
Owner

@SCP12rs commented on GitHub (Sep 21, 2024):

image
Tried to build the project via .bat
An error occurred.

<!-- gh-comment-id:2365174029 --> @SCP12rs commented on GitHub (Sep 21, 2024): ![image](https://github.com/user-attachments/assets/85326522-9ac9-420e-93da-b8a0850d1525) Tried to build the project via .bat An error occurred.
Author
Owner

@UnicornChan commented on GitHub (Sep 22, 2024):

Do you have CUDA installed and set in the environment variables?
I see the final compilation error is due to failing to get the CUDA version.

<!-- gh-comment-id:2366847066 --> @UnicornChan commented on GitHub (Sep 22, 2024): Do you have CUDA installed and set in the environment variables? I see the final compilation error is due to failing to get the CUDA version.
Author
Owner

@SCP12rs commented on GitHub (Sep 23, 2024):

image
image
Maybe I didn't patch it correctly?

<!-- gh-comment-id:2367122664 --> @SCP12rs commented on GitHub (Sep 23, 2024): ![image](https://github.com/user-attachments/assets/856c649b-196d-4116-a824-aa40ae49a08b) ![image](https://github.com/user-attachments/assets/015eb49c-0921-4989-a95d-c8db96b5e7cb) Maybe I didn't patch it correctly?
Author
Owner

@SCP12rs commented on GitHub (Sep 23, 2024):

image

Update

<!-- gh-comment-id:2367141292 --> @SCP12rs commented on GitHub (Sep 23, 2024): ![image](https://github.com/user-attachments/assets/d8d05a64-4c1e-4cf2-b3b2-5cbec0a2ab18) Update
Author
Owner

@UnicornChan commented on GitHub (Sep 25, 2024):

I'm very sorry about it. The Windows server I previously used for testing was tested with CUDA 12.5, but not with CUDA 12.6. The script failure might be due to the version update. I will upgrade my Windows server and re-test to verify this issue.

<!-- gh-comment-id:2374578868 --> @UnicornChan commented on GitHub (Sep 25, 2024): I'm very sorry about it. The Windows server I previously used for testing was tested with CUDA 12.5, but not with CUDA 12.6. The script failure might be due to the version update. I will upgrade my Windows server and re-test to verify this issue.
Author
Owner

@SCP12rs commented on GitHub (Sep 26, 2024):

Thank you. I will keep an eye on your project. Very high hopes.

<!-- gh-comment-id:2376482504 --> @SCP12rs commented on GitHub (Sep 26, 2024): Thank you. I will keep an eye on your project. Very high hopes.
Author
Owner

@micellince commented on GitHub (Feb 11, 2025):

I'm very sorry about it. The Windows server I previously used for testing was tested with CUDA 12.5, but not with CUDA 12.6. The script failure might be due to the version update. I will upgrade my Windows server and re-test to verify this issue.

pip install torch装的是cpu版本的,卸载换对应cuda版本的torch就好了。

<!-- gh-comment-id:2650439104 --> @micellince commented on GitHub (Feb 11, 2025): > I'm very sorry about it. The Windows server I previously used for testing was tested with CUDA 12.5, but not with CUDA 12.6. The script failure might be due to the version update. I will upgrade my Windows server and re-test to verify this issue. pip install torch装的是cpu版本的,卸载换对应cuda版本的torch就好了。
Author
Owner

@micellince commented on GitHub (Feb 11, 2025):

Thank you. I will keep an eye on your project. Very high hopes.

pip uninstall torch ....
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 ( or 121 126.....).

<!-- gh-comment-id:2650442802 --> @micellince commented on GitHub (Feb 11, 2025): > Thank you. I will keep an eye on your project. Very high hopes. pip uninstall torch .... pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 ( or 121 126.....).
Author
Owner

@fshurra commented on GitHub (Feb 12, 2025):

I meet the same problem recently using a raw python install.
the problem solved after inject the "os.add_dll_directory" to let is search for the cuda library path.

This problem might came from the default .dll searching manner of your python install.
Please check this answer. https://stackoverflow.com/a/71645987/29078640

This problem might simply caused by not using the python inside conda env.
As I will have no surprise if the conda env have patched this default manner for searching .dll
(just like what they have done on searching .so)

<!-- gh-comment-id:2654554036 --> @fshurra commented on GitHub (Feb 12, 2025): I meet the same problem recently using a raw python install. the problem solved after inject the "[os.add_dll_directory](https://docs.python.org/3.8/library/os.html#os.add_dll_directory)" to let is search for the cuda library path. This problem might came from the default .dll searching manner of your python install. Please check this answer. https://stackoverflow.com/a/71645987/29078640 This problem might simply caused by not using the python inside conda env. As I will have no surprise if the conda env have patched this default manner for searching .dll (just like what they have done on searching .so)
Author
Owner

@elijahxb commented on GitHub (Feb 15, 2025):

Image

same issue.
@fshurra could you please show us how to add_dll_directory,i mean where the cuda library path is?
for example, should i add the code like below?

os.add_dll_directory('C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\lib\x64')

<!-- gh-comment-id:2660677434 --> @elijahxb commented on GitHub (Feb 15, 2025): ![Image](https://github.com/user-attachments/assets/c42b8f56-f276-4c3e-82b7-c235bdb842e4) same issue. @fshurra could you please show us how to add_dll_directory,i mean where the cuda library path is? for example, should i add the code like below? `os.add_dll_directory('C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\lib\x64')`
Author
Owner

@shijd32 commented on GitHub (Feb 15, 2025):

same issue:

File "D:\ProgramData\anaconda3\envs\Ktransformers\Lib\site-packages\ktransformers\util\custom_gguf.py", line 27, in
import KTransformersOps
ImportError: DLL load failed while importing KTransformersOps: 找不到指定的程序。

How can I solve this problem? Thank you very much!

<!-- gh-comment-id:2660774939 --> @shijd32 commented on GitHub (Feb 15, 2025): same issue: File "D:\ProgramData\anaconda3\envs\Ktransformers\Lib\site-packages\ktransformers\util\custom_gguf.py", line 27, in <module> import KTransformersOps ImportError: DLL load failed while importing KTransformersOps: 找不到指定的程序。 How can I solve this problem? Thank you very much!
Author
Owner

@shijd32 commented on GitHub (Feb 16, 2025):

WHO KNOW?

<!-- gh-comment-id:2661213545 --> @shijd32 commented on GitHub (Feb 16, 2025): WHO KNOW?
Author
Owner

@YoungITer commented on GitHub (Feb 16, 2025):

same issue:

File "D:\ProgramData\anaconda3\envs\Ktransformers\Lib\site-packages\ktransformers\util\custom_gguf.py", line 27, in import KTransformersOps ImportError: DLL load failed while importing KTransformersOps: 找不到指定的程序。

How can I solve this problem? Thank you very much!

I have the same problem. Please help

<!-- gh-comment-id:2661499251 --> @YoungITer commented on GitHub (Feb 16, 2025): > same issue: > > File "D:\ProgramData\anaconda3\envs\Ktransformers\Lib\site-packages\ktransformers\util\custom_gguf.py", line 27, in import KTransformersOps ImportError: DLL load failed while importing KTransformersOps: 找不到指定的程序。 > > How can I solve this problem? Thank you very much! I have the same problem. Please help
Author
Owner

@fshurra commented on GitHub (Feb 17, 2025):

Image

same issue. @fshurra could you please show us how to add_dll_directory,i mean where the cuda library path is? for example, should i add the code like below?

os.add_dll_directory('C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\lib\x64')

@elijahxb
Yes. Please add this directory in the "site-packages\ktransformers\util\custom_gguf.py"
before "import KTransformersOps"

This solved the problem for me.

<!-- gh-comment-id:2663903051 --> @fshurra commented on GitHub (Feb 17, 2025): > ![Image](https://github.com/user-attachments/assets/c42b8f56-f276-4c3e-82b7-c235bdb842e4) > > same issue. [@fshurra](https://github.com/fshurra) could you please show us how to add_dll_directory,i mean where the cuda library path is? for example, should i add the code like below? > > `os.add_dll_directory('C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\lib\x64')` @elijahxb Yes. Please add this directory in the "site-packages\ktransformers\util\custom_gguf.py" before "import KTransformersOps" This solved the problem for me.
Author
Owner

@ErvinXie commented on GitHub (Dec 11, 2025):

This issue has been automatically closed due to inactivity for 60 days.

If you believe this issue is still relevant, please feel free to reopen it with additional information or context.

Thank you for your contribution to KTransformers!


此 issue 因超过 60 天无活动而被自动关闭。

如果您认为此问题仍然存在,请随时重新打开并提供更多信息或上下文。

感谢您对 KTransformers 的贡献!

<!-- gh-comment-id:3639896346 --> @ErvinXie commented on GitHub (Dec 11, 2025): This issue has been automatically closed due to inactivity for 60 days. If you believe this issue is still relevant, please feel free to reopen it with additional information or context. Thank you for your contribution to KTransformers! --- 此 issue 因超过 60 天无活动而被自动关闭。 如果您认为此问题仍然存在,请随时重新打开并提供更多信息或上下文。 感谢您对 KTransformers 的贡献!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/ktransformers#49
No description provided.