Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No platform for requested kernels #72

Open
jgninterline opened this issue Oct 13, 2023 · 8 comments
Open

No platform for requested kernels #72

jgninterline opened this issue Oct 13, 2023 · 8 comments

Comments

@jgninterline
Copy link

jgninterline commented Oct 13, 2023

Hi,

I'm trying to get a non-standard module working in plumed so it looks like I need to compile both plumed and openmm-plumed from source and link them to openmm. I'm using the conda distribution of openmm 8 and installing the other codes in its env. I can run openmm without plumed just fine using the resulting code, but when I try to add in a plumed force, I get this error:

$ python test.py
Warning: importing 'simtk.openmm' is deprecated.  Import 'openmm' instead.
Traceback (most recent call last):
  File "/home/gnelson/Projects/ITGAM/Path_Determination/tst/test.py", line 25, in <module>
    simulation = Simulation(prmtop.topology, system, integrator)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gnelson/miniconda3/envs/plumed/lib/python3.11/site-packages/openmm/app/simulation.py", line 99, in __init__
    self.context = mm.Context(self.system, self.integrator)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gnelson/miniconda3/envs/plumed/lib/python3.11/site-packages/openmm/openmm.py", line 9037, in __init__
    _openmm.Context_swiginit(self, _openmm.new_Context(*args))
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
openmm.OpenMMException: No Platform supports all the requested kernels

Here is test.py:

from openmm.app import *
from openmm import *
from openmm.unit import *
from sys import stdout
from openmmplumed import PlumedForce

Platform.loadPluginsFromDirectory('/full/path/to/miniconda3/envs/plumed/lib/plugins')

prmtop = AmberPrmtopFile('amber.parm7')
inpcrd = AmberInpcrdFile('amber.rst7')
system = prmtop.createSystem(nonbondedMethod=PME, nonbondedCutoff=1*nanometer, constraints=HBonds)
plmd="""
PATHMSD REFERENCE=path-forward-models.pdb LAMBDA=51250 NEIGH_STRIDE=4 NEIGH_SIZE=8 LABEL=path
CUSTOM ARG=path.zzz FUNC=sqrt(x) PERIODIC=NO LABEL=path_z
DRR ARG=path.sss,path_z KAPPA=250,2.5e6 FULLSAMPLES=500 GRID_MIN=2,0.0 GRID_MAX=27,0.045 GRID_SPACING=0.1,0.001 TEMP=310 FRICTION=8.0,8.0 TAU=0.5,0.5 TEXTOUTPUT OUTPUTFREQ=1000 HISTORYFREQ=1000 LABEL=drr
METAD ARG=drr.path.sss_fict,drr.path_z_fict SIGMA=0.5,0.005 HEIGHT=1.5 PACE=500 GRID_MIN=0,-0.02 GRID_MAX=29,0.06 GRID_SPACING=0.1,0.001 BIASFACTOR=20 TEMP=310 FILE=HILLS LABEL=metad
CUSTOM ARG=path_z FUNC=(0.05-x)^-1 PERIODIC=NO LABEL=custom_z
BIASVALUE ARG=custom_z LABEL=z_wall
LOWER_WALLS ARG=path.sss AT=3 OFFSET=0.0 KAPPA=100 EPS=1.0 LABEL=lwall_s
UPPER_WALLS ARG=path.sss AT=26 OFFSET=0.0 KAPPA=100 EPS=1.0 LABEL=uwall_s
PRINT ARG STRIDE=10 FILE=plumed-force2.log FMT=%12.4f
FLUSH STRIDE=100"""
system.addForce(PlumedForce(plmd))
integrator = LangevinMiddleIntegrator(300*kelvin, 1/picosecond, 0.002*picoseconds)
simulation = Simulation(prmtop.topology, system, integrator)
simulation.context.setPositions(inpcrd.positions)
if inpcrd.boxVectors is not None:
        simulation.context.setPeriodicBoxVectors(*inpcrd.boxVectors)
simulation.minimizeEnergy()
simulation.reporters.append(PDBReporter('output.pdb', 1000))
simulation.reporters.append(StateDataReporter(stdout, 1000, step=True, potentialEnergy=True, temperature=True))
simulation.step(10000)

I added "Platform.loadPluginsFromDirectory" based on the comments in this thread: #10 (comment), but I still get the error.

The plugin directory does appear to contain the correct plugins:

$ ls /full/path/to/miniconda3/envs/plumed/lib/plugins
libOpenMMAmoebaCUDA.so libOpenMMAmoebaOpenCL.so libOpenMMAmoebaReference.so libOpenMMCPU.so libOpenMMCUDA.so libOpenMMCudaCompiler.so libOpenMMDrudeCUDA.so libOpenMMDrudeOpenCL.so libOpenMMDrudeReference.so libOpenMMOpenCL.so libOpenMMPME.so libOpenMMPlumedCUDA.so libOpenMMPlumedOpenCL.so libOpenMMPlumedReference.so libOpenMMRPMDCUDA.so libOpenMMRPMDOpenCL.so libOpenMMRPMDReference.so
@peastman
Copy link
Member

Can you print out the value of Platform.getPluginLoadFailures()? That may give a clue to the problem.

Also, can you edit your post to put lines with ``` immediately before and after the code? It's getting rendered as markdown, which makes it hard to read.

@jgninterline
Copy link
Author

jgninterline commented Oct 13, 2023

Here's what I get:

('Error loading library /full/path/to/miniconda3/envs/plumed/lib/plugins/libOpenMMPlumedCUDA.so: libplumedKernel.so: cannot open shared object file: No such file or directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/plugins/libOpenMMPlumedOpenCL.so: libplumedKernel.so: cannot open shared object file: No such file or directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/plugins/libOpenMMPlumedReference.so: libplumedKernel.so: cannot open shared object file: No such file or directory')

The weird thing is that /full/path/to/miniconda3/envs/plumed/lib/plugins/libOpenMMPlumedCUDA.so is there so I'm not sure why it says it can't find it...

EDIT

Ok, so looking closer at this; libOpenMMPlumedCUDA.so, libOpenMMPlumedOpenCL.so and libOpenMMPlumedReference.so are all at those paths. However, libplumedKernel.so is not. It is found one level higher at, "/full/path/to/miniconda3/envs/plumed/lib". I tried adding another loadPluginsFromDirectory call this time pointing to the directory for "libplumedKernel.so" and I this is what I get:

('Error loading library /full/path/to/miniconda3/envs/plumed/lib/tcl8: /full/path/to/miniconda3/envs/plumed/lib/tcl8: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/tk8.6: /full/path/to/miniconda3/envs/plumed/lib/tk8.6: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/plumed: /full/path/to/miniconda3/envs/plumed/lib/plumed: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/tcl8.6: /full/path/to/miniconda3/envs/plumed/lib/tcl8.6: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/plugins: /full/path/to/miniconda3/envs/plumed/lib/plugins: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libbz2.a: /full/path/to/miniconda3/envs/plumed/lib/libbz2.a: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/terminfo: /full/path/to/miniconda3/envs/plumed/lib/terminfo: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libffi.a: /full/path/to/miniconda3/envs/plumed/lib/libffi.a: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/itcl4.2.3: /full/path/to/miniconda3/envs/plumed/lib/itcl4.2.3: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/python3.1: /full/path/to/miniconda3/envs/plumed/lib/python3.1: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libpcre.a: /full/path/to/miniconda3/envs/plumed/lib/libpcre.a: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/tdbc1.1.5: /full/path/to/miniconda3/envs/plumed/lib/tdbc1.1.5: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/pkgconfig: /full/path/to/miniconda3/envs/plumed/lib/pkgconfig: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libuuid.a: /full/path/to/miniconda3/envs/plumed/lib/libuuid.a: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/python3.11: /full/path/to/miniconda3/envs/plumed/lib/python3.11: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libgcc_s.so: /full/path/to/miniconda3/envs/plumed/lib/libgcc_s.so: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libplumed.a: /full/path/to/miniconda3/envs/plumed/lib/libplumed.a: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/thread2.8.8: /full/path/to/miniconda3/envs/plumed/lib/thread2.8.8: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/tkConfig.sh: /full/path/to/miniconda3/envs/plumed/lib/tkConfig.sh: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/tclConfig.sh: /full/path/to/miniconda3/envs/plumed/lib/tclConfig.sh: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libplumed.so: libplumedKernel.so: cannot open shared object file: No such file or directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/sqlite3.40.0: /full/path/to/miniconda3/envs/plumed/lib/sqlite3.40.0: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libpcrecpp.a: /full/path/to/miniconda3/envs/plumed/lib/libpcrecpp.a: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/tdbcodbc1.1.5: /full/path/to/miniconda3/envs/plumed/lib/tdbcodbc1.1.5: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libncurses.so: /full/path/to/miniconda3/envs/plumed/lib/libncurses.so: file too short', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libpcreposix.a: /full/path/to/miniconda3/envs/plumed/lib/libpcreposix.a: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libcudadevrt.a: /full/path/to/miniconda3/envs/plumed/lib/libcudadevrt.a: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/tclooConfig.sh: /full/path/to/miniconda3/envs/plumed/lib/tclooConfig.sh: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libncurses++.a: /full/path/to/miniconda3/envs/plumed/lib/libncurses++.a: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libtkstub8.6.a: /full/path/to/miniconda3/envs/plumed/lib/libtkstub8.6.a: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libncursesw.so: /full/path/to/miniconda3/envs/plumed/lib/libncursesw.so: file too short', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/tdbcmysql1.1.5: /full/path/to/miniconda3/envs/plumed/lib/tdbcmysql1.1.5: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libncurses++w.a: /full/path/to/miniconda3/envs/plumed/lib/libncurses++w.a: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libtclstub8.6.a: /full/path/to/miniconda3/envs/plumed/lib/libtclstub8.6.a: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libdevice.10.bc: /full/path/to/miniconda3/envs/plumed/lib/libdevice.10.bc: invalid ELF header', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/tdbcpostgres1.1.5: /full/path/to/miniconda3/envs/plumed/lib/tdbcpostgres1.1.5: cannot read file data: Is a directory', 'Error loading library /full/path/to/miniconda3/envs/plumed/lib/libplumedWrapper.a: /full/path/to/miniconda3/envs/plumed/lib/libplumedWrapper.a: invalid ELF header')
Traceback (most recent call last):
  File "/full/path/to/Projects/ITGAM/Path_Determination/tst/test.py", line 27, in <module>
    simulation = Simulation(prmtop.topology, system, integrator)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/full/path/to/miniconda3/envs/plumed/lib/python3.11/site-packages/openmm/app/simulation.py", line 99, in __init__
    self.context = mm.Context(self.system, self.integrator)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/full/path/to/miniconda3/envs/plumed/lib/python3.11/site-packages/openmm/openmm.py", line 9037, in __init__
    _openmm.Context_swiginit(self, _openmm.new_Context(*args))
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^
openmm.OpenMMException: No Platform supports all the requested kernels

Most of those seem to be complaining about files that are not library files, but i still have the original error.

Here's the command I used to configure plumed:

./configure --enable-modules=drr --prefix=/full/path/to/miniconda3/envs/plumed

Is that not the correct location?

@peastman
Copy link
Member

That isn't an OpenMM plugin. It's the actual PLUMED library, which the OpenMM plugins need to link to. It needs to be in your library path.

What is the output of

ldd /full/path/to/miniconda3/envs/plumed/lib/plugins/libOpenMMPlumedCUDA.so

@jgninterline
Copy link
Author

Ahh, makes sense. Here's the output:

$ ldd /full/path/to/miniconda3/envs/plumed/lib/plugins/libOpenMMPlumedCUDA.so
	linux-vdso.so.1 (0x00007ffff5da7000)
	libOpenMM.so.8.0 => not found
	libOpenMMCUDA.so => not found
	libOpenMMPlumed.so => not found
	libplumed.so => not found
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f87717dc000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f87717c1000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f87715cd000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f877147e000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f8771a1b000)

Do I need to explicitly set LD_LIBRARY_PATH? Or have I installed things in the wrong places?

@peastman
Copy link
Member

The top level of the environment's lib directory should automatically be included in the library path within the Python process. Any libraries there should be found.

I see that libOpenMMPlumedCUDA.so does not directly depend on libplumedKernel.so, the library that prevented it from loading. It must be indirect. Can you use ldd to figure out which library depends on it? libplumed.so seems the most likely one.

@jgninterline
Copy link
Author

jgninterline commented Oct 14, 2023

Here's the output for libplumed.so:

$ ldd miniconda3/envs/plumed/lib/libplumed.so
	linux-vdso.so.1 (0x00007ffedf2bf000)
	libplumedKernel.so => not found
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fece51fc000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fece5416000)

I assume that means that it depends on libplumedKernel.so, right? It looks like they're both located in the same directory, miniconda3/envs/plumed/lib/libplumed.so and miniconda3/envs/plumed/lib/libplumedKernel.so

@peastman
Copy link
Member

Correct. I don't understand what's going on. libplumed.so is trying to load libplumedKernel.so and failing. @GiovanniBussi do you have any idea what the problem could be?

@GiovanniBussi
Copy link
Contributor

Can you try to recompile (relinking should be sufficient, just clean up whatever is in src/lib) plumed after configuring with the following option:

export STATIC_LIBS=-Wl,-rpath-link,/path/to/where/plumed/is/installed/lib

See what we do to build on conda forge.

This is needed to properly find dependent libraries (such as libplumedKernel.so)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants