The model saved in linux can not be loaded in Win10

My Linux server : titan v x 4
My Win10 pc : 1080ti

I trained my model in Linux server, and saved model using this code ‘netG.state_dict()’.
And I have checked that there is no problem loading the model under Linux server.
However, despite using the same code and model, this error occurs when loading in win10.

Traceback (most recent call last):
File “D:/home/hdd/cjr/pytorch-fid-master/”, line 62, in
recon_ar = Reconstructor_SR(net)
File “D:\home\hdd\cjr\pytorch-fid-master\”, line 197, in init
File “C:\Users\10127\Anaconda3\envs\pytorch\lib\site-packages\torch\nn\modules\”, line 721, in load_state_dict, “\n\t”.join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for DataParallel:
Unexpected key(s) in state_dict: “module.residual_block1.bn1.num_batches_tracked”, “module.residual_block1.bn2.num_batches_tracked”, “module.residual_block2.bn1.num_batches_tracked”, “module.residual_block2.bn2.num_batches_tracked”, “module.residual_block3.bn1.num_batches_tracked”,

Is there a difference between the way Pytorch save on Linux and the way Pytorch save on Windows?
If there are differences, how can we solve this problem?


The problem is that the net you try to load the state dict into does not have the same architecture as the one you saved. Or you use different version of pytorch from one machine to the other. The listed keys correspond to the num_batches_tracked field of the batchnorm layers.

1 Like

I think it’s a version issue as you said. Thank you so much!