如何解决问题ModuleNotFoundError:没有名为'tensorflow.python.compiler.tensorrt'的模块

时间:2019-12-14 12:13:17

标签: python tensorflow

可以帮我吗? 下面是我的代码:

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import tensorflow as tf
from tensorflow.python.compiler.tensorrt import trt_convert as trt
# import tensorflow.contrib.slim as slim

当我运行它时,出现错误:

ModuleNotFoundError: No module named 'tensorflow.python.compiler.tensorrt'

我还使用

而不是from tensorflow.python.compiler.tensorrt import trt_convert as trt

from tensorflow.python.compiler.tensorrt import trt,但没有任何改变 我使用TensorFlow的1.14版本。

如何解决该问题?

谢谢您的帮助

2 个答案:

答案 0 :(得分:0)

在低于1.14.1的版本中,正确的导入是:

import tensorflow.contrib.tensorrt as trt

答案 1 :(得分:0)