当前位置:网站首页>The onnx model is exported as a TRT model
The onnx model is exported as a TRT model
2022-07-25 20:50:00 【Master Fuwen】
linux Similar environment , This article aims at Windows Environmental Science
Configure it according to this article TensorRT Environment :
TensorRT windows10 Installation process record
Method 1 : Code conversion
It can be used directly TensorRT Python API Medium onnx Parser To read and serialize the model and save
however , In the process , In fact, it has been built , Or just say , Namely build The process , So we need to convert the accuracy to TF32、FP32 perhaps INT8, It needs to be done before saving .
Before conversion , First, check whether your platform supports the corresponding accuracy :
Or according to your graphics card model , Check your... Here
CUDA Computing power version—> CUDA Calculation capacity table , Then according to this version , To check whether the corresponding precision is supported --> Precision mode supported by hardware
for instance , I am a GTX1650Ti The graphics card :
The computing power is 7.5, Then look up this table :
You can see , This version of the card does not support TF32 and DLAor , according to Of this blog API To create a builder, Then use these three API Let's see if the corresponding precision is supported :
import tensorrt as trt
logger = trt.Logger(trt.Logger.WARNING)
builder = trt.Builder(logger)
>>> builder.platform_has_fast_fp16
True
>>> builder.platform_has_fast_int8
True
>>> builder.platform_has_tf32
False
Above is GTX 1650Ti Final accuracy support
Know the accuracy support , Next , According to the content of this blog :Python API analysis In the first part of
In the process of transformation , How to specify precision , You can refer to this blog :
https://blog.csdn.net/HaoZiHuang/article/details/125830788
A little hint , If you don't know Config Where is the object , He is in builder It is instantiated only after it has been created :
config = builder.create_builder_config()
forehead , Still refer to this article Python API analysis
Method 2 : Command line conversion
I still remember in this article Blog Mentioned in trtexec Do you
Command line conversion , It's not so fancy :
trtexec --onnx=output.onnx --saveEngine=outfp32.engine --workspace=2048 --minShapes=x:1x3x224x224 --optShapes=x:1x3x224x224 --maxShapes=x:1x3x224x224
trtexec --onnx=output.onnx --saveEngine=outfp16.engine --workspace=2048 --minShapes=x:1x3x224x224 --optShapes=x:1x3x224x224 --maxShapes=x:1x3x224x224 --fp16
trtexec --onnx=output.onnx --saveEngine=outfpi8.engine --workspace=2048 --minShapes=x:1x3x224x224 --optShapes=x:1x3x224x224 --maxShapes=x:1x3x224x224 --int8
trtexec --onnx=output.onnx --saveEngine=outfpbest.engine --workspace=2048 --minShapes=x:1x3x224x224 --optShapes=x:1x3x224x224 --maxShapes=x:1x3x224x224 --best
There are 4 That's ok , Namely fp32、fp16、int8 and The best strategy
the last one --best , Generally, no brain chooses this OK 了 ,TensorRT Our algorithm will automatically find the fastest
But in fact , You didn't specify --int8 He must be int8 Of , Only the preference is --int8, For details, please refer to this introduction about accuracy :TensorRT in Reduced Precision, If you don't understand it, read the original English …
A little bit about other parameters :
--onnx=output.onnx # To be transformed onnx Model
--saveEngine=outfp32.engine # Output position
--workspace=2048 # Set the workspace size , The unit is MB
--minShapes=x:1x3x224x224 # This is the minimum input to calibrate the model , The input tensor name is `x`
--optShapes=x:1x3x224x224
--maxShapes=x:1x3x224x224
Actually , I don't know how to translate these three below ,hxd Make do with it :
--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
Mainly the first few parameters , The last few are not important hh
边栏推荐
- matlab----EEGLab查看脑电信号
- Remote - basic principle introduction
- Follow up of Arlo's thinking
- [FAQ] access the HMS core push service, and the server sends messages. Cause analysis and solutions of common error codes
- [workplace rules] it workplace rules | poor performance
- process.env
- The international summit osdi included Taobao system papers for the first time, and end cloud collaborative intelligence was recommended by the keynote speech of the conference
- Fanoutexchange switch code tutorial
- JS scope and scope chain
- leetcode-919:完全二叉树插入器
猜你喜欢

Has baozi ever played in the multi merchant system?

Illustration leetcode - 3. longest substring without repeated characters (difficulty: medium)

If the order is not paid for 30 minutes, it will be automatically cancelled. How to achieve this? (Collection Edition)

ROS_ Rqt toolbox

Mobile web layout method

Chinese son-in-law OTA Ono became the first Asian president of the University of Michigan, with an annual salary of more than 6.5 million!

基于腾讯地图实现精准定位,实现微信小程序考勤打卡功能

Opencv learning Fourier transform experience and line direction Fourier transform code

Solution to oom exceptions caused by improper use of multithreading in production environment (supreme Collection Edition)

两数,三数之和
随机推荐
Illustration leetcode - 3. longest substring without repeated characters (difficulty: medium)
Use of C log4net: add file name and line number to the output log content; Repackaged class output file name and line number
Temperature and humidity environment monitoring system based on stm32
Huatai Securities account opening process, is it safe to open an account on your mobile phone
Force deduction ----- calculate the money of the force deduction bank
How to use buffer queue to realize high concurrent order business (glory Collection Edition)
Success factors of software R & D effectiveness measurement
Chinese son-in-law OTA Ono became the first Asian president of the University of Michigan, with an annual salary of more than 6.5 million!
FanoutExchange交换机代码教程
使用oap切面导致controller被重复调用
In June 2021, the interview suffered a Waterloo. Is it so convoluted now
Too many passwords, don't know how to record? Why don't you write a password box applet yourself
Leetcode-6130: designing digital container systems
[tensorrt] trtexec tool to engine
Remote - basic principle introduction
Google guava is just a brother. What is the real king of caching? (glory Collection Edition)
How to choose a microservice registration center?
每条你收藏的资讯背后,都离不开TA
Compilation and operation of program
DDD的Go实战