Hi @glaringlee. Actually, doing
module = torch.jit.load('model.pt')
does not work. That is, the load
call itself returns without errors, but if you then try to do a forward pass on the model, you get something like this:
Traceback (most recent call last):
File "./load.py", line 63, in <module>
main()
File "./load.py", line 59, in main
output = model(data)
File "/home/botelho/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/botelho/.local/lib/python3.6/site-packages/torch/jit/_script.py", line 558, in __getattr__
return super(RecursiveScriptModule, self).__getattr__(attr)
File "/home/botelho/.local/lib/python3.6/site-packages/torch/jit/_script.py", line 288, in __getattr__
return super(ScriptModule, self).__getattr__(attr)
File "/home/botelho/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 779, in __getattr__
type(self).__name__, name))
torch.nn.modules.module.ModuleAttributeError: 'RecursiveScriptModule' object has no attribute 'forward'
And yes, both my libtorch and pytorch versions are 1.7.0.