AttributeError: ‘tensorrt.tensorrt.Builder‘ object has no attribute ‘build_cuda_engine‘
问题描述
[11/16 16:54:10 trt_export]: Loading ONNX file from path ../../outputs/onnx_model/baseline_R18.onnx...[11/16 16:54:10 trt_export]: Beginning ONNX file parsing[11/16 16:54:10 trt_export]: Completed parsing of ONNX file.D:\fast-reid-master\fast-reid-master\tools\deploy\trt_export.py:132: DeprecationWarning: Use set_memory_pool_limit instead. config.max_workspace_size = max_workspace_size * (1 << 25)[11/16 16:54:10 trt_export]: Building an engine from file ../../outputs/onnx_model/baseline_R18.onnx; this may take a while...Traceback (most recent call last): File "D:\fast-reid-master\fast-reid-master\tools\deploy\trt_export.py", line 166, in <module> onnx2trt(onnx_file_path, engineFile, args.mode, int8_calibrator=int8_calib) File "D:\fast-reid-master\fast-reid-master\tools\deploy\trt_export.py", line 145, in onnx2trt engine = builder.build_cuda_engine(network)AttributeError: 'tensorrt.tensorrt.Builder' object has no attribute 'build_cuda_engine'
问题原因
tensorrt版本大于等于7时,不再使用build_cuda_engine
解决办法
将
engine = builder.build_cuda_engine(network)
改为:
profile = builder.create_optimization_profile() config = builder.create_builder_config() config.add_optimization_profile(profile) engine = builder.build_engine(network, config)
参考文章:
https://blog.csdn.net/qq_38333041/article/details/122481404