tenosrrt错误AttributeError: 'NoneType' object has no attribute 'serialize, 解决方法:更换版本

时间:2021-03-30 16:54:08   收藏:0   阅读:354

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

原文:https://www.cnblogs.com/mrlonely2018/p/14596337.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!