openmm / openmm-ml

High level API for using machine learning models in OpenMM simulations
Other
82 stars 25 forks source link

failed to equip `nnpops` with error #39

Closed JSLJ23 closed 1 year ago

JSLJ23 commented 2 years ago

Hi developers of openmm-ml,

I was trying to run a small MD simulation completely based on ani2x potentials but the system fails to be created at the potential.createSystem(modeller.topology) step throwing this error:

/home/joshua/anaconda3/envs/openmm_torch_py39/lib/python3.9/site-packages/torchani/resources/ failed to equip nnpops with error: /home/joshua/anaconda3/envs/openmm_torch_py39/lib/python3.9/site-packages/NNPOps/libNNPOpsPyTorch.so: undefined symbol: _ZNK3c106IValue12isDoubleListEv

I am trying to run it on a small protein of 10 amino acids in length, with the default solvation parameters in the openmm tutorial. modeller.addSolvent(forcefield=forcefield, padding=1.0*nanometers)

Is this error due to unrecognized elements in the protein PDB or possibly something else?

I have attached the protein PDB file here for reference.

Packages: openmm 7.7.0 openmmml 1.0 torchani 2.2.2 nnpops 0.2

Chignolin.zip

JSLJ23 commented 2 years ago
from openmm.app import PDBFile, Modeller, ForceField, Simulation, PME, HBonds
from openmm.unit import nanometers, kelvin, picoseconds, femtoseconds
from openmm import Platform, LangevinIntegrator

from openmmml import MLPotential
potential = MLPotential('ani2x')
pdb = PDBFile("./Chignolin.pdb")
modeller = Modeller(pdb.topology, pdb.positions)
forcefield = ForceField('amber14-all.xml', 'amber14/tip3pfb.xml')
modeller.addHydrogens()
modeller.addSolvent(forcefield=forcefield, padding=1.0*nanometers)

system = potential.createSystem(modeller.topology,
                                nonbondedMethod=PME,
                                nonbondedCutoff=1.0*nanometers,
                                constraints=HBonds
                               )

/home/joshua/anaconda3/envs/openmm_torch_py39/lib/python3.9/site-packages/torchani/resources/ failed to equip nnpops with error: /home/joshua/anaconda3/envs/openmm_torch_py39/lib/python3.9/site-packages/NNPOps/libNNPOpsPyTorch.so: undefined symbol: _ZNK3c106IValue12isDoubleListEv

peastman commented 2 years ago

@raimis is the best person to comment on what's causing the missing symbol. I think it's probably caused by incompatible library versions of some sort.

I just want to point out that ANI isn't designed for use on proteins and generally won't work with them. For example, it doesn't know anything about charges, so all the charged atoms will be treated as if they were neutral. It only really works for nonpolar small molecules.

JSLJ23 commented 2 years ago

I actually tried creating another python 3.8 conda enviornment and installed an older version of torchani (2.2) and this error went away but a different error came out when I was trying to run the simulation.step() part.

OpenMMException: The following operation failed in the TorchScript interpreter. Traceback of TorchScript (most recent call last): File "", line 57, in self_scalar_type = self.dtype def backward(grad_output): grad_self = AD_sum_backward(grad_output, self_size, dim, keepdim).to(self_scalar_type) / AD_safe_size(self_size, dim)


                return grad_self, None, None, None
  File "<string>", line 24, in AD_sum_backward
            if not keepdim and len(sizes) > 0:
                if len(dims) == 1:
                    return grad.unsqueeze(dims[0]).expand(sizes)
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
                else:
                    res = AD_unsqueeze_multiple(grad, dims, len(sizes))
RuntimeError: expand(CUDADoubleType{[1, 1]}, size=[1]): the number of sizes provided (1) must be greater or equal to the number of dimensions in the tensor (2)
JSLJ23 commented 2 years ago

In the example code snippet of having ANI compute the internal forces for the ligand, how does the createMixedSystem() method know how to only assign the ligand intermolecular forces to ANI with just the ml_atoms = [atom.index for atom in chains[1].atoms()] provided?

Does createMixedSystem() only apply the ANI computations to the potentials / forces between the atoms specified by the atom indexes and to nothing else? i.e. if Atom 1, 2, 3 are specified, then only potentials contributed by the interactions between 1 & 2, 2 & 3, and 1 & 3 are computed with ANI but not 1 & 4?

peastman commented 2 years ago

Does createMixedSystem() only apply the ANI computations to the potentials / forces between the atoms specified by the atom indexes and to nothing else?

Correct.