-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ONNX to TensorRT method #278
Comments
@zhiqwang Hi, Will Does
Additionally we can use:
|
This repository https://github.com/triple-Mu/YOLO-TensorRT8 enables easier end2end registration. |
The trtexec tool avoids writing the code to generate the engine, and it has built-in performance analysis tools such as inference speed test, cuda kernel startup time and so on. I have related cases in notebook. |
Hi @AlexeyAB ,
TRT generated by
I guess not,
I am relatively neutral on this one.
This PR is great! Just FYI seems trtexec --onnx=yolov7-tiny.onnx --saveEngine=yolov7-tiny-nms.trt --fp16 --int8 --calib=<file> |
It's true that graphsurgeon can do a lot, but this builds on people's familiarity with the API. If you need to add functions such as preprocessing, it will be difficult to use graphsurgeon if a lot of op changes are involved. And the difficulty of reading the code will also increase. |
+1 for using trtexec to convert.
|
Also, the ONNX-TRT script provided by @Linaom1214 unfortunatly lacks a lot of options, e.g. implicit batching versus explicit batching settings, optimization profiles, etc... |
ONNX to TensorRT with docker for reference. Docker with GPU is the only dependency for this. ONNX to TensorRT with dockerdocker run -it --rm --gpus=all nvcr.io/nvidia/tensorrt:22.04-py3
# from new shell copy onnx to container
docker cp yolov7-tiny.onnx 898c16f38c99:/workspace/tensorrt/bin
# in container now
cd /workspace/tensorrt/bin
# convert onnx to tensorrt with min batch size 1, opt batch size 8 and max batch size 16
./trtexec --onnx=yolov7-tiny.onnx --minShapes=input:1x3x640x640 --optShapes=input:8x3x640x640 --maxShapes=input:16x3x640x640 --fp16 --workspace=4096 --saveEngine=yolov7-tiny.engine |
|
Hi @AlexeyAB and @Linaom1214
Very glad to see that #61 was merged, and I see that there is a new instructions say that ONNX can export to TensorRT via Lin's repo, but this doesn't seem like a good way to do it from a maintenance perspective, is it possible that Lin can pull this export method to this repository as a command line tools?
git clone https://github.com/Linaom1214/tensorrt-python.git cd tensorrt-python python export.py -o yolov7-tiny.onnx -e yolov7-tiny-nms.trt -p fp16
BTW we can also use the trtexct provided by TensorRT to export the serialized engine as below (for TensorRT 8.2.4+, seems that TensorRT 8.4 deprecates
workspace
argument):Perhaps this approach would be simpler.
The text was updated successfully, but these errors were encountered: