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
How to load Mobilenet V2 correctly in Cuda Engine (Python)? #259
Comments
Hi @Semihal, You can try increasing the logger's verbosity: For Mobilenet specifically, I think there are several public ONNX models you could try to use along with the ONNX Parser instead, such as from the ONNX model zoo: https://github.com/onnx/models/tree/master/vision/classification/mobilenet#model. If you want to keep the TF code, you could also try to use There is some code in this repo that could help serve as a reference for converting the Mobilenet ONNX model to TensorRT: https://github.com/rmccorm4/tensorrt-utils/tree/master/classification/imagenet#onnx-model-zoo You can also try using Also, if you encounter similar issues with the ONNX parser, it's API provides a get_error() method to help debug more. I don't believe the UFF parser has the same capability. |
If you're determined to use UFF instead, I noticed that you're using CUDA 10.1, and I think there are currently some known issues with that due to TF binaries not being built with CUDA 10.1. There is some discussion on that in this issue: #123 (comment) |
Hi @rmccorm4 , I found that there are some logs when running UFF -> CudaEngine conversion in the CLI (not present, for example, when running in Jupyter).
I tried running on Jetson Xavier with the following environment:
... UFF or ONNX?
I would like to use TensorFlow for model development, is there any fundamental difference in using UFF or ONNX? |
The ONNX parser is generally better supported and tends to support more ops than UFF. There is also more infrastructure around ONNX, particularly with 3rd party tools for exporting, converting, etc. Especially Netron which is helpful for debugging bad ONNX models. You can continue to use TF for development, but I would suggest trying tf2onnx to see if it works for you. |
During conversion sd_mobilenet_v2 (http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v2_coco_2018_03_29.tar.gz) I get *.onnx files, but during conversion there are ReferenceError errors. A similar situation for mobilenet_v1 (http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v1_coco_2018_01_28.tar.gz).
But I'm still trying to run the conversion to engine through onnx_to_tensorrt.py and get the following:
|
Hi @Semihal, It looks like there are two steps to tf2onnx: (1) conversion and then (2) optimization. It seems like some errors happened during optimization, but it might not be necessary. You can try to quickly verify the ONNX files with something like You can also try to do some offline optimization with something like this: https://github.com/daquexian/onnx-simplifier#our-solution But I haven't tried that myself. |
I tried running the
|
Hi @rmccorm4 , Do you have any more ideas how to deal with my problem? |
I tried using graphsurgeon to change the data type and now get this error:
, have any suggestions? |
Hi @Semihal, I think another user had a similar issue here which was resolved: https://devtalk.nvidia.com/default/topic/1067555/tensorrt/tensorrt-inference-error-while-load-onnx-model/post/5409905/?offset=7#5412924 Please try the suggestions here and let me know if it helps. |
You could try to use the |
@Semihal your best bet would also be to try now with TensorRT 7.0 which was just released today: https://developer.nvidia.com/nvidia-tensorrt-download. It expanded a lot on the ONNX parser: https://docs.nvidia.com/deeplearning/sdk/tensorrt-release-notes/tensorrt-7.html#rel_7-0-0 |
@rmccorm4 , Thanks, I'll try! |
Hi @Semihal, Yes unfortunately that's correct: #292 (comment) Did |
Hi @rmccorm4, |
Did that give you a new error? Can you share an ONNX model to reproduce the error? |
Hi, I ran in the same issues with TensorTR 7 using the ONNX parser for a custom SSD Mobilinet v2. My net was trained with TF 1.14 using the object detection api and translated to onnx with tf2onnx using op 11. I've also changed the type of the image_tensor node to float32 to avoid the unsupported type (line 121 https://github.com/tensorflow/models/blob/master/research/object_detection/exporter.py), but then it fails to load some weights because they are int64. Have you find any solution? My last hope is that downgrading TF will make it work. |
Can you share the explicit commands you ran and errors you got? I thought TensorRT casted INT64 -> INT32 when possible and gave a warning, but I don't think I've seen that fail. If possible as well, please share your ONNX model so I can reproduce the issue. |
@lorenzolightsgdwarf
|
Hi @rmccorm4,
The first line is what you suggested, but note that the following message contains |
Hi @JingyuQian, For the TensorRT warning, it should be fine. It will give an error if the cast from INT64->INT32 failed (INT64 value was outside of the range of INT32). As to why the INT64 types are generated, I'm not totally sure. Check this FAQ: Q: Does ONNX support implicit scalar datatype casting? https://pytorch.org/docs/stable/onnx.html |
@Semihal did switching to PyTorch work out for you? Still having any issues? |
Hi! Yes, it is work. |
Awesome, glad to hear. |
I got the below error when i run WARNING: ONNX model has a newer ir_version (0.0.5) than this parser was built against (0.0.3). Any suggestions for this?? sudo apt-cache show nvidia-jetpack |
Actually, I would recommand to build pure TensorRT engine and load weights from pytorch/tensorflow models. |
Environment
TensorRT Version: 6.0.1.5
GPU Type: Quadro P5000
Nvidia Driver Version: 430.26
CUDA Version: Cuda compilation tools, release 10.1, V10.1.243
> nvcc --version
> nvidia-smi
CUDNN Version:
Operating System + Version:
Python Version (if applicable):
TensorFlow Version (if applicable): v1.12.0-0-ga6d8ffae09 1.12.0
Baremetal or Container (if container which image + tag): nvcr.io/nvidia/tensorrt:19.11-py3
Steps To Reproduce
But I get this conclusion:
How to determine what mistake was made? Does UffParser have any logs? How to properly import Mobilenet V2 into CudaEngine (Python)?
The text was updated successfully, but these errors were encountered: