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 think other zip readers should work too though.

On my case, when I opened the saved file with text editor (actually Pycharm) the first line looks like this

PK                    e a checkpoint-032epoch/versionFB ZZZ4

I then just change the last letter from 4 to 3, like

a = open('w1.pth', 'rb').readlines()
a[0] = a[0][:-2] + bytes(b'3\n')
with open('w2.pth', 'wb') as wr:
    for aa in a:
        wr.write(aa)

Don’t forget to backup your file though.

1 Like