AttributeError:模块“tensorrt”没有属性“推断”

2024-09-27 00:18:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用tensorRT来部署我的pytorch模型,但我在导入tensorRT时遇到了一个问题

Traceback (most recent call last):
  File "/home/fffan/fffan_files/Experiment/pytorch-tensorrt-master/model2trt.py", line 10, in <module>
      import calib as calibrator
  File "/home/fffan/fffan_files/Experiment/pytorch-tensorrt-master/calib.py", line 13, in <module>
      class PythonEntropyCalibrator(trt.infer.EntropyCalibrator):
  AttributeError: module 'tensorrt' has no attribute 'infer'

代码如下所示:

    class PythonEntropyCalibrator(trt.infer.EntropyCalibrator):
        def __init__(self, input_layers, stream):
            trt.infer.EntropyCalibrator.__init__(self)
            self.input_layers = input_layers
            self.stream = stream

            self.d_input = cuda.mem_alloc(self.stream.calibration_data.nbytes)
            stream.reset()

我的张力是5.1.5。 知道的人请告诉我。非常感谢


Tags: selfhomeinputstreamlayersfilespytorchfile

热门问题