5

I have recently updated my Pytorch version to 1.6.0 on my local machine to use their mixed-precision training, since then I am encountering this issue, I have tried the solution mentioned here, but it is still throwing below error.

RuntimeError: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at /opt/conda/conda-bld/pytorch_1591914880026/work/caffe2/serialize/inline_container.cc:132, please report a bug to PyTorch. Attempted to read a PyTorch file with version 4, but the maximum supported version for reading is 3. Your PyTorch installation may be too old.

Link to reproduce: https://www.kaggle.com/rohitsingh9990/error-reproducing-code?scriptVersionId=37468859

Any help will be appreciated, thanks in advance.

Samir Mughal
  • 255
  • 2
  • 7
Rohit Singh
  • 111
  • 2
  • 7
  • 2
    A workaround is to use `torch.load` in the newer PyTorch and then re-save with `_use_new_zipfile_serialization=False` – dashesy Oct 18 '21 at 19:50

1 Answers1

0

In torch.__version__ == 1.6.0 :

torch.save(model_.state_dict(), 'best_model.pth.tar', use_new_zipfile_serialization=False)

then in torch.__version__ == 1.5.1:

torch.load('best_model.pth.tar',map_location='cpu')

Po-Yu Kao
  • 2,597
  • 2
  • 12
  • 14