Skip to content
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

Help with use of onnx model and TensorRT #1

Closed
xavidzo opened this issue Mar 28, 2021 · 5 comments
Closed

Help with use of onnx model and TensorRT #1

xavidzo opened this issue Mar 28, 2021 · 5 comments

Comments

@xavidzo
Copy link

xavidzo commented Mar 28, 2021

Hello @CarkusL, I haven't tested yet your code for exporting to onnx model, but congratulations. I tried to implement the same exports to onnx in the last few days until I realized that exporting PointPillars as a whole model was difficult because of the PillarsScatter backbone.

Have you tried using your onnx model in TensorRT or what's the purpose of converting the model to onnx in your case?
In my attempts the "ScatterND" operation was not supported in TensorRT, that's why I gave up
Do you have maybe and idea how to do the same operation without Scatter, another alternative?

I noticed in order to get the final results for training or inference, the functions here

return self.bbox_head.loss(example, preds)
self.bbox_head.loss and self.bbox_head.predict should be adapted to the output of onnx because originally in PyTorch code the output of the head is a list of dictionaries, but in onnx the outputs are quiet different... are you also working on this adaption of the bbox_head functions to onnx output for further post-processing?

@CarkusL
Copy link
Owner

CarkusL commented Mar 29, 2021

Thank you for your quesion!
Yes, TensorRT doesn't support ScatterND. I think you maybe need to implement the ScatterND in TensorRT by using cuda.
see https://docs.nvidia.com/deeplearning/tensorrt/developer-guide/index.html#extending

now, I don't add the bbox_head for onnx because there are other ops which doesn't support in TensorRT.
I will try to add the cuda implementation for ScatterND in the next few weeks.

@xavidzo
Copy link
Author

xavidzo commented Mar 29, 2021

Thanks for your answer. So I guess, you did not use yet your onnx model for inference / prediction ??
I meant before, I saw you exported the bbox_head in onnx, the forward() method of bbox_head and it works in TensorRT.
I tested it and it works fine, but the output of the bbox_head in onnx is not a list of dictionaries as in PyTorch. For the final prediction results, the function self.bbox_head.predict() must be adapted in PyTorch code to accept the new inputs in onnx format... have you tried this or will you try to do it soon?
I was thinking to try onnxruntime gpu (https://www.onnxruntime.ai/docs/get-started/install.html) to accelerate the model with cuda directly in onnx format instead of TensorRT, maybe you could also take a look at this option...

@xavidzo
Copy link
Author

xavidzo commented Apr 14, 2021

Have you actually used your model with onnxruntime, can you answer please @CarkusL?
I think the input dimensions for example["voxels"] is not always the same for every batch data after voxelization,
so having fixed dimensions for the onnnx model input does not work with variable input shape...am I wrong?

@CarkusL
Copy link
Owner

CarkusL commented Apr 24, 2021

I uploaded the scatterNDPlugin code for the Tensorrt, you can try to do Inference the onnx model in Tensorrt.

@CarkusL
Copy link
Owner

CarkusL commented May 9, 2021

Have you actually used your model with onnxruntime, can you answer please @CarkusL?
I think the input dimensions for example["voxels"] is not always the same for every batch data after voxelization,
so having fixed dimensions for the onnnx model input does not work with variable input shape...am I wrong?

You can fix the input dimensions [1,10, 60000,20] or [1,10, 30000,20] for example["voxels"]. You can pad 0 for the example["voxels"] and coordinate, if you don't have 30000 or 60000 pillars.

@CarkusL CarkusL closed this as completed Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants