无法在TensorFlow R1.14中导入'tensorflow.contrib.tensorrt' [英] Failed to import 'tensorflow.contrib.tensorrt' in tensorflow r1.14

查看:1988
本文介绍了无法在TensorFlow R1.14中导入'tensorflow.contrib.tensorrt'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Tensorflow r1.14,并且想要使用TF-TRT.但是,会发生以下错误:

I have installed the Tensorflow r1.14 and want to use TF-TRT. However, the following error occurs:

"ModuleNotFoundError:没有名为'tensorflow.contrib.tensorrt'的模块""

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

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

when running the sample code. The same error occurs with Tensorflow r1.13. So my question is do I need to install the tensorflow.contrib.tensorrt library separately? If yes, how?

此外,我可以运行TensorRT的示例代码,例如sampleINT8,成功.单击此处以查看我成功运行的示例代码.

Additionally, I can run the sample code of the TensorRT, e.g. sampleINT8, successfully. Click here to see my successful sample code run.

这使我相信TensorRT已正确安装.但是,TF-TRT仍然不起作用.

This leads me to believe that TensorRT is installed properly. However, the TF-TRT still doesn't work.

任何帮助将不胜感激!

推荐答案

在TF 1.14中,TF-TRT从contrib移到了核心.

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

您需要这样导入:从tensorflow.python.compiler.tensorrt import> trt_convert为trt

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的正确答案.

This is the correct answer for Linux.

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

However, if you're using Windows: the TensorRT Python API (and therefore TF-TRT) is not supported for Windows at the moment, so the TensorFlow python packages aren't built with TensorRT.

这篇关于无法在TensorFlow R1.14中导入'tensorflow.contrib.tensorrt'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆