Skip to content

torch.load fails for AIMNet2 models (.jpt) with PyTorch >= 2.6 due to weights_only=True default #97

@EidRashed

Description

@EidRashed

I got this error when I tried to use this fork https://github.com/peastman/openmm-ml/blob/aimnet2/openmmml/models/aimnet2potential.py

Traceback (most recent call last): File "/app/someproject/production/FC/test.py", line 607, in <module> Minimize() File "/app/someproject/production/FC/test.py", line 245, in Minimize system = create_mixed_system( File "/app/someproject/production/FC/test.py", line 226, in create_mixed_system hybrid_system = potential.createMixedSystem( File "/root/miniconda3/envs/workflow2/lib/python3.10/site-packages/openmmml/mlpotential.py", line 269, in createMixedSystem self._impl.addForces(topology, newSystem, atomList, forceGroup, **args) File "/root/miniconda3/envs/workflow2/lib/python3.10/site-packages/openmmml/models/aimnet2potential.py", line 62, in addForces model = torch.load('aimnet2_wb97m-d3_ens.jpt') File "/root/miniconda3/envs/workflow2/lib/python3.10/site-packages/torch/serialization.py", line 1495, in load raise RuntimeError( RuntimeError: Cannot use ``weights_only=True`` with TorchScript archives passed to ``torch.load``. In PyTorch 2.6, we changed the default value of the weights_onlyargument intorch.loadfromFalsetoTrue. Re-running torch.loadwithweights_onlyset toFalse will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions