【torch加速】python onnx to tensorRT报错NotImplementedError: Converting dtype(‘float16‘) to a ctypes type

在进行torch加速时,使用了torch-onnx-torch的思路,当前阶段已成功生成tensorrt engine,但是在使用tensor RT engine进行推理的过程中遇到了该报错:NotImplementedError: Converting dtype(‘float16’) to a ctypes type


推理实现过程参考的tensorRT github项目的example中的yolov3-https://github.com/NVIDIA/TensorRT/tree/release/8.6/samples/python/yolov3_onnx

报错是出现在common文件的HostDeviceMem函数中,意思是float16类型在ctype中没有定义,解决方式见TensorRT issue #3222

I made a workaround :

 1. Initialize np.ndarray from int16 ctypes point 
 2. use arr.dtype = np.float16 to change dtype inplace.

其意思就是既然ctype没有该类型,就在开辟内存时用int16类型来代替float16,因为他们占用的内存大小是一样的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值