I have a Windows 10 machine and an Ubuntu VM, both running PyTorch 1.9.1.
After quantizing a model on the Linux machine, I used torch.save(net, output_file) in order to save it, and loaded it on the Windows machine, by running net = torch.load(input_file). This step completed without any error.
The problem starts when on Windows I try to call methods of the network, such as net.eval(), net.to('cpu').
Here is the error I get:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "d:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 852, in to
    return self._apply(convert)
  File "d:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 530, in _apply
    module._apply(fn)
  File "d:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 529, in _apply
    for module in self.children():
  File "d:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1527, in children
    for name, module in self.named_children():
  File "d:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1545, in named_children
    for name, module in self._modules.items():
  File "d:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1130, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'Conv2d' object has no attribute '_modules'

If I try to forward an image, I get another AttributeError:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "d:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1051, in _call_impl
    return forward_call(*input, **kwargs)
  File "d:\Anaconda3\lib\site-packages\torchvision\models\resnet.py", line 249, in forward
    return self._forward_impl(x)
  File "d:\Anaconda3\lib\site-packages\torchvision\models\resnet.py", line 232, in _forward_impl
    x = self.conv1(x)
  File "d:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1049, in _call_impl
    if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
  File "d:\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1130, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'Conv2d' object has no attribute '_backward_hooks'