我已安装 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
这是 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/