onnx to trt failed - RuntimeError: cannot get YoloLayer_TRT plugin creator

onnx to trt failed - RuntimeError: cannot get YoloLayer_TRT plugin creator

我正在尝试在 AWS ec2 上 运行 YoloV4(演示 5)TensorRt demos repo

我使用 nvidia-gpu(使用 AMI - Amazon Linux 2 AMI with NVIDIA TESLA GPU Driver)创建了 ec2 VM,

其中有:NVIDIA-SMI 450.119.01   Driver Version: 450.119.01   CUDA Version: 11.0.

在这个 EC2 上,我拉取并进入了 tensorrt 官方容器,其中:

sudo docker run --gpus all -it -v /home/ec2-user/player-detection:/home nvcr.io/nvidia/tensorrt:20.02-py3 bash

我做了以下步骤:

  1. 运行 python3 -m pip install --upgrade setuptools pip && python3 -m pip install nvidia-pyindex && pip install nvidia-tensorrt.
  2. yolo/ 文件夹中,我 运行: pip3 install -r requirements.txt.
  3. pip3 install onnx==1.9.0.
  4. plugins/ 文件夹中,我 运行 make.
  5. yolo/文件夹里面,我运行./download_yolo.sh&&python3 yolo_to_onnx.py -m yolov4&&python3 onnx_to_tensorrt.py -m yolov4.

python3 onnx_to_tensorrt.py -m yolov4 命令出现以下错误:

 "RuntimeError: cannot get YoloLayer_TRT plugin creator"

从阅读 https://github.com/jkjung-avt/tensorrt_demos/issues/476 看来问题与动态库有关。

我试图查看我拥有的库,并得到:

$ ldd libyolo_layer.so 
    linux-vdso.so.1 (0x00007fff142a4000)
    libnvinfer.so.7 => /usr/lib/x86_64-linux-gnu/libnvinfer.so.7 (0x00007f9673734000)
    libcudart.so.11.0 => /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudart.so.11.0 (0x00007f96734af000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9673126000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9672f0e000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9672b1d000)
    libcudnn.so.8 => /usr/lib/x86_64-linux-gnu/libcudnn.so.8 (0x00007f96728f4000)
    libmyelin.so.1 => /usr/lib/x86_64-linux-gnu/libmyelin.so.1 (0x00007f9672074000)
    libnvrtc.so.11.1 => /usr/local/cuda-11.1/targets/x86_64-linux/lib/libnvrtc.so.11.1 (0x00007f966feac000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f966fca4000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f966faa0000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f966f702000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f9699135000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f966f4e3000)
    libcublas.so.11 => /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcublas.so.11 (0x00007f9668008000)
    libcublasLt.so.11 => /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcublasLt.so.11 (0x00007f965a23e000)

好像漏掉了一些,而且当我尝试打印所有插件时,我没有看到YoloLayer_TRT

知道如何解决吗?

您是否使用 ctypes 模块加载了 libyolo_layer.so?好像YoloLayer_TRT是yolo团队自定义的插件,在python.

中使用需要加载库文件

https://github.com/jkjung-avt/tensorrt_demos/issues/476#issuecomment-935225260

解决方案是:

  1. 将图像标签更改为 :21.10-py3(感谢 Hyunwoo Kim!)。
  2. TENSORRT_INCS 更改为 /usr/include/x86_64-linux-gnu/NvInfer*,将 TENSORRT_LIBS 更改为 /usr/lib/x86_64-linux-gnu/libnvinfer*
  3. 将计算更改为 70(在我的环境中)- 您可以检查您的版本 here