Serialization error when loading pretrained network, "tarfile.ReadError: invalid header"

Hi.
I have got a question. I have trained a deep neural network on GPU, and then finally moved my GPU mode deep network to the CPU mode. Further more, after saving CPU mode network with torch.save(net.state_dict(), 'final.pth') and moving to another system and loading with net.load_state_dict(torch.load('./final.pth')) and running it, I have encountered with below error. Could you please help me what is the problem of my code?

Traceback (most recent call last):
File “/home/mohammad/anaconda3/lib/python3.6/tarfile.py”, line 185, in nti
n = int(s.strip() or “0”, 8)
ValueError: invalid literal for int() with base 8: ‘ons\nOrde’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/mohammad/anaconda3/lib/python3.6/tarfile.py”, line 2287, in next
tarinfo = self.tarinfo.fromtarfile(self)
File “/home/mohammad/anaconda3/lib/python3.6/tarfile.py”, line 1086, in fromtarfile
obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
File “/home/mohammad/anaconda3/lib/python3.6/tarfile.py”, line 1028, in frombuf
chksum = nti(buf[148:156])
File “/home/mohammad/anaconda3/lib/python3.6/tarfile.py”, line 187, in nti
raise InvalidHeaderError(“invalid header”)
tarfile.InvalidHeaderError: invalid header

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “TestCode.py”, line 357, in
net.load_state_dict(torch.load(’./final.pth’))
File “/home/mohammad/anaconda3/lib/python3.6/site-packages/torch/serialization.py”, line 248, in load
return _load(f, map_location, pickle_module)
File “/home/mohammad/anaconda3/lib/python3.6/site-packages/torch/serialization.py”, line 314, in _load
with closing(tarfile.open(fileobj=f, mode=‘r:’, format=tarfile.PAX_FORMAT)) as tar,
File “/home/mohammad/anaconda3/lib/python3.6/tarfile.py”, line 1582, in open
return func(name, filemode, fileobj, **kwargs)
File “/home/mohammad/anaconda3/lib/python3.6/tarfile.py”, line 1612, in taropen
return cls(name, mode, fileobj, **kwargs)
File “/home/mohammad/anaconda3/lib/python3.6/tarfile.py”, line 1475, in init
self.firstmember = self.next()
File “/home/mohammad/anaconda3/lib/python3.6/tarfile.py”, line 2299, in next
raise ReadError(str(e))
tarfile.ReadError: invalid header

I have to say that my server’s pytorch version is 0.1.11 and my own system is 0.1.8. Is this the source of error?

Thanks

Edit 1:
I have tried above code on our server. It is actually fine and without error. These errors were started to generate when I reinstalled pytorch.

Edit 2:
The saved format before reinstallation of pytorch on our server was .tar but after reinstallation it has changed to Binary. Moreover, I should say that all of the conversion are done on server!

@apaszke, @fmassa, @albanD, @smth Could you please help me to settle this issue ?

upgrading your pytorch on desktop will solve issue.

Okay thanks I solved the issue!

@mderakhshani did you figure out why it said “cannot read file data” when upgrading pytorch ?

@smth, Actually upgrading was not applicable for me! I uninstalled anaconda first and then reinstall it again.