I want use tensorRT to deploy my pytorch model.But I get a problem in import 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'
The code is like this:
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()
my tensorRT is 5.1.5. Somebody who knows please tell me.Thank you Very much!
import tensorrt.infer
? – user2357112 supports Monica Jun 18 '20 at 8:33import tensorrt as trt
does not importtensorrt.infer
. – user2357112 supports Monica Jun 19 '20 at 8:38import tensorrt.infer
and get error likeNo module named 'tensorrt.infer
. How should I import in correct way? – Frank.Fan Jun 19 '20 at 8:46tensorrt
package. If you named one of your own filestensorrt.py
, pick a different name. (Checktensorrt.__file__
to figure out where Python is resolvingtensorrt
.) – user2357112 supports Monica Jun 19 '20 at 8:49