You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ImportError: DLL load failed while importing tensorrt #1446
PS C:\Users\Plasm> python
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import tensorrt
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Plasm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\tensorrt_init_.py", line 71, in
from .tensorrt import *
ImportError: DLL load failed while importing tensorrt: 找不到指定的模块。(means ‘The specified module could not be found’)
Thanks for reporting the bug. I can repro on python 3.11 with tensorrt==9.3.0.post12.dev1 wheel on windows. I have root-caused the issue to missing cuDNN libs. Here are my findings
import tensorrt_llm works OOTB because TRT-LLM first imports torch (which loads up cuDNN libs) and then imports tensorrt (which can find these cuDNN libs) loaded by torch.
import tensorrt as trt does NOT work because tensorrt 9.3.0 requires cuDNN libs. Now cuDNN does get installed along with TRT but these are nvidia-cublas-cu12 libs
I suspected that these libs were not getting loaded, so I tried installing cudnn-12 libs from another version using python3 -m pip uninstall nvidia-cudnn-cu12 and python3 -m pip install nvidia-cudnn-cu12==8.9.4.25 and after that import TRT works
Also note that if you are getting strange error messages like #1062, you need to first import torch followed by tensorrt.
I don't know why this issue surfaced now, but it may be better to report this in the TRT package repo. Let me consult with packaging experts and get back to you. For now the workaround is to do
# Remove older version of TRT
pip3 uninstall -y tensorrt nvidia-cudnn-cu12
pip3 install nvidia-cudnn-cu12==8.9.4.25
pip3 install tensorrt==9.3.0.post12.dev1 --extra-index-url https://pypi.nvidia.com/
Seems like this is a known issue and we missed it in the windows packaging requirements. For now, please use the workaround mentioned above : we will fix this soon. Thanks!
CUDA:12.4
CUDNN:9.1.0(I've updated)
(But there's a question I'm not sure about, what is the relationship between the cudnn manually added to CUDA and the cudnn downloaded by pip)(It's not clear to me if pip's cudnn is compatible with my cudnn 9.1.0)
I have followed the steps you gave.
PS C:\Users\Plasm> python -c "import tensorrt as trt; print(trt.version)"
9.3.0.post12.dev1
It seems that tensorrt has been recognized normally.But when checking tensorrt-llm,it's still an error.
PS C:\Users\Plasm> python -c "import tensorrt_llm; print(tensorrt_llm.utils.trt_version())"
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Plasm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\tensorrt_llm_init.py", line 28, in add_trt_llm_dll_directory()
File "C:\Users\Plasm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\tensorrt_llm_init.py", line 24, in _add_trt_llm_dll_directory
os.add_dll_directory(
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\os.py", line 1118, in add_dll_directory
cookie = nt._add_dll_directory(path)
FileNotFoundError: [WinError 3] 系统找不到指定的路径。: 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\Lib\site-packages\tensorrt_llm\libs'
It doesn't seem to be able to find Tensorrt-llm.
However,
PS C:\Users\Plasm> pip check
torchdata 0.7.0 has requirement torch==2.1.0, but you have torch 2.2.0+cu121.
torchtext 0.16.0+cpu has requirement torch==2.1.0, but you have torch 2.2.0+cu121.
torchvision 0.16.0+cu121 has requirement torch==2.1.0+cu121, but you have torch 2.2.0+cu121.
How do I make sure that torch doesn't conflict with 3 packages? Update 3 packages to a certain version?
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\Lib\site-packages
and this leads to confusion. trt-llm looks for the site-packages\tensorrt_llm\libs directory to load DLLs. So while location (1) is where you have installed trt-llm looks like (2) is the "official" site-packages directory. Can you let me know
if you are installing tensorrt-llm as a user (using pip install -u flag)
@tp5uiuc I seem to understand that my python is downloaded from the Microsoft Store, not the official python website.The catalog downloaded by the store is different from that downloaded by the official one.This may be the cause of the error.
Activity
tp5uiuc commentedon Apr 15, 2024
Hi @Plasma4004
Thanks for reporting the bug. I can repro on python 3.11 with
tensorrt==9.3.0.post12.dev1wheel on windows. I have root-caused the issue to missingcuDNNlibs. Here are my findingsimport tensorrt_llmworks OOTB because TRT-LLM first imports torch (which loads upcuDNNlibs) and then imports tensorrt (which can find thesecuDNNlibs) loaded by torch.import tensorrt as trtdoes NOT work becausetensorrt 9.3.0requires cuDNN libs. Now cuDNN does get installed along with TRT but these are nvidia-cublas-cu12 libsI suspected that these libs were not getting loaded, so I tried installing cudnn-12 libs from another version using
python3 -m pip uninstall nvidia-cudnn-cu12andpython3 -m pip install nvidia-cudnn-cu12==8.9.4.25and after that import TRT worksAlso note that if you are getting strange error messages like #1062, you need to first import torch followed by tensorrt.
I don't know why this issue surfaced now, but it may be better to report this in the TRT package repo. Let me consult with packaging experts and get back to you. For now the workaround is to do
tp5uiuc commentedon Apr 17, 2024
Seems like this is a known issue and we missed it in the windows packaging requirements. For now, please use the workaround mentioned above : we will fix this soon. Thanks!
Plasma4004 commentedon Apr 26, 2024
CUDA:12.4
CUDNN:9.1.0(I've updated)
(But there's a question I'm not sure about, what is the relationship between the cudnn manually added to CUDA and the cudnn downloaded by pip)(It's not clear to me if pip's cudnn is compatible with my cudnn 9.1.0)
I have followed the steps you gave.
It seems that tensorrt has been recognized normally.But when checking tensorrt-llm,it's still an error.
It doesn't seem to be able to find Tensorrt-llm.
However,
Plasma4004 commentedon Apr 26, 2024
And after the operation
There is a conflict in the pip package.
How do I make sure that torch doesn't conflict with 3 packages? Update 3 packages to a certain version?
tp5uiuc commentedon Apr 29, 2024
@Plasma4004 : Good to know that the import issue has been resolved. I am answering other questions inline.
There seems to be two versions of python site-packages in your local env:
C:\Users\Plasm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packagesC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\Lib\site-packagesand this leads to confusion.
trt-llmlooks for thesite-packages\tensorrt_llm\libsdirectory to load DLLs. So while location (1) is where you have installedtrt-llmlooks like (2) is the "official" site-packages directory. Can you let me knowtensorrt-llmas a user (usingpip install -uflag)pythonin the first place?Plasma4004 commentedon Apr 30, 2024
@tp5uiuc I seem to understand that my python is downloaded from the Microsoft Store, not the official python website.The catalog downloaded by the store is different from that downloaded by the official one.This may be the cause of the error.
tp5uiuc commentedon Apr 30, 2024
Great, thanks for letting me know @Plasma4004 . I am closing the issue, but feel free to re-open in case you have more questions.