modricwang/Pytorch-Model-to-TensorRT

ImportError onnxparser

lawrencekiba opened this issue · 6 comments

Have you encountered this issue? Had this when running python main.py, however I can import tensorrt as usual.

from tensorrt.parsers import onnxparser
ImportError: cannot import name 'onnxparser'

Hi,
what's your version of CUDA, cuDNN and TensorRT?I will try to reproduce this environment issue.
Guess it is caused by a TensorRT interface update.

gipb commented

In my case, I just changed from tensorrt.parsers to from tensorrt.legacy.parsers. Then I was able to import the onnxparser.

However, after I imported the onnxparser, I got the following error.

AttributeError Traceback (most recent call last)
in
10 output_names=output_names)
11
---> 12 onnx_infer()
13
14 if not os.path.exists(args.trt_model_name):

in onnx_infer()
97
98 def onnx_infer():
---> 99 apex = onnxparser.create_onnxconfig()
100 apex.set_model_file_name(args.onnx_model_name)
101 apex.set_model_dtype(trt.legacy.infer.DataType.FLOAT)

AttributeError: type object 'onnxparser' has no attribute 'create_onnxconfig'

What should I do?

I'm using CUDA 10.0, CuDNN 7.6.0 and TensorRT-5.1.5.0.

@gipb Have you solved this problem? I got the same problem.

In my case, I just changed from tensorrt.parsers to from tensorrt.legacy.parsers. Then I was able to import the onnxparser.

However, after I imported the onnxparser, I got the following error.

AttributeError Traceback (most recent call last)
in
10 output_names=output_names)
11
---> 12 onnx_infer()
13
14 if not os.path.exists(args.trt_model_name):
in onnx_infer()
97
98 def onnx_infer():
---> 99 apex = onnxparser.create_onnxconfig()
100 apex.set_model_file_name(args.onnx_model_name)
101 apex.set_model_dtype(trt.legacy.infer.DataType.FLOAT)
AttributeError: type object 'onnxparser' has no attribute 'create_onnxconfig'

What should I do?

I'm using CUDA 10.0, CuDNN 7.6.0 and TensorRT-5.1.5.0.

I have the same problem,have you solved the problem?

I get this Error when I import calib:

Traceback (most recent call last):
  File "/home/fffan/fffan_files/Experiment/Pytorch-Model-to-TensorRT-master/main.py", line 16, in <module>
    import calib as calibrator
  File "/home/fffan/fffan_files/Experiment/Pytorch-Model-to-TensorRT-master/calib.py", line 13, in <module>
    class PythonEntropyCalibrator(trt.infer.EntropyCalibrator):
AttributeError: 'module' object has no attribute 'infer'

My tensorRT is 5.1 . Does somebody know new API in tensorRT 5.1?