tenosrrt错误AttributeError: 'NoneType' object has no attribute 'serialize, 解决方法:更换版本
File "/usr/local/lib/python3.6/dist-packages/torch2trt-0.1.0-py3.6-linux-x86_64.egg/torch2trt/torch2trt.py", line 419, in _on_state_dict state_dict[prefix + "engine"] = bytearray(self.engine.serialize()) AttributeError: 'NoneType' object has no attribute 'serialize
错误产生环境:
trt_pose(https://github.com/NVIDIA-AI-IOT/trt_pose)
if not os.path.exists(OPTIMIZED_MODEL): print('-- Converting TensorRT models. This may takes several minutes...') model.load_state_dict(torch.load(MODEL_WEIGHTS)) self.model_trt = torch2trt.torch2trt(model, [data], fp16_mode=True, max_workspace_size=1 << 25) torch.save(self.model_trt.state_dict(), OPTIMIZED_MODEL)
解决方法:
将tenosrRT版本从7.2.2.3更换为7.1.3.4
#export LD_LIBRARY_PATH=/home/tonyyan/Documents/TensorRT-7.2.2.3/lib
export LD_LIBRARY_PATH=/home/tonyyan/Documents/TensorRT-7.1.3.4.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn8.0/TensorRT-7.1.3.4/lib:$LD_LIBRARY_PATH