加载 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

一站式 AI 云服务平台

更多推荐