【问题标题】:module 'tensorrt' has no attribute 'Logger'模块“tensorrt”没有属性“记录器”
【发布时间】:2019-07-03 12:49:32
【问题描述】:

我在导入 Logger() 和 Builder() 时出错

我在使用 Jetson AGX Xavier。

我也尝试过 python shell。

import tensorflow.contrib.tensorrt as trt
TRT_LOGGER = trt.Logger(trt.Logger.INFO)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'tensorflow.contrib.tensorrt' has no attribute 'Logger'

我也不能导入 trt.Builder()。

Python 版本是 3.6.7

“dpkg -l | grep nvinfer”的输出给出了 Tensor RT 版本:

ii  libnvinfer-dev                             5.0.6-1+cuda10.0                                arm64        TensorRT development libraries and headers
ii  libnvinfer-samples                         5.0.6-1+cuda10.0                                all          TensorRT samples and documentation
ii  libnvinfer5                                5.0.6-1+cuda10.0                                arm64        TensorRT runtime libraries
ii  python-libnvinfer                          5.0.6-1+cuda10.0                                arm64        Python bindings for TensorRT
ii  python-libnvinfer-dev                      5.0.6-1+cuda10.0                                arm64        Python development package for TensorRT
ii  python3-libnvinfer                         5.0.6-1+cuda10.0                                arm64        Python 3 bindings for TensorRT
ii  python3-libnvinfer-dev 5.0.6-1+cuda10.0 arm64 Python 3 development package for TensorRT

【问题讨论】:

    标签: tensorflow python-3.6 nvidia nvidia-jetson tensorrt


    【解决方案1】:

    你正在导入的包import tensorflow.contrib.tensorrt as trt不是TensorRT,这是将TensorRT集成到TF中的包。该软件包没有您要查找的模块,例如 Logger 或 Builder。这个包有自己的 API,用于使用 TensorRT 优化 TF 模型。

    更多将 TensorRT 集成到 TF 的链接:

    如果你想在 TF 之外直接使用 TensorRT API,你应该像这样导入它:import tensorrt as trt

    【讨论】:

    • 您好,我已经尝试在 python shell 上进行跟踪。 import tensorrt as trt TRT_LOGGER = trt.Logger(trt.Logger.INFO) 但它仍然抛出同样的错误。 AttributeError: 模块 'tensorrt' 没有属性 'Logger'"
    【解决方案2】:

    我解决了这个问题。 我所做的是:

    我已经删除了 Tensorflow 1.13 并安装了 1.12。 我删除了所有的虚拟环境。 对 Jetpack 4.2 及其 Tensor RT 版本未做任何更改。

    但我仍然找不到问题所在。

    谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-24
      • 1970-01-01
      • 1970-01-01
      • 2014-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-04
      相关资源
      最近更新 更多