我想优化我的神经网络(来自谷歌的Resnet101),以便使用TensorRT (ver.5.1)。我一直在寻找如何做到这一点的博客和教程,并找到了一些像here和其他一些东西。它们都有一个共同点:
trt_graph = trt.create_inference_graph(
getNetwork(network_file_name),
outputs,
max_batch_size=batch_size,
max_workspace_size_bytes=workspace_size,
precision_mode=”INT8")
但问题是,我的TensorRT版本没有这样的功能。我得到了如下输出。
Python 3.6.6 |Anaconda custom (64-bit)
>>> import tensorrt as trt
>>> trt.__version__
5.1.2.2
>>> trt.create_inference_graph()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'tensorrt' has no attribute 'create_inference_graph'
有没有人知道这个函数在TensorRT 5.1版本中是否被其他函数替代了?如何运行它?
发布于 2019-05-21 19:42:14
正如@Uziel建议的那样,Tensorrt应该与:
import tensorflow.contrib.tensorrt as trt
不幸的是,在我的例子中,导入导致了以下错误:
tensorflow.python.framework.errors_impl.NotFoundError: libnvinfer.so.4: cannot open shared object file: No such file or directory
我安装的TensorRT出现问题。在重新安装一切后,它现在可以工作了。
发布于 2019-05-21 03:42:16
tensorflow的一些安装已经默认具有tensorrt。尝试使用;
import tensorflow.contrib.tensorrt as trt
发布于 2021-01-07 15:43:14
这也是您可以从中导入tensorrt的另一个位置
from tensorflow.python.compiler.tensorrt import trt_convert as trt
https://stackoverflow.com/questions/55922195
复制相似问题