【问题标题】:running deeplab v3+ with tensorRT使用 tensorRT 运行 deeplab v3+
【发布时间】:2019-04-18 15:16:45
【问题描述】:

我正在尝试使用 tensorRT 优化 deeplab v3+ 模型,但出现以下错误:

    UFF Version 0.5.5
=== Automatically deduced input nodes ===
[name: "ImageTensor"
op: "Placeholder"
attr {
  key: "_output_shapes"
  value {
    list {
      shape {
        dim {
          size: 1
        }
        dim {
          size: -1
        }
        dim {
          size: -1
        }
        dim {
          size: 3
        }
      }
    }
  }
}
attr {
  key: "dtype"
  value {
    type: DT_UINT8
  }
}
attr {
  key: "shape"
  value {
    shape {
      dim {
        size: 1
      }
      dim {
        size: -1
      }
      dim {
        size: -1
      }
      dim {
        size: 3
      }
    }
  }
}
]
=========================================

=== Automatically deduced output nodes ===
[name: "Squeeze_1"
op: "Squeeze"
input: "resize_images/ResizeNearestNeighbor"
attr {
  key: "T"
  value {
    type: DT_INT64
  }
}
attr {
  key: "_output_shapes"
  value {
    list {
      shape {
        dim {
          size: 1
        }
        dim {
          size: -1
        }
        dim {
          size: -1
        }
      }
    }
  }
}
attr {
  key: "squeeze_dims"
  value {
    list {
      i: 3
    }
  }
}
]
==========================================

Using output node Squeeze_1
Converting to UFF graph
Warning: No conversion function registered for layer: ResizeNearestNeighbor yet.
Converting resize_images/ResizeNearestNeighbor as custom op: ResizeNearestNeighbor
Warning: No conversion function registered for layer: ExpandDims yet.
Converting ExpandDims_1 as custom op: ExpandDims
Warning: No conversion function registered for layer: Slice yet.
Converting Slice as custom op: Slice
Warning: No conversion function registered for layer: ArgMax yet.
Converting ArgMax as custom op: ArgMax
Warning: No conversion function registered for layer: ResizeBilinear yet.
Converting ResizeBilinear_2 as custom op: ResizeBilinear
Warning: No conversion function registered for layer: ResizeBilinear yet.
Converting ResizeBilinear_1 as custom op: ResizeBilinear
Traceback (most recent call last):
  File "c:\users\iariav\anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\iariav\anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\iariav\Anaconda3\envs\tensorflow\Scripts\convert-to-uff.exe\__main__.py", line 9, in <module>
  File "c:\users\iariav\anaconda3\envs\tensorflow\lib\site-packages\uff\bin\convert_to_uff.py", line 89, in main
    debug_mode=args.debug
  File "c:\users\iariav\anaconda3\envs\tensorflow\lib\site-packages\uff\converters\tensorflow\conversion_helpers.py", line 187, in from_tensorflow_frozen_model
    return from_tensorflow(graphdef, output_nodes, preprocessor, **kwargs)
  File "c:\users\iariav\anaconda3\envs\tensorflow\lib\site-packages\uff\converters\tensorflow\conversion_helpers.py", line 157, in from_tensorflow
    debug_mode=debug_mode)
  File "c:\users\iariav\anaconda3\envs\tensorflow\lib\site-packages\uff\converters\tensorflow\converter.py", line 94, in convert_tf2uff_graph
    uff_graph, input_replacements, debug_mode=debug_mode)
  File "c:\users\iariav\anaconda3\envs\tensorflow\lib\site-packages\uff\converters\tensorflow\converter.py", line 72, in convert_tf2uff_node
    inp_node = tf_nodes[inp_name]
KeyError: 'logits/semantic/biases/read'

据我了解,这是由 uff 转换器不支持的某些层引起的吗?有没有人成功地将 deeplab 模型转换为 uff? 我在 tensorflow 中使用原始的 deeplabv3+ 模型。

谢谢

【问题讨论】:

    标签: tensorflow tensorrt deeplab


    【解决方案1】:

    是的,由于层支持,有时让特定模型在 TensorRT 中工作有点棘手。 这些是新的 TensorRT 5GA 支持的层(摘自开发者指南):

    问您是否可以看到您有一些层,例如 ResizeNearestNeighborResizeBilinearArgMax,您最好的方法和我最终做的是将网络移植到某个点并使用 cpp API 创建层我需要。检查IPluginV2 和IPluginCreator,看看你是否可以自己实现这些层。

    我认为随着时间的推移会推出更多层支持,但我想如果你迫不及待,不妨自己尝试一下。

    【讨论】:

    • 谢谢,@bpinaya。有没有办法只转换支持的子图(层),让 tf 处理其余的(不支持的层)?
    • 有时可行,您可以将网络转换为 TRT 到某个点,获取这些层的输出并自己处理它们。这在 FCN 中很常见,因为 deconv 层被窃听。如果该层位于网络中间,那就更棘手了,我想你可以转换到某个部分,自己处理,然后将输出放到另一个转换的部分。如果该层位于网络中间,则最好使用插件创建器。
    【解决方案2】:

    我已经使用 TF-TRT 在 Jetson Nano 上运行 deeplabv3+ 模型。根据 TensorRT 发行说明

    弃用 Caffe Parser 和 UFF Parser - 我们将在 TensorRT 7 中弃用 Caffe Parser 和 UFF Parser。它们将在 TensorRT 8 的下一个主要版本中进行测试和功能,但我们计划在后续主要版本中删除支持.计划迁移您的工作流程以使用 tf2onnx、keras2onnx 或 TensorFlow-TensorRT (TF-TRT) 进行部署。

    使用 TF-TRT,我可以获得优化的 TensorRT 图,即使在对我的数据集进行重新训练后,它也能成功运行。

    此外,如果您使用的版本不支持某些运算符,那么对于那些特定的运算符,执行回退到 tensorflow。 这意味着执行中不会有任何错误,只是优化程度会降低。

    参考资料:

    1. TF-TRT 用户指南:https://docs.nvidia.com/deeplearning/frameworks/tf-trt-user-guide/index.html#integrate-ovr
    2. 张量流博客:https://blog.tensorflow.org/2019/06/high-performance-inference-with-TensorRT.html

    【讨论】:

      猜你喜欢
      • 2019-06-23
      • 2020-03-17
      • 2019-09-10
      • 2017-04-29
      • 2019-09-30
      • 2019-12-10
      • 2018-11-14
      • 2020-03-19
      • 2018-11-29
      相关资源
      最近更新 更多