2

我有一个用于对象检测的自定义 Faster R-CNN 网络,我在其中定义了一些自定义运算符:nms并将roi_pooling其编译到.so文件中。该.so文件被包装,可以由 tensorflow 框架调用。

将 tensorflow 冻结图转换为.pb文件后,我使用以下代码:

trt_graph = trt.create_inference_graph(graph_def, OUTPUT_NAMES,
                                         max_batch_size=cfg.test_batch_per_gpu,
                                         max_workspace_size_bytes=5000000000,
                                         precision_mode="FP16")  # Get optimized graph

但它报告了很多警告和错误:

2018-04-25 23:45:54.451261: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:0 due to: "Invalid argument: Failed to create Input layer" SKIPPING......( 30 nodes)
2018-04-25 23:45:54.452898: E tensorflow/contrib/tensorrt/log/trt_logger.cc:38] DefaultLogger Parameter check failed at: ../builder/Network.cpp::addInput::377, condition: isValidDims(dims)
2018-04-25 23:45:54.452914: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:1 due to: "Invalid argument: Failed to create Input layer" SKIPPING......( 23 nodes)
2018-04-25 23:45:54.455730: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:2 due to: "Unimplemented: Require 4 dimensional input. Got 2 resnet_v1_50_5/Exp" SKIPPING......( 9 nodes)
2018-04-25 23:45:54.457270: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:3 due to: "Unimplemented: Require 4 dimensional input. Got 2 resnet_v1_50_5/Exp_1" SKIPPING......( 9 nodes)
2018-04-25 23:45:54.458798: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:4 due to: "Unimplemented: Require 4 dimensional input. Got 2 resnet_v1_50_5/Exp_5" SKIPPING......( 9 nodes)
2018-04-25 23:45:54.460327: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:5 due to: "Unimplemented: Require 4 dimensional input. Got 1 resnet_v1_50_5/strided_slice_60" SKIPPING......( 6 nodes)
2018-04-25 23:45:54.461882: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:6 due to: "Unimplemented: Require 4 dimensional input. Got 2 resnet_v1_50_5/Exp_6" SKIPPING......( 9 nodes)
2018-04-25 23:45:54.463425: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:7 due to: "Unimplemented: Require 4 dimensional input. Got 1 resnet_v1_50_5/strided_slice_6" SKIPPING......( 6 nodes)
2018-04-25 23:45:54.464976: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:8 due to: "Unimplemented: Require 4 dimensional input. Got 2 resnet_v1_50_5/ones_2" SKIPPING......( 4 nodes)
2018-04-25 23:45:54.466543: E tensorflow/contrib/tensorrt/log/trt_logger.cc:38] DefaultLogger Parameter check failed at: ../builder/Network.cpp::addInput::377, condition: isValidDims(dims)
2018-04-25 23:45:54.466571: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:9 due to: "Invalid argument: Failed to create Input layer" SKIPPING......( 33 nodes)
2018-04-25 23:45:54.468105: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:10 due to: "Unimplemented: Require 4 dimensional input. Got 2 resnet_v1_50_5/ones_1" SKIPPING......( 3 nodes)
2018-04-25 23:45:54.469726: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:11 due to: "Unimplemented: Require 4 dimensional input. Got 2 resnet_v1_50_5/Exp_7" SKIPPING......( 9 nodes)
2018-04-25 23:45:54.471356: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:12 due to: "Unimplemented: Require 4 dimensional input. Got 2 resnet_v1_50_5/ones_3" SKIPPING......( 4 nodes)
2018-04-25 23:45:54.473207: E tensorflow/contrib/tensorrt/log/trt_logger.cc:38] DefaultLogger Parameter check failed at: ../builder/Network.cpp::addInput::377, condition: isValidDims(dims)
2018-04-25 23:45:54.473259: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:13 due to: "Invalid argument: Failed to create Input layer" SKIPPING......( 380 nodes)
2018-04-25 23:45:54.475765: W tensorflow/contrib/tensorrt/convert/convert_graph.cc:418] subgraph conversion error for subgraph_index:14 due to: "Unimplemented: Require 4 dimensional input. Got 1 resnet_v1_50_5/strided_slice_8" SKIPPING......( 6 nodes)
...

这个错误的原因是什么?如何解决?谢谢。

4

2 回答 2

0

这可能是由于 TensorRT 在调用它来优化图形时需要知道所有张量的大小。一种可能的解决方法是为更快的 rcnn 模型指定一个固定的输入图像张量大小,例如,对模型配置文件进行以下修改。

起初:

faster_rcnn {
  num_classes: 90
  image_resizer {
    keep_aspect_ratio_resizer {
      min_dimension: 600
      max_dimension: 1024
    }
  }
  ......

修改的:

faster_rcnn {
  num_classes: 90
  image_resizer {
    fixed_shape_resizer {
      height: 600
      width:  1024
    }
  }
  ......

参考:https ://github.com/NVIDIA-Jetson/tf_trt_models/issues/6#issuecomment-423098067

于 2018-10-01T10:45:10.760 回答
-1

当您的输入节点未正确注册时会发生这种情况,请确保您使用正确的输入节点名称,您可以在会话中从 tf 图打印节点名称,print([n.name for n in tf.get_default_graph().as_graph_def().node])详情请参阅 nvidia 开发者论坛,https://devtalk .nvidia.com/default/topic/1032314/?comment=5251907

于 2018-06-18T21:44:15.897 回答