Open Connor923 opened 10 months ago
you can run tools/check_env.py,if tensorrt custom ops is not Available,you need to build it.See how to build[docs/en/01-how-to-build/windows.md](https://github.com/open-mmlab/mmdeploy/blob/main/docs/en/01-how-to-build/windows.md)
you can run tools/check_env.py,if tensorrt custom ops is not Available,you need to build it.See how to build[docs/en/01-how-to-build/windows.md](https://github.com/open-mmlab/mmdeploy/blob/main/docs/en/01-how-to-build/windows.md)
I meet the same error, and i run python tools/check_env.py ,got the following:
05/24 15:07:53 - mmengine - INFO -
05/24 15:07:53 - mmengine - INFO - **Environmental information** 05/24 15:07:57 - mmengine - INFO - sys.platform: win32 05/24 15:07:57 - mmengine - INFO - Python: 3.10.14 | packaged by Anaconda, Inc. | (main, May 6 2024, 19:44:50) [MSC v.1916 64 bit (AMD64)] 05/24 15:07:57 - mmengine - INFO - CUDA available: True 05/24 15:07:57 - mmengine - INFO - MUSA available: False 05/24 15:07:57 - mmengine - INFO - numpy_random_seed: 2147483648 05/24 15:07:57 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 4090 05/24 15:07:57 - mmengine - INFO - CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8 05/24 15:07:57 - mmengine - INFO - NVCC: Cuda compilation tools, release 11.8, V11.8.89 05/24 15:07:57 - mmengine - INFO - MSVC: 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.37.32824 版 05/24 15:07:57 - mmengine - INFO - GCC: n/a 05/24 15:07:57 - mmengine - INFO - PyTorch: 2.3.0+cu118 05/24 15:07:57 - mmengine - INFO - PyTorch compiling details: PyTorch built with:
05/24 15:07:57 - mmengine - INFO - TorchVision: 0.18.0+cu118 05/24 15:07:57 - mmengine - INFO - OpenCV: 4.9.0 05/24 15:07:57 - mmengine - INFO - MMEngine: 0.10.4 05/24 15:07:57 - mmengine - INFO - MMCV: 2.1.0 05/24 15:07:57 - mmengine - INFO - MMCV Compiler: MSVC 193732824 05/24 15:07:57 - mmengine - INFO - MMCV CUDA Compiler: 11.8 05/24 15:07:57 - mmengine - INFO - MMDeploy: 1.3.1+ec4abe5 05/24 15:07:57 - mmengine - INFO -
05/24 15:07:57 - mmengine - INFO - **Backend information** 05/24 15:07:57 - mmengine - INFO - tensorrt: 10.0.1 05/24 15:07:57 - mmengine - INFO - tensorrt custom ops: Available 05/24 15:07:57 - mmengine - INFO - ONNXRuntime: 1.12.0 05/24 15:07:57 - mmengine - INFO - ONNXRuntime-gpu: None 05/24 15:07:57 - mmengine - INFO - ONNXRuntime custom ops: Available 05/24 15:07:57 - mmengine - INFO - pplnn: None 05/24 15:07:57 - mmengine - INFO - ncnn: None 05/24 15:07:57 - mmengine - INFO - snpe: None 05/24 15:07:57 - mmengine - INFO - openvino: None 05/24 15:07:57 - mmengine - INFO - torchscript: 2.3.0+cu118 05/24 15:07:57 - mmengine - INFO - torchscript custom ops: NotAvailable 05/24 15:07:57 - mmengine - INFO - rknn-toolkit: None 05/24 15:07:57 - mmengine - INFO - rknn-toolkit2: None 05/24 15:07:57 - mmengine - INFO - ascend: None 05/24 15:07:57 - mmengine - INFO - coreml: None 05/24 15:07:57 - mmengine - INFO - tvm: None 05/24 15:07:57 - mmengine - INFO - vacc: None 05/24 15:07:57 - mmengine - INFO -
05/24 15:07:57 - mmengine - INFO - **Codebase information** 05/24 15:07:57 - mmengine - INFO - mmdet: 3.3.0 05/24 15:07:57 - mmengine - INFO - mmseg: None 05/24 15:07:57 - mmengine - INFO - mmpretrain: 1.2.0 05/24 15:07:57 - mmengine - INFO - mmocr: None 05/24 15:07:57 - mmengine - INFO - mmagic: None 05/24 15:07:57 - mmengine - INFO - mmdet3d: None 05/24 15:07:57 - mmengine - INFO - mmpose: None 05/24 15:07:57 - mmengine - INFO - mmrotate: None 05/24 15:07:57 - mmengine - INFO - mmaction: None 05/24 15:07:57 - mmengine - INFO - mmrazor: None 05/24 15:07:57 - mmengine - INFO - mmyolo: None
Hi, @Ultraopxt I just encountered this error too. Did u solve this problem? Hope to receive ur reply.
I think this is the tensorrt versions. Lots of things dont support 10 I think. I'm still working it out though.
Yeah, for me it was just use 8
Yeah, for me it was just use 8
Thanks for ur reply! I previouslty using tensorrt 8 instead of 10, but i got another error: TypeError: pybind11::init(): factory function returned nullptr
when i runned the following code:
def build_engine(model_file):
with trt.Builder(TRT_LOGGER) as builder, builder.create_network() as network,trt.OnnxParser(network, TRT_LOGGER) as parser:
builder.max_workspace_size = MAX_WORKSPACE_SIZE
builder.max_batch_size = MAX_BATCH_SIZE
with open(model_file, 'rb') as model:
parser.parse(model.read())
engine = builder.build_cuda_engine(network)
return engine
Have u run into this error?
@rlewkowicz can u share ur packages and version of ur virtual env? Thanks!
Do note, that I think like ultralytics and some others use paths under the hood. So like I have the cuda toolkit, and I dump cudnn, tensort all into that folder, and then just for the dlls I copy lib to bin. They just load system dlls and don't use any python specifics at all. So cudatoolkit, dump all other nvidia assets in there, add it to path, success.
Package Version
------------------------------ --------------------
absl-py 1.3.0
addict 2.4.0
aiofiles 23.2.1
albumentations 1.4.2
altair 5.3.0
annotated-types 0.7.0
anyio 4.4.0
appdirs 1.4.4
asgiref 3.8.1
asttokens 2.2.1
attr 0.3.1
attrs 23.2.0
azure-core 1.30.2
azure-storage-blob 12.20.0
backcall 0.2.0
beautifulsoup4 4.12.3
bleach 5.0.1
boto 2.49.0
boto3 1.34.142
botocore 1.34.142
boxing 0.1.4
cachetools 5.2.0
certifi 2024.2.2
cffi 1.16.0
charset-normalizer 3.3.2
click 8.1.7
colorama 0.4.6
coloredlogs 15.0.1
contourpy 1.2.0
cryptography 42.0.8
cycler 0.12.1
decorator 5.1.1
defusedxml 0.7.1
distro 1.9.0
Django 3.2.25
django-annoying 0.10.6
django-cors-headers 3.6.0
django-csp 3.7
django-debug-toolbar 3.2.1
django-environ 0.10.0
django-extensions 3.1.0
django-filter 2.4.0
django-model-utils 4.1.1
django-ranged-fileresponse 0.1.2
django-rq 2.5.1
django-storages 1.12.3
django-user-agents 0.4.0
djangorestframework 3.13.1
drf-dynamic-fields 0.3.0
drf-flex-fields 0.9.5
drf-generators 0.3.0
ecal5 5.11.1
exceptiongroup 1.2.1
executing 1.2.0
expiringdict 1.2.2
fastapi 0.112.0
ffmpy 0.4.0
filelock 3.13.1
flatbuffers 24.3.25
fonttools 4.49.0
fsspec 2024.2.0
gdown 5.2.0
gitdb 4.0.10
GitPython 3.1.30
google-api-core 2.19.1
google-auth 2.32.0
google-auth-oauthlib 0.4.6
google-cloud-appengine-logging 1.4.4
google-cloud-audit-log 0.2.5
google-cloud-core 2.4.1
google-cloud-logging 3.10.0
google-cloud-storage 2.17.0
google-crc32c 1.5.0
google-resumable-media 2.7.1
googleapis-common-protos 1.63.2
gradio 4.31.5
gradio_client 0.16.4
grpc-google-iam-v1 0.13.1
grpcio 1.64.1
grpcio-status 1.62.2
h11 0.14.0
htmlmin 0.1.12
httpcore 1.0.5
httpx 0.27.0
huggingface-hub 0.23.2
humanfriendly 10.0
humansignal-drf-yasg 1.21.9
idna 3.6
ijson 3.2.3
imageio 2.34.0
imgviz 1.7.5
importlib_resources 6.4.0
inflection 0.5.1
ipython 8.8.0
isodate 0.6.1
jedi 0.18.2
Jinja2 3.1.3
jmespath 1.0.1
joblib 1.3.2
jsonschema 3.2.0
kiwisolver 1.4.5
label-studio 1.12.1
label-studio-converter 0.0.58
label-studio-tools 0.0.4
labelme 5.4.1
launchdarkly-server-sdk 8.2.1
lazy_loader 0.3
lockfile 0.12.2
lxml 5.2.2
Markdown 3.4.1
markdown-it-py 3.0.0
MarkupSafe 2.1.5
matplotlib 3.8.3
matplotlib-inline 0.1.6
mdurl 0.1.2
mpmath 1.3.0
natsort 8.4.0
networkx 3.2.1
nltk 3.6.7
numpy 1.26.4
oauthlib 3.2.2
onnx 1.14.0
onnx-simplifier 0.4.36
onnxruntime 1.15.1
onnxruntime-gpu 1.18.0
onnxsim 0.4.36
onnxslim 0.1.31
openai 1.35.12
opencv-python 4.9.0.80
opencv-python-headless 4.9.0.80
ordered-set 4.0.2
orjson 3.10.6
packaging 23.2
pandas 2.2.1
parso 0.8.3
pickleshare 0.7.5
Pillow 9.5.0
pip 22.3.1
prompt-toolkit 3.0.36
proto-plus 1.24.0
protobuf 3.20.3
psutil 5.9.8
psycopg2-binary 2.9.9
pure-eval 0.2.2
py-cpuinfo 9.0.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycocotools 2.0.7
pycparser 2.22
pydantic 2.8.2
pydantic_core 2.20.1
pydub 0.25.1
Pygments 2.14.0
pyparsing 3.1.2
PyQt5 5.15.10
PyQt5-Qt5 5.15.2
PyQt5-sip 12.13.0
pyreadline3 3.4.1
pyRFC3339 1.1
pyrsistent 0.20.0
PySocks 1.7.1
python-dateutil 2.9.0.post0
python-json-logger 2.0.4
python-multipart 0.0.9
pytz 2022.7.1
PyYAML 6.0.1
QtPy 2.4.1
rapidfuzz 3.5.2
redis 3.5.3
regex 2024.5.15
requests 2.31.0
requests-oauthlib 1.3.1
rich 13.7.1
rq 1.10.1
rsa 4.9
ruff 0.5.6
rules 2.2
s3transfer 0.10.2
safetensors 0.4.3
scikit-image 0.22.0
scikit-learn 1.4.1.post1
scipy 1.13.0
screen-ocr 0.5.0
seaborn 0.13.2
semantic-version 2.10.0
semver 3.0.2
sentry-sdk 2.8.0
setuptools 65.5.0
shellingham 1.5.4
six 1.16.0
smmap 5.0.0
sniffio 1.3.1
soupsieve 2.5
sqlparse 0.5.0
stack-data 0.6.2
starlette 0.37.2
sympy 1.12
tensorboard 2.11.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
tensorrt 8.5.2.2
termcolor 2.4.0
thop 0.1.1.post2209072238
threadpoolctl 3.4.0
tifffile 2024.2.12
tomlkit 0.12.0
toolz 0.12.1
torch 2.1.2+cu118
torchaudio 2.1.2+cu118
torchvision 0.16.2+cu118
tqdm 4.66.2
traitlets 5.8.0
typer 0.12.3
typing_extensions 4.10.0
tzdata 2024.1
ua-parser 0.18.0
ujson 5.10.0
ultralytics 8.1.34
uritemplate 4.1.1
urllib3 2.2.2
user-agents 2.2.0
uvicorn 0.30.5
wcwidth 0.2.5
webencodings 0.5.1
websockets 11.0.3
Werkzeug 2.2.2
wheel 0.38.4
windows-capture 1.0.51
winsdk 1.0.0b10
xmljson 0.2.0
@Jellie122 ^^
@rlewkowicz OMG!!!! It works, thank u very much! I've been stuck on this error for a week! And i can't find the solutions from issures. (tear of joy.jpg)
@rlewkowicz OMG!!!! It works, thank u very much! I've been stuck on this error for a week! And i can't find the solutions from issures. (tear of joy.jpg)
The esoteric dependency management is the hardest part LOL. Windows is so hard to work on too. If you can I find linux easier my self for most stuff.
Yeah, i think so too. Many packages only work on linux, and many bugs only show up on windows. Most of people use linux for development. There are few references.
@rlewkowicz Anyway, thank u for ur help! :)
Hi,I just encountered this error too. Did u solve this problem? Hope to receive ur reply.
Hi,I just encountered this error too. Did u solve this problem? Hope to receive ur reply.
Yes. You can refer to our conversation above. Make sure ur DLLs are copied into bin.
Thanks for ur reply! Do you mean copying the Dlls from mmdeploy/lib into the CUDA bin?I tried but it failed
Thanks for ur reply! Do you mean copying the Dlls from mmdeploy/lib into the CUDA bin?I tried but it failed
The error i encountered earlier was that it couldn't find dlls concerning tensorRT, so i copied dlls from tensorRT lib to CUDA bin. Maybe u should find out what dlls it need but can't find.
Checklist
Describe the bug
When I converted the model to tensorRT based on the official documentation, some errors occurred. System has prompt “Could not find module 'mmdeploy_tensorrt_ops.dll' ”.
The link to the official document is as follows: https://mmdeploy.readthedocs.io/zh-cn/latest/02-how-to-run/prebuilt_package_windows.html#tensorrt
Have you ever had similar problems before, or do you have any relevant suggestions? Please let me know, thanks a lot.
Reproduction
from mmdeploy.apis import torch2onnx from mmdeploy.apis.tensorrt import onnx2tensorrt from mmdeploy.backend.sdk.export_info import export2SDK import os
img = 'mmpretrain/demo/demo.JPEG' work_dir = 'trt/resnet' save_file = 'end2end.onnx' deploy_cfg = 'mmdeploy/configs/mmpretrain/classification_tensorrt_static-224x224.py' model_cfg = 'mmpretrain/configs/resnet/resnet18_8xb32_in1k.py' model_checkpoint = 'resnet18_8xb32_in1k_20210831-fbbb1da6.pth' device = 'cuda:0'
torch2onnx(img, work_dir, save_file, deploy_cfg, model_cfg, model_checkpoint, device)
onnx_model = os.path.join(work_dir, save_file) save_file = 'end2end.engine' model_id = 0 device = 'cuda:0' onnx2tensorrt(work_dir, save_file, model_id, deploy_cfg, onnx_model, device)
export2SDK(deploy_cfg, model_cfg, work_dir, pth=model_checkpoint, device=device)
Environment
Error traceback