tensorflow - 在tensorflow r1.14中导入 'tensorflow.contrib.tensorrt'失败

标签 tensorflow tensorrt

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

"ModuleNotFoundError: No module named 'tensorflow.contrib.tensorrt'"

运行示例代码时。 Tensorflow r1.13 也会出现同样的错误。所以我的问题是我需要单独安装 tensorflow.contrib.tensorrt 库吗?如果是,怎么办?

此外,我可以运行TensorRT的示例代码,例如sampleINT8,成功。点击here查看我成功运行的示例代码。

这让我相信 TensorRT 已正确安装。但是,TF-TRT 仍然无法工作。

任何帮助将不胜感激!

最佳答案

In TF 1.14, TF-TRT was moved to the core from contrib.

You need to import it like this: 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

这是 Linux 的正确答案。

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

关于tensorflow - 在tensorflow r1.14中导入 'tensorflow.contrib.tensorrt'失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55523680/

相关文章:

pytorch - 运行 TRTorch 示例时为 "error while loading shared libraries: libnvinfer.so.7: cannot open shared object file: No such file or directory"

python - 如何使用 Triton 服务器 "ensemble model"和 1 :N input/output to create patches from large image?

python - 为什么分布式 TensorFlow 玩具示例需要太长时间?

multithreading - TensorFlow/Keras 多线程模型拟合

tensorflow - 训练神经网络来检测最频繁的输入

tensorflow - 从子流程创建引擎时 TensorRT 创建异常

python - Keras:无法将输入数组从形状 (14,1) 广播到形状 (14)

python - 无法在 Django 中加载 tensorflow

tensorrt - 使用 onnx 进行 TRT 推理 - 错误代码 1 : Cuda Driver (invalid resource handle)

python - 将 Tensorflow Frozen Graph 转换为 UFF 以进行 TensorRT 推理