Any workaround for loading a newer version model weight with older verison pytorch

I am using pytorch1.6 and can’t use the latest 1.7 for some reason.

When I load the model, I encounter the error:

    super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at ../caffe2/serialize/, 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.

I am wondering is there a workaround to solve this problem.

For example, load model with pytorch1.7, and save the weight in a format that pytorch1.6 can use.
The use pytorch1.6 to reload the model.

Is this possible to realize?

Thanks in advance.

Following DableUTeeF,

In my case, I opened the weight file using vim and noticed that at the end of the first line, there is something like this:


I just change 4 to 3 and now I can load the model :thinking: :thinking:

I don’t know if it is OK.

PyTorch doesn’t guarantee forward compatibility, so while your “hack” might work, you might encounter unwanted side effects and issues.
If possible, try to save and load the model in 1.6 or update to 1.7.1 (which would be the better approach).