本文主要是介绍onnx模型转trt模型报错TensorRT was linked against cuDNN 8.4.1 but loaded cuDNN 8.2.1,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
具体报错:Results saved to D:\todesk\yolov8model
Predict: yolo predict task=detect model=yolov8s.onnx imgsz=640
Validate: yolo val task=detect model=yolov8s.onnx imgsz=640 data=coco.yaml
Visualize: https://netron.app
(yolov8) PS D:\todesk\yolov8model> D:\1\TensorRT_YOLO\TensorRT-8.4.2.4\bin\trtexec.exe --onnx=yolov8s.onnx --saveEngine=yolov8s.trt --buildOnly --minShapes=images:1x3x640x640 --optShapes=images:4x3x640x640 --maxShapes=images:8x3x640x640
&&&& RUNNING TensorRT.trtexec [TensorRT v8402] # D:\1\TensorRT_YOLO\TensorRT-8.4.2.4\bin\trtexec.exe --onnx=yolov8s.onnx --saveEngine=yolov8s.trt --buildOnly --minShapes=images:1x3x640x640 --optShapes=images:4x3x640x640 --maxShapes=images:8x3x640x640
[05/24/2023-16:33:33] [I] === Model Options ===
[05/24/2023-16:33:33] [I] Format: ONNX
[05/24/2023-16:33:33] [I] Model: yolov8s.onnx
[05/24/2023-16:33:33] [I] Output:
[05/24/2023-16:33:33] [I] === Build Options ===
[05/24/2023-16:33:33] [I] Max batch: explicit batch
[05/24/2023-16:33:33] [I] Memory Pools: workspace: default, dlaSRAM: default, dlaLocalDRAM: default, dlaGlobalDRAM: default
[05/24/2023-16:33:33] [I] minTiming: 1
[05/24/2023-16:33:33] [I] avgTiming: 8
[05/24/2023-16:33:33] [I] Precision: FP32
[05/24/2023-16:33:33] [I] LayerPrecisions:
[05/24/2023-16:33:33] [I] Calibration:
[05/24/2023-16:33:33] [I] Refit: Disabled
[05/24/2023-16:33:33] [I] Sparsity: Disabled
[05/24/2023-16:33:33] [I] Safe mode: Disabled
[05/24/2023-16:33:33] [I] DirectIO mode: Disabled
[05/24/2023-16:33:33] [I] Restricted mode: Disabled
[05/24/2023-16:33:33] [I] Build only: Enabled
[05/24/2023-16:33:33] [I] Save engine: yolov8s.trt
[05/24/2023-16:33:33] [I] Load engine:
[05/24/2023-16:33:33] [I] Profiling verbosity: 0
[05/24/2023-16:33:33] [I] Tactic sources: Using default tactic sources
[05/24/2023-16:33:33] [I] timingCacheMode: local
[05/24/2023-16:33:33] [I] timingCacheFile:
[05/24/2023-16:33:33] [I] Input(s)s format: fp32:CHW
[05/24/2023-16:33:33] [I] Output(s)s format: fp32:CHW
[05/24/2023-16:33:33] [I] Input build shape: images=1x3x640x640+4x3x640x640+8x3x640x640
[05/24/2023-16:33:33] [I] Input calibration shapes: model
[05/24/2023-16:33:33] [I] === System Options ===
[05/24/2023-16:33:33] [I] Device: 0
[05/24/2023-16:33:33] [I] DLACore:
[05/24/2023-16:33:33] [I] Plugins:
[05/24/2023-16:33:33] [I] === Inference Options ===
[05/24/2023-16:33:33] [I] Batch: Explicit
[05/24/2023-16:33:33] [I] Input inference shape: images=4x3x640x640
[05/24/2023-16:33:33] [I] Iterations: 10
[05/24/2023-16:33:33] [I] Duration: 3s (+ 200ms warm up)
[05/24/2023-16:33:33] [I] Sleep time: 0ms
[05/24/2023-16:33:33] [I] Idle time: 0ms
[05/24/2023-16:33:33] [I] Streams: 1
[05/24/2023-16:33:33] [I] ExposeDMA: Disabled
[05/24/2023-16:33:33] [I] Data transfers: Enabled
[05/24/2023-16:33:33] [I] Spin-wait: Disabled
[05/24/2023-16:33:33] [I] Multithreading: Disabled
[05/24/2023-16:33:33] [I] CUDA Graph: Disabled
[05/24/2023-16:33:33] [I] Separate profiling: Disabled
[05/24/2023-16:33:33] [I] Time Deserialize: Disabled
[05/24/2023-16:33:33] [I] Time Refit: Disabled
[05/24/2023-16:33:33] [I] Inputs:
[05/24/2023-16:33:33] [I] === Reporting Options ===
[05/24/2023-16:33:33] [I] Verbose: Disabled
[05/24/2023-16:33:33] [I] Averages: 10 inferences
[05/24/2023-16:33:33] [I] Percentile: 99
[05/24/2023-16:33:33] [I] Dump refittable layers:Disabled
[05/24/2023-16:33:33] [I] Dump output: Disabled
[05/24/2023-16:33:33] [I] Profile: Disabled
[05/24/2023-16:33:33] [I] Export timing to JSON file:
[05/24/2023-16:33:33] [I] Export output to JSON file:
[05/24/2023-16:33:33] [I] Export profile to JSON file:
[05/24/2023-16:33:33] [I]
[05/24/2023-16:33:33] [I] === Device Information ===
[05/24/2023-16:33:33] [I] Selected Device: NVIDIA GeForce RTX 4080
[05/24/2023-16:33:33] [I] Compute Capability: 8.9
[05/24/2023-16:33:33] [I] SMs: 76
[05/24/2023-16:33:33] [I] Compute Clock Rate: 2.535 GHz
[05/24/2023-16:33:33] [I] Device Global Memory: 16375 MiB
[05/24/2023-16:33:33] [I] Shared Memory per SM: 100 KiB
[05/24/2023-16:33:33] [I] Memory Bus Width: 256 bits (ECC disabled)
[05/24/2023-16:33:33] [I] Memory Clock Rate: 11.201 GHz
[05/24/2023-16:33:33] [I]
[05/24/2023-16:33:33] [I] TensorRT version: 8.4.2
[05/24/2023-16:33:34] [I] [TRT] [MemUsageChange] Init CUDA: CPU +489, GPU +0, now: CPU 13900, GPU 1491 (MiB)
[05/24/2023-16:33:34] [I] [TRT] [MemUsageChange] Init builder kernel library: CPU +378, GPU +104, now: CPU 14465, GPU 1595 (MiB)
[05/24/2023-16:33:34] [I] Start parsing network model
[05/24/2023-16:33:35] [I] [TRT] ----------------------------------------------------------------
[05/24/2023-16:33:35] [I] [TRT] Input filename: yolov8s.onnx
[05/24/2023-16:33:35] [I] [TRT] ONNX IR version: 0.0.8
[05/24/2023-16:33:35] [I] [TRT] Opset version: 17
[05/24/2023-16:33:35] [I] [TRT] Producer name: pytorch
[05/24/2023-16:33:35] [I] [TRT] Producer version: 2.0.1
[05/24/2023-16:33:35] [I] [TRT] Domain:
[05/24/2023-16:33:35] [I] [TRT] Model version: 0
[05/24/2023-16:33:35] [I] [TRT] Doc string:
[05/24/2023-16:33:35] [I] [TRT] ----------------------------------------------------------------
[05/24/2023-16:33:35] [W] [TRT] onnx2trt_utils.cpp:369: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[05/24/2023-16:33:35] [I] Finish parsing network model
[05/24/2023-16:33:35] [I] [TRT] [MemUsageChange] Init cuBLAS/cuBLASLt: CPU +759, GPU +272, now: CPU 15167, GPU 1867 (MiB)
[05/24/2023-16:33:36] [I] [TRT] [MemUsageChange] Init cuDNN: CPU +387, GPU +264, now: CPU 15554, GPU 2131 (MiB)
[05/24/2023-16:33:36] [W] [TRT] TensorRT was linked against cuDNN 8.4.1 but loaded cuDNN 8.2.1
[05/24/2023-16:33:36] [I] [TRT] Local timing cache in use. Profiling results in this builder pass will not be stored.
Unexpected Internal Error: [virtualMemoryBuffer.cpp::nvinfer1::StdVirtualMemoryBufferImpl::~StdVirtualMemoryBufferImpl::104] Error Code 1: Cuda Runtime (driver shutting down)
参考这篇博客
(16条消息) 【TensorRT】TensorRT was linked against cudnn 8.6.0 but loaded cudnn 8.3.2_半路转行的水博的博客-CSDN博客https://blog.csdn.net/sanxiaw/article/details/128017373
于是去cuDNN Archive | NVIDIA 开发者https://developer.nvidia.cn/rdp/cudnn-archive
下载cudnn8.4.1版本的cudnn(具体名称为cudnn-windows-x86_64-8.4.1.50_cuda11.6-archive.zip)
中间还报错抛出异常——Could not locate zlibwapi.dll. Please make sure it is in your library p
参考如下这两篇解决这个zlibwapi.dll的报错。(16条消息) Could not locate zlibwapi.dll. Please make sure it is in your library path_zlibwapi.dll无法注册_Chaos_Happy的博客-CSDN博客https://blog.csdn.net/Chaos_Happy/article/details/124064428Installation Guide - NVIDIA Docshttps://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#install-zlib-windows
最后成功输出了:
(yolov8) PS D:\todesk\yolov8model> D:\1\TensorRT_YOLO\TensorRT-8.4.2.4\bin\trtexec.exe --onnx=yolov8s.onnx --saveEngine=yolov8s.trt --buildOnly --minShapes=images:1x3x640x640 --optShapes=images:4x3x640x640 --maxShapes=images:8x3x640x640
&&&& RUNNING TensorRT.trtexec [TensorRT v8402] # D:\1\TensorRT_YOLO\TensorRT-8.4.2.4\bin\trtexec.exe --onnx=yolov8s.onnx --saveEngine=yolov8s.trt --buildOnly --minShapes=images:1x3x640x640 --optShapes=images:4x3x640x640 --maxShapes=images:8x3x640x640
[05/24/2023-16:56:08] [I] === Model Options ===
[05/24/2023-16:56:08] [I] Format: ONNX
[05/24/2023-16:56:08] [I] Model: yolov8s.onnx
[05/24/2023-16:56:08] [I] Output:
[05/24/2023-16:56:08] [I] === Build Options ===
[05/24/2023-16:56:08] [I] Max batch: explicit batch
[05/24/2023-16:56:08] [I] Memory Pools: workspace: default, dlaSRAM: default, dlaLocalDRAM: default, dlaGlobalDRAM: default
[05/24/2023-16:56:08] [I] minTiming: 1
[05/24/2023-16:56:08] [I] avgTiming: 8
[05/24/2023-16:56:08] [I] Precision: FP32
[05/24/2023-16:56:08] [I] LayerPrecisions:
[05/24/2023-16:56:08] [I] Calibration:
[05/24/2023-16:56:08] [I] Refit: Disabled
[05/24/2023-16:56:08] [I] Sparsity: Disabled
[05/24/2023-16:56:08] [I] Safe mode: Disabled
[05/24/2023-16:56:08] [I] DirectIO mode: Disabled
[05/24/2023-16:56:08] [I] Restricted mode: Disabled
[05/24/2023-16:56:08] [I] Build only: Enabled
[05/24/2023-16:56:08] [I] Save engine: yolov8s.trt
[05/24/2023-16:56:08] [I] Load engine:
[05/24/2023-16:56:08] [I] Profiling verbosity: 0
[05/24/2023-16:56:08] [I] Tactic sources: Using default tactic sources
[05/24/2023-16:56:08] [I] timingCacheMode: local
[05/24/2023-16:56:08] [I] timingCacheFile:
[05/24/2023-16:56:08] [I] Input(s)s format: fp32:CHW
[05/24/2023-16:56:08] [I] Output(s)s format: fp32:CHW
[05/24/2023-16:56:08] [I] Input build shape: images=1x3x640x640+4x3x640x640+8x3x640x640
[05/24/2023-16:56:08] [I] Input calibration shapes: model
[05/24/2023-16:56:08] [I] === System Options ===
[05/24/2023-16:56:08] [I] Device: 0
[05/24/2023-16:56:08] [I] DLACore:
[05/24/2023-16:56:08] [I] Plugins:
[05/24/2023-16:56:08] [I] === Inference Options ===
[05/24/2023-16:56:08] [I] Batch: Explicit
[05/24/2023-16:56:08] [I] Input inference shape: images=4x3x640x640
[05/24/2023-16:56:08] [I] Iterations: 10
[05/24/2023-16:56:08] [I] Duration: 3s (+ 200ms warm up)
[05/24/2023-16:56:08] [I] Sleep time: 0ms
[05/24/2023-16:56:08] [I] Idle time: 0ms
[05/24/2023-16:56:08] [I] Streams: 1
[05/24/2023-16:56:08] [I] ExposeDMA: Disabled
[05/24/2023-16:56:08] [I] Data transfers: Enabled
[05/24/2023-16:56:08] [I] Spin-wait: Disabled
[05/24/2023-16:56:08] [I] Multithreading: Disabled
[05/24/2023-16:56:08] [I] CUDA Graph: Disabled
[05/24/2023-16:56:08] [I] Separate profiling: Disabled
[05/24/2023-16:56:08] [I] Time Deserialize: Disabled
[05/24/2023-16:56:08] [I] Time Refit: Disabled
[05/24/2023-16:56:08] [I] Inputs:
[05/24/2023-16:56:08] [I] === Reporting Options ===
[05/24/2023-16:56:08] [I] Verbose: Disabled
[05/24/2023-16:56:08] [I] Averages: 10 inferences
[05/24/2023-16:56:08] [I] Percentile: 99
[05/24/2023-16:56:08] [I] Dump refittable layers:Disabled
[05/24/2023-16:56:08] [I] Dump output: Disabled
[05/24/2023-16:56:08] [I] Profile: Disabled
[05/24/2023-16:56:08] [I] Export timing to JSON file:
[05/24/2023-16:56:08] [I] Export output to JSON file:
[05/24/2023-16:56:08] [I] Export profile to JSON file:
[05/24/2023-16:56:08] [I]
[05/24/2023-16:56:08] [I] === Device Information ===
[05/24/2023-16:56:08] [I] Selected Device: NVIDIA GeForce RTX 4080
[05/24/2023-16:56:08] [I] Compute Capability: 8.9
[05/24/2023-16:56:08] [I] SMs: 76
[05/24/2023-16:56:08] [I] Compute Clock Rate: 2.535 GHz
[05/24/2023-16:56:08] [I] Device Global Memory: 16375 MiB
[05/24/2023-16:56:08] [I] Shared Memory per SM: 100 KiB
[05/24/2023-16:56:08] [I] Memory Bus Width: 256 bits (ECC disabled)
[05/24/2023-16:56:08] [I] Memory Clock Rate: 11.201 GHz
[05/24/2023-16:56:08] [I]
[05/24/2023-16:56:08] [I] TensorRT version: 8.4.2
[05/24/2023-16:56:08] [I] [TRT] [MemUsageChange] Init CUDA: CPU +483, GPU +0, now: CPU 12059, GPU 1491 (MiB)
[05/24/2023-16:56:09] [I] [TRT] [MemUsageChange] Init builder kernel library: CPU +377, GPU +104, now: CPU 12626, GPU 1595 (MiB)
[05/24/2023-16:56:09] [I] Start parsing network model
[05/24/2023-16:56:09] [I] [TRT] ----------------------------------------------------------------
[05/24/2023-16:56:09] [I] [TRT] Input filename: yolov8s.onnx
[05/24/2023-16:56:09] [I] [TRT] ONNX IR version: 0.0.8
[05/24/2023-16:56:09] [I] [TRT] Opset version: 17
[05/24/2023-16:56:09] [I] [TRT] Producer name: pytorch
[05/24/2023-16:56:09] [I] [TRT] Producer version: 2.0.1
[05/24/2023-16:56:09] [I] [TRT] Domain:
[05/24/2023-16:56:09] [I] [TRT] Model version: 0
[05/24/2023-16:56:09] [I] [TRT] Doc string:
[05/24/2023-16:56:09] [I] [TRT] ----------------------------------------------------------------
[05/24/2023-16:56:09] [W] [TRT] onnx2trt_utils.cpp:369: Your ONNX model has been generated with INT64 weights, while TensorRT does not natively support INT64. Attempting to cast down to INT32.
[05/24/2023-16:56:09] [I] Finish parsing network model
[05/24/2023-16:56:09] [I] [TRT] [MemUsageChange] Init cuBLAS/cuBLASLt: CPU +759, GPU +272, now: CPU 13318, GPU 1867 (MiB)
[05/24/2023-16:56:10] [I] [TRT] [MemUsageChange] Init cuDNN: CPU +164, GPU +56, now: CPU 13482, GPU 1923 (MiB)
[05/24/2023-16:56:10] [I] [TRT] Local timing cache in use. Profiling results in this builder pass will not be stored.
[05/24/2023-16:57:28] [I] [TRT] Detected 1 inputs and 3 output network tensors.
[05/24/2023-16:57:28] [I] [TRT] Total Host Persistent Memory: 154464
[05/24/2023-16:57:28] [I] [TRT] Total Device Persistent Memory: 1202688
[05/24/2023-16:57:28] [I] [TRT] Total Scratch Memory: 0
[05/24/2023-16:57:28] [I] [TRT] [MemUsageStats] Peak memory usage of TRT CPU/GPU memory allocators: CPU 15 MiB, GPU 6734 MiB
[05/24/2023-16:57:28] [I] [TRT] [BlockAssignment] Algorithm ShiftNTopDown took 114.958ms to assign 16 blocks to 223 nodes requiring 272035344 bytes.
[05/24/2023-16:57:28] [I] [TRT] Total Activation Memory: 272035344
[05/24/2023-16:57:28] [I] [TRT] [MemUsageChange] TensorRT-managed allocation in building engine: CPU +6, GPU +51, now: CPU 6, GPU 51 (MiB)
[05/24/2023-16:57:28] [W] [TRT] The getMaxBatchSize() function should not be used with an engine built from a network created with NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag. This function will always return 1.
[05/24/2023-16:57:28] [W] [TRT] The getMaxBatchSize() function should not be used with an engine built from a network created with NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag. This function will always return 1.
[05/24/2023-16:57:29] [I] Engine built in 81.0279 sec.
[05/24/2023-16:57:29] [I] [TRT] [MemUsageChange] Init CUDA: CPU +0, GPU +0, now: CPU 14781, GPU 2339 (MiB)
[05/24/2023-16:57:29] [I] [TRT] Loaded engine size: 51 MiB
[05/24/2023-16:57:29] [I] [TRT] [MemUsageChange] TensorRT-managed allocation in engine deserialization: CPU +0, GPU +50, now: CPU 0, GPU 50 (MiB)
[05/24/2023-16:57:29] [I] Engine deserialized in 0.0364477 sec.
[05/24/2023-16:57:29] [I] Skipped inference phase since --buildOnly is added.
&&&& PASSED TensorRT.trtexec [TensorRT v8402] # D:\1\TensorRT_YOLO\TensorRT-8.4.2.4\bin\trtexec.exe --onnx=yolov8s.onnx --saveEngine=yolov8s.trt --buildOnly --minShapes=images:1x3x640x640 --optShapes=images:4x3x640x640 --maxShapes=images:8x3x640x640
安装环境依赖于python3.9
(yolov8) PS D:\todesk\yolov8model> conda list
# packages in environment at D:\soft\conda\envs\yolov8:
#
# Name Version Build Channel
ca-certificates 2023.01.10 haa95532_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
certifi 2023.5.7 pypi_0 pypi
charset-normalizer 3.1.0 pypi_0 pypi
colorama 0.4.6 pypi_0 pypi
contourpy 1.0.7 pypi_0 pypi
cycler 0.11.0 pypi_0 pypi
filelock 3.12.0 pypi_0 pypi
fonttools 4.39.4 pypi_0 pypi
idna 3.4 pypi_0 pypi
importlib-resources 5.12.0 pypi_0 pypi
jinja2 3.1.2 pypi_0 pypi
kiwisolver 1.4.4 pypi_0 pypi
markupsafe 2.1.2 pypi_0 pypi
matplotlib 3.7.1 pypi_0 pypi
mpmath 1.3.0 pypi_0 pypi
networkx 3.1 pypi_0 pypi
numpy 1.24.3 pypi_0 pypi
onnx 1.14.0 pypi_0 pypi
opencv-python 4.7.0.72 pypi_0 pypi
openssl 1.1.1t h2bbff1b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
packaging 23.1 pypi_0 pypi
pandas 2.0.1 pypi_0 pypi
pillow 9.5.0 pypi_0 pypi
pip 23.0.1 py39haa95532_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
protobuf 4.23.1 pypi_0 pypi
psutil 5.9.5 pypi_0 pypi
pyparsing 3.0.9 pypi_0 pypi
python 3.9.16 h6244533_2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
python-dateutil 2.8.2 pypi_0 pypi
pytz 2023.3 pypi_0 pypi
pyyaml 6.0 pypi_0 pypi
requests 2.31.0 pypi_0 pypi
scipy 1.10.1 pypi_0 pypi
seaborn 0.12.2 pypi_0 pypi
sentry-sdk 1.24.0 pypi_0 pypi
setuptools 66.0.0 py39haa95532_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
six 1.16.0 pypi_0 pypi
sqlite 3.41.2 h2bbff1b_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
sympy 1.12 pypi_0 pypi
torch 2.0.1 pypi_0 pypi
torchvision 0.15.2 pypi_0 pypi
tqdm 4.65.0 pypi_0 pypi
typing-extensions 4.6.1 pypi_0 pypi
tzdata 2023.3 pypi_0 pypi
ultralytics 8.0.107 pypi_0 pypi
urllib3 1.26.16 pypi_0 pypi
vc 14.2 h21ff451_1 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
vs2015_runtime 14.27.29016 h5e58377_2 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
wheel 0.38.4 py39haa95532_0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
zipp 3.15.0 pypi_0 pypi
参考(16条消息) Win10环境下yolov8快速配置与测试_FeiYull_的博客-CSDN博客https://blog.csdn.net/m0_72734364/article/details/128815530
和这篇
(16条消息) win10下 yolov8 tensorrt模型加速部署【实战】_FeiYull_的博客-CSDN博客https://blog.csdn.net/m0_72734364/article/details/128865904?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-1-128865904-blog-129989402.235%5Ev36%5Epc_relevant_anti_vip&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2~default~CTRLIST~Rate-1-128865904-blog-129989402.235%5Ev36%5Epc_relevant_anti_vip&utm_relevant_index=2清华镜像源+英伟达pypi库
conda create -n yolov8 python=3.9 -y
conda activate yolov8
pip install ultralytics
这篇关于onnx模型转trt模型报错TensorRT was linked against cuDNN 8.4.1 but loaded cuDNN 8.2.1的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!