0
点赞
收藏
分享

微信扫一扫

【Bug解决】UnpicklingError: A load persistent id instruction was encountered, but no persistent_load.


问题环境

在将pytorch本地训练好的模型,传到jetson nano平台上,加载模型时,报了这个错误:

UnpicklingError: A load persistent id instruction was encountered, but no persistent_load.

问题原因

查阅相关资料,这是由于pytorch在1.6.0版本之后,模型保存默认方式是压缩的形式,而在jetson nano版本上的pytorch版本是1.0.0,因此无法直接加载.pth文件。
用下面的方式可以查看pytorch的版本:

import torch
print(torch.__version__)

问题解决

设置保存模型时不进行压缩,即修改保存模型语句为:

torch.save(model.state_dict(), MODEL_PATH, _use_new_zipfile_serialization=False)


举报

相关推荐

Tortoise Git could not load this key错误解决

0 条评论