On a Jetson Nano TensorRT Version: 7.1.3 Python Version (if applicable): 3.6.9 TensorFlow Version (if applicable): 1.15
Description
I trained a U-Net segmentation model with Keras (TensorFlow backend), I then get a frozen graph (.pb). I wanted to make inference with my model on a Jetson Nano, so I try to convert my frozen graph to uff, and then to TensorRT engine.
I got an error saying that the operation _ResizeNearestNeighbor (present in 4 layers of this type : up_sampling2d_4/resize/ResizeNearestNeighbor) is unsupported by the UffParser, as can also confirmed this page.
On Stack Overflow, I found that TensorRT has an API called IResizeLayer which supports “Nearest” interpolation and can thus be used to implement upsampling, with no need of using custom layers/plugins.
I tried this using graphsurgeon, here is the code I used :
dynamic_graph = gs.DynamicGraph(os.path.abspath(os.path.join(DIR_NAME, 'frozen_model_backsub.pb')))
nodes=[n.name for n in dynamic_graph.as_graph_def().node]
ns={}
for node in nodes:
if "ResizeNearestNeighbor" in node:
ns[node]=gs.create_plugin_node(name=node,op="IResizeLayer")
dynamic_graph.collapse_namespaces(ns)
But I still get an error and I don’t know what I am doing wrong : UffParser: Validator error: up_sampling2d_4/resize/ResizeNearestNeighbor: Unsupported operation _IResizeLayer
Any help would be very appreciated.
Thanks.
Camille
Thank you for your quick response.
I installed onnx-tensorrt but when trying to convert my model, I got the following error :
----------------------------------------------------------------
Input filename: unet_backsub.onnx
ONNX IR version: 0.0.7
Opset version: 12
Producer name: keras2onnx
Producer version: 1.7.0
Domain: onnxmltools
Model version: 0
Doc string:
----------------------------------------------------------------
WARNING: ONNX model has a newer ir_version (0.0.7) than this parser was built against (0.0.6).
Parsing model
Building TensorRT engine, FP16 available:1
Max batch size: 32
Max workspace size: 1024 MiB
[2020-10-15 10:14:57 ERROR] Network has dynamic or shape inputs, but no optimization profile has been defined.
[2020-10-15 10:14:57 ERROR] Network validation failed.
terminate called after throwing an instance of 'std::runtime_error'
what(): Failed to create object
Aborted (core dumped)