openmm / openmm-plumed

OpenMM plugin to interface with PLUMED
59 stars 23 forks source link

Specified a Platform for a Context which does not support all required kernels #59

Closed danielpert closed 2 years ago

danielpert commented 2 years ago

I am trying to run a simulation on a GPU using CUDA but am running into this error:

Traceback (most recent call last): File "../src/biased_simulation.py", line 277, in run_simulation(args.force_constant) File "../src/biased_simulation.py", line 222, in run_simulation simulation = Simulation(modeller.topology, system, integrator, platform) File "XXXX/lib/python3.8/site-packages/simtk/openmm/app/simulation.py", line 103, in init self.context = mm.Context(self.system, self.integrator, platform) File "XXXX/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/python3.8/site-packages/simtk/openmm/openmm.py", line 15587, in init _openmm.Context_swiginit(self, _openmm.new_Context(*args)) simtk.openmm.OpenMMException: Specified a Platform for a Context which does not support all required kernels

According to this GitHub issue: https://github.com/openmm/openmm-plumed/issues/10, this is solved by using Platform.loadPluginsFromDirectory() with the directory where the OpenMMPlumed**.so files are located, but I am already doing this and loading the following plugins:

libOpenMMAmoebaCUDA.so libOpenMMCudaCompiler.so libOpenMMOpenCL.so libOpenMMPlumedReference.so libOpenMMAmoebaReference.so libOpenMMDrudeCUDA.so libOpenMMPME.so libOpenMMRPMDCUDA.so libOpenMMCPU.so libOpenMMDrudeOpenCL.so libOpenMMPlumedCUDA.so libOpenMMRPMDOpenCL.so libOpenMMCUDA.so libOpenMMDrudeReference.so libOpenMMPlumedOpenCL.so libOpenMMRPMDReference.so

I checked Platform.getPluginLoadFailures() and there are no failures for the shared object files.

peastman commented 2 years ago

After you create your System but before creating the Simulation, can you insert the following code and post the output?

print('loaded libraries:', pluginLoadedLibNames)
print('load failures:', Platform.getPluginLoadFailures())
print('forces:')
for f in system.getForces():
    print(f.getName())

Also print out the value returned by loadPluginsFromDirectory() and post that.

danielpert commented 2 years ago

loaded libraries: ['libOpenMMCPU.so', 'libOpenMMPME.so', 'libOpenMMCUDA.so', 'libOpenMMOpenCL.so', 'libOpenMMRPMDCUDA.so', 'libOpenMMDrudeCUDA.so', 'libOpenMMAmoebaCUDA.so', 'libOpenMMRPMDOpenCL.so', 'libOpenMMPlumedCUDA.so', 'libOpenMMDrudeOpenCL.so', 'libOpenMMCudaCompiler.so', 'libOpenMMPlumedOpenCL.so', 'libOpenMMRPMDReference.so', 'libOpenMMDrudeReference.so', 'libOpenMMAmoebaReference.so', 'libOpenMMPlumedReference.so'] load failures: () forces: Traceback (most recent call last): File "biased_simulation.py", line 283, in run_simulation(args.force_constant) File "biased_simulation.py", line 227, in run_simulation print(f.getName()) AttributeError: 'HarmonicBondForce' object has no attribute 'getName'

This is probably the issue! Although I am not sure how to fix it.

The output of loadPluginsFromDirectory() is:

('XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMCPU.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMPME.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMCUDA.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMOpenCL.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMRPMDCUDA.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMDrudeCUDA.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMAmoebaCUDA.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMRPMDOpenCL.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMPlumedCUDA.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMDrudeOpenCL.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMCudaCompiler.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMPlumedOpenCL.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMRPMDReference.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMDrudeReference.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMAmoebaReference.so', 'XXXXXXX/linux-centos7-haswell/gcc-8.2.0/openmm-7.5.0-jqi6xufw5yoxhm3mtam5vw3b42hx54q6/lib/plugins/libOpenMMPlumedReference.so')

danielpert commented 2 years ago

okay, looking at my previous post I don't know what I was thinking, obviously that is not the problem, it must be because I am using an older version of OpenMM that doesn't implement the getName() method (I am using 7.5). Anyway here are the forces from system.getForces(): [<simtk.openmm.openmm.HarmonicBondForce; proxy of <Swig Object of type 'OpenMM::HarmonicBondForce ' at 0x7fe919243960> >, <simtk.openmm.openmm.HarmonicAngleForce; proxy of <Swig Object of type 'OpenMM::HarmonicAngleForce ' at 0x7fe919243720> >, <simtk.openmm.openmm.PeriodicTorsionForce; proxy of <Swig Object of type 'OpenMM::PeriodicTorsionForce ' at 0x7fe919243b40> >, <simtk.openmm.openmm.NonbondedForce; proxy of <Swig Object of type 'OpenMM::NonbondedForce ' at 0x7fe919243bd0> >, <simtk.openmm.openmm.CMMotionRemover; proxy of <Swig Object of type 'OpenMM::CMMotionRemover ' at 0x7fe919243c60> >, <simtk.openmm.openmm.Force; proxy of <Swig Object of type 'OpenMM::Force ' at 0x7fe919243cf0> >]

peastman commented 2 years ago

Is there a reason you're using such an old version? That will require everything else to also be compatible with it, which might itself be the source of the problems.

I notice that libOpenMMPlumedCUDA.so is included in pluginLoadedLibNames. That means it was loaded automatically, and you shouldn't need to call loadPluginsFromDirectory(). If you do need to, something's gone wrong at an earlier point. Calling loadPluginsFromDirectory() to load the plugins a second time could itself cause problems.

You didn't say how you installed OpenMM and the PLUMED plugin, so I assumed you had installed the conda packages. Based on the above output, though, it looks like you must have compiled from source?

Is it possible you have two different copies of OpenMM present, and you're loading two different sets of plugins associated with different versions? That will cause problems.

danielpert commented 2 years ago

I am using 7.5 because that is the version installed on my cluster. You are right, I do not need to call loadPluginsFromDirectory() if OPENMM_PLUGIN_DIR is set correctly so I can get rid of that line. Yes I installed OpenMM and the Plumed plugin from source. It turns out I had not properly installed a separate plugin to the plugin directory. Doing this resolved the error.