加载 PyTorch 深度学习框架模型报错

RuntimeError: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at /pytorch/caffe2/serialize/inline_container.cc:132, please report a bug to PyTorch. Attempted to read a PyTorch file with version 3, but the maximum supported version for reading is 2. Your PyTorch installation may be too old. (init at /pytorch/caffe2/serialize/inline_container.cc:132)

这句话里面最重要的是:

Attempted to read a PyTorch file with version 3, but the maximum supported version for reading is 2

言外之意就是在高版本上训练模型,在低版本上加载模型会有上述问题,解决方案如下:

PyTorch 版本假如是1.4.0版本上加载1.6.0训练的模型:
在这里插入图片描述
只需要在保存模型的时候将下面绿色线的参数改为 False
在这里插入图片描述

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐