TensorRT trtexec 学习笔记

  • trtexec 实现onnx转tensorrt
./trtexec --onnx=test.onnx --saveEngine=test.gie --verbose --dumpLayerInfo --dumpOutput --dumpProfile

其中

--verbose 打印log

--dumpLayerInfo将每个layer的信息都打印出来

--dumpOutput将每个输出都打印到终端上来

--dumpProfile打印一些中间分析信息,比如每层的 执行时间

  • trtexec使用GIE进行推理
./my_trtexec --loadEngine=model_fp16.gie --fp16 --loadInputs=input:input_tensor.bin --exportOutput=output.json

其中
--loadEngine 加载已经转化好的plan文件
--fp16 表示半精度
--loadInputs 可以加载输入数据

    input:input_tensor.bin, 
    input是网络的输入名字,根据自己的网络进行修改
    input_tensor.bin是自己生成好的输入,比如将图像数据转换成float之后,存成文件

--exportOutput 将网络所有的输出保存成output.json文件

  • trtexec 转换DynamicShpaes的ONNX
trtexec --onnx=my_model.onnx --saveEngine=my_model_fp16.trt --minShapes=input:1x3x320x320 --optShapes=input:1x3x640x640 --maxShapes=input:1x3x1280x1280 --fp16

其中
input:1x3x320x320, input是输入tensor的名字
--minShapes 是指输入“input"的最小尺寸
--optShapes 是当前输入的实际大小
--maxShapes 是指输入”input"的最大尺寸
--fp16 推理引擎的精度
官方解释:

  --minShapes=spec            Build with dynamic shapes using a profile with the min shapes provided
  --optShapes=spec            Build with dynamic shapes using a profile with the opt shapes provided
  --maxShapes=spec            Build with dynamic shapes using a profile with the max shapes provided
  --minShapesCalib=spec       Calibrate with dynamic shapes using a profile with the min shapes provided
  --optShapesCalib=spec       Calibrate with dynamic shapes using a profile with the opt shapes provided
  --maxShapesCalib=spec       Calibrate with dynamic shapes using a profile with the max shapes provided
                              Note: All three of min, opt and max shapes must be supplied.
                                    However, if only opt shapes is supplied then it will be expanded so
                                    that min shapes and max shapes are set to the same values as opt shapes.
                                    Input names can be wrapped with escaped single quotes (ex: \'Input:0\').
                              Example input shapes spec: input0:1x3x256x256,input1:1x3x128x128
                              Each input shape is supplied as a key-value pair where key is the input name and
                              value is the dimensions (including the batch dimension) to be used for that input.
                              Each key-value pair has the key and value separated using a colon (:).
                              Multiple input shapes can be provided via comma-separated key-value pairs.

  • trtexec动态加载自定义插件
trtexec --onnx=my_model.onnx --plugins=build/my_plugin.so --saveEngine=my_model.engine

其中
--plugins 指定我们自定义插件动态库文件名
官方解释
--plugins                   Plugin library (.so) to load (can be specified multiple times)

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值