无法在tensorflow r1.14中导入“tensorflow.contrib.tensorrt”

2024-03-06

我已经安装了Tensorflow r1.14并想使用TF-TRT。但是,出现以下错误:

“ModuleNotFoundError:没有名为“tensorflow.contrib.tensorrt”的模块”

运行示例代码时。同样的错误发生在Tensorflow r1.13。所以我的问题是我需要安装tensorflow.contrib.tensorrt图书馆分开?如果是,怎么办?

此外,我可以运行示例代码TensorRT, e.g. sampleINT8, 成功地。点击here https://i.stack.imgur.com/BKVER.jpg查看我成功运行的示例代码。

这让我相信TensorRT已正确安装。但是,那TF-TRT还是不行。

任何帮助将不胜感激!


在 TF 1.14 中,TF-TRT 从 contrib 移至核心。

您需要像这样导入它: from tensorflow.python.compiler.tensorrt import > trt_convert as trt

https://github.com/tensorflow/tensorrt/blob/master/tftrt/examples/image-classification/image_classification.py#L22 https://github.com/tensorflow/tensorrt/blob/master/tftrt/examples/image-classification/image_classification.py#L22

这是 Linux 的正确答案。

但是,如果您使用的是 Windows:Windows 目前不支持 TensorRT Python API(因此 TF-TRT),因此 TensorFlow python 包不是使用 TensorRT 构建的。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法在tensorflow r1.14中导入“tensorflow.contrib.tensorrt” 的相关文章

随机推荐