The conversion of the ANI-2x model to TorchScript fails with PyTorch 1.9
See original GitHub issueThe conversion of the ANI-2x model to TorchScript fails with PyTorch 1.9:
import torch
import torchani
print(torch.__version__)
print(torchani.__version__)
torch.jit.script(torchani.models.ANI2x())
$ conda install -c conda-forge pytorch=1.9 torchani
$ python debug.py
1.9.0
2.2
Traceback (most recent call last):
File "debug_torchani.py", line 7, in <module>
torch.jit.script(torchani.models.ANI2x())
File "/shared/raimis/opt/miniconda/envs/tmp_torchani/lib/python3.8/site-packages/torch/jit/_script.py", line 1096, in script
return torch.jit._recursive.create_script_module(
File "/shared/raimis/opt/miniconda/envs/tmp_torchani/lib/python3.8/site-packages/torch/jit/_recursive.py", line 412, in create_script_module
return create_script_module_impl(nn_module, concrete_type, stubs_fn)
File "/shared/raimis/opt/miniconda/envs/tmp_torchani/lib/python3.8/site-packages/torch/jit/_recursive.py", line 474, in create_script_module_impl
script_module = torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
File "/shared/raimis/opt/miniconda/envs/tmp_torchani/lib/python3.8/site-packages/torch/jit/_script.py", line 497, in _construct
init_fn(script_module)
File "/shared/raimis/opt/miniconda/envs/tmp_torchani/lib/python3.8/site-packages/torch/jit/_recursive.py", line 437, in init_fn
cpp_module.setattr(name, orig_value)
RuntimeError: Could not cast attribute 'rev_species' to type Dict[Tensor, int]: Unable to cast Python instance to C++ type (compile in debug mode for details)
But it works with PyTorch 1.8:
$ conda install -c conda-forge pytorch=1.8 torchani
$ python debug.py
1.8.0
2.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
TorchScript — PyTorch 1.13 documentation
In many cases either tracing or scripting is an easier approach for converting a model to TorchScript. Tracing and scripting can be composed...
Read more >Error when converting PyTorch model to TorchScript
I just figured out that models loaded from torchvision.models are in train mode by default. AlexNet and SqueezeNet both have Dropout layers, ...
Read more >Converting Exact GP Models to TorchScript
In this notebook, we'll demonstrate converting an Exact GP model to TorchScript. In general, this is the same as for standard PyTorch models...
Read more >Deploy models into production (advanced) - PyTorch Lightning
TorchScript allows you to serialize your models in a way that it can be loaded in non-Python environments. The LightningModule has a handy...
Read more >TorchScript and PyTorch JIT | Deep Dive - YouTube
In this talk, we dive deep into TorchScript and PyTorch JIT.For more information on TorchScript, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@yueyericardo thanks for your effort! The issue is solved and the solution integrated into NNPOps (https://github.com/openmm/NNPOps/releases/tag/v0.1)
ohh yes, thanks for the heads up! I will merge this tomorrow, I hadn’t noticed this stopped working in the public repo.
On Thu, 14 Oct 2021, 22:23 Jinze (Richard) Xue, @.***> wrote: