Giter Club home page Giter Club logo

openmmexampleplugin's Introduction

OpenMM Example Plugin

This project is an example of how to write a plugin for OpenMM. It includes nearly everything you would want in a real plugin, including implementations for the Reference, OpenCL, and CUDA platforms, serialization support, test cases, and a Python API. It is useful as a starting point for anyone who wants to write a plugin.

This plugin defines a single Force subclass called ExampleForce, which implements an anharmonic bond force of the form E(r)=k*r4. Of course, you don't actually need a plugin to implement a force of that form: you could do it trivially with CustomBondForce. But since it is so simple, it makes a very good example.

I assume you are already familiar with the OpenMM API, and that you have already read the OpenMM Developer Guide. If not, go read it now. I will not repeat anything that is covered there, and only focus on what is unique to this plugin.

Building The Plugin

This project uses CMake for its build system. To build it, follow these steps:

  1. Create a directory in which to build the plugin.

  2. Run the CMake GUI or ccmake, specifying your new directory as the build directory and the top level directory of this project as the source directory.

  3. Press "Configure".

  4. Set OPENMM_DIR to point to the directory where OpenMM is installed. This is needed to locate the OpenMM header files and libraries.

  5. Set CMAKE_INSTALL_PREFIX to the directory where the plugin should be installed. Usually, this will be the same as OPENMM_DIR, so the plugin will be added to your OpenMM installation.

  6. If you plan to build the OpenCL platform, make sure that OPENCL_INCLUDE_DIR and OPENCL_LIBRARY are set correctly, and that EXAMPLE_BUILD_OPENCL_LIB is selected.

  7. If you plan to build the CUDA platform, make sure that CUDA_TOOLKIT_ROOT_DIR is set correctly and that EXAMPLE_BUILD_CUDA_LIB is selected.

  8. Press "Configure" again if necessary, then press "Generate".

  9. Use the build system you selected to build and install the plugin. For example, if you selected Unix Makefiles, type make install.

Test Cases

To run all the test cases build the "test" target, for example by typing make test.

This project contains several different directories for test cases: one for each platform, and another for serialization related code. Each of these directories contains a CMakeLists.txt file that automatically creates a test from every file whose name starts with "Test" and ends with ".cpp". To create new tests, just add a new file to any of these directories. The file should contain a main() function that executes any tests in the file and returns 0 if all tests were successful or 1 if any of them failed.

Usually plugins are loaded dynamically at runtime, but that doesn't work well for test cases: you want to be able to run the tests before the plugin has yet been installed into the plugins directory. Instead, the test cases directly link against the relevant plugin libraries. But that creates another problem: when a plugin is dynamically loaded at runtime, its platforms and kernels are registered automatically, but that doesn't happen for code that statically links against it. Therefore, the very first line of each main() function typically invokes a method to do the registration that would have been done if the plugin were loaded automatically:

registerExampleOpenCLKernelFactories();

The OpenCL and CUDA test directories create three tests from each source file: the program is invoked three times while passing the strings "single", "mixed", and "double" as a command line argument. The main() function should take this value and set it as the default precision for the platform:

if (argc > 1)
    Platform::getPlatformByName("OpenCL").setPropertyDefaultValue("OpenCLPrecision", string(argv[1]));

This causes the plugin to be tested in all three of the supported precision modes every time you run the test suite.

OpenCL and CUDA Kernels

The OpenCL and CUDA versions of the force are implemented with the common compute framework. This allows us to write a single class (CommonCalcExampleForceKernel) that provides an implementation for both platforms at the same time. Device code is written in a subset of the OpenCL and CUDA languages, with a few macro and function definitions to make them identical.

The OpenCL and CUDA platforms compile all of their kernels from source at runtime. This requires you to store all your kernel source in a way that makes it accessible at runtime. That turns out to be harder than you might think: simply storing source files on disk is brittle, since it requires some way of locating the files, and ordinary library files cannot contain arbitrary data along with the compiled code. Another option is to store the kernel source as strings in the code, but that is very inconvenient to edit and maintain, especially since C++ doesn't have a clean syntax for multi-line strings.

This project (like OpenMM itself) uses a hybrid mechanism that provides the best of both approaches. The source code for the kernels is found in the platforms/common/src/kernels directory. At build time, a CMake script loads every .cc file contained in the directory and generates a class with all the file contents as strings. For the example plugin, the directory contains a single file called exampleForce.cc. You can put anything you want into this file, and then C++ code can access the content of that file as CommonExampleKernelSources::exampleForce. If you add more .cc files to this directory, correspondingly named variables will automatically be added to CommonExampleKernelSources.

Python API

OpenMM uses SWIG to generate its Python API. SWIG takes an "interface file", which is essentially a C++ header file with some extra annotations added, as its input. It then generates a Python extension module exposing the C++ API in Python.

When building OpenMM's Python API, the interface file is generated automatically from the C++ API. That guarantees the C++ and Python APIs are always synchronized with each other and avoids the potential bugs that would come from having duplicate definitions. It takes a lot of complex processing to do that, though, and for a single plugin it's far simpler to just write the interface file by hand. You will find it in the "python" directory.

To build and install the Python API, build the "PythonInstall" target, for example by typing "make PythonInstall". (If you are installing into the system Python, you may need to use sudo.) This runs SWIG to generate the C++ and Python files for the extension module (ExamplePluginWrapper.cpp and exampleplugin.py), then runs a setup.py script to build and install the module. Once you do that, you can use the plugin from your Python scripts:

from simtk.openmm import System
from exampleplugin import ExampleForce
system = System()
force = ExampleForce()
system.addForce(force)

License

This is part of the OpenMM molecular simulation toolkit originating from Simbios, the NIH National Center for Physics-Based Simulation of Biological Structures at Stanford, funded under the NIH Roadmap for Medical Research, grant U54 GM072970. See https://simtk.org.

Portions copyright (c) 2014-2021 Stanford University and the Authors.

Authors: Peter Eastman

Contributors:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

openmmexampleplugin's People

Contributors

jlmaccal avatar peastman avatar swails avatar zonca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

openmmexampleplugin's Issues

Swig wrappers / std:vector

I'm having a problem calling any routine that takes a std:vector as input or output. This code used to work fine when my plugin was part of the openmm tree. Now, it fails at runtime with errors like:

    TypeError: in method 'MeldForce_addDistProfileRestraint', argument 7 of type 'std::vector< double,std::allocator< double > >'

In this example, I am trying to pass a numpy array, which used to work fine. I'm sure this has something to do with type maps, but I have no idea where to even start.

Libraries not found for CUDA 11

I hate to bug you all with this problem, but I'm really at my wit's end at the moment.

I've built the latest version of OpenMM from source by cloning the openmm/openmm Github repository. I've done this many times before, but only recently started having this problem. I have Cuda 11 installed, and for the first time, I was getting an error that CUDA_CUDA_LIBRARY was NOTFOUND. So instead of running ccmake without any arguments, I ran

cmake -DCMAKE_INSTALL_PREFIX=/home/lvotapka/bin/openmm -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs ..

Since the directory /usr/local/cuda/lib64/stubs contains the libcuda.so file.

But now when I try to install a plugin (this one or any others), I get the following errors at the end of the make step:

[100%] Linking CXX executable TestCudaExampleForce
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: warning: libcuda.so.1, needed by /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so, not found (try using -rpath or -rpath-link)
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: warning: libcufft.so.10, needed by /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so, not found (try using -rpath or -rpath-link)
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuCtxSetLimit' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to [email protected]'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuGetErrorName' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuCtxGetLimit'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuCtxDestroy_v2' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuCtxSetCurrent'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuMemcpyDtoD_v2' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuEventCreate'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuMemcpyDtoDAsync_v2' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to [email protected]'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to [email protected]' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuDeviceGet'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuMemcpyDtoH_v2' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuFuncSetCacheConfig'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuMemFreeHost' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to [email protected]'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuStreamCreate' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuMemAlloc_v2'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuProfilerStop' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuMemFree_v2'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuMemcpy' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuMemcpyDtoHAsync_v2'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to [email protected]' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuDriverGetVersion'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuDeviceCanAccessPeer' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuDeviceGetName'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuMemHostGetDevicePointer_v2' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to [email protected]'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuMemcpyHtoDAsync_v2' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuModuleLoad'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuCtxEnablePeerAccess' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuLaunchKernel'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuStreamWaitEvent' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuCtxSynchronize'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuModuleLoadDataEx' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuDeviceGetAttribute'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuDeviceGetCount' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuMemcpyHtoD_v2'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuMemcpyAsync' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to [email protected]'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuInit' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuEventSynchronize'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuEventRecord' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuCtxCreate_v2'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuModuleGetFunction' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuStreamSynchronize'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuCtxSetCacheConfig' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to [email protected]'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuStreamDestroy_v2' /home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to cuEventDestroy_v2'
/home/lvotapka/miniconda3/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: /home/lvotapka/bin/openmm/lib/plugins/libOpenMMCUDA.so: undefined reference to `cuMemHostAlloc'
collect2: error: ld returned 1 exit status
platforms/cuda/tests/CMakeFiles/TestCudaExampleForce.dir/build.make:98: recipe for target 'platforms/cuda/tests/TestCudaExampleForce' failed
make[2]: *** [platforms/cuda/tests/TestCudaExampleForce] Error 1
CMakeFiles/Makefile2:348: recipe for target 'platforms/cuda/tests/CMakeFiles/TestCudaExampleForce.dir/all' failed
make[1]: *** [platforms/cuda/tests/CMakeFiles/TestCudaExampleForce.dir/all] Error 2
Makefile:140: recipe for target 'all' failed
make: *** [all] Error 2

I've been struggling for awhile to resolve this problem, even installing an older version of Cuda (10.2), to no avail. Any help or ideas would be much appreciated.

Question about vector<Vec3> in swig interface file

I am planning to write a new force that uses the RMSD between molecules and I will use the OpenMM RMSDForce as a base.
The first thing I did was to include in the plugin the OpenMM RMSDForce, which I named MyRMSDForce for now.
I am getting the following error when creating MyRMSDForce:

File "/home/silveira/miniconda3/lib/python3.6/site-packages/exampleplugin.py", line 394, in __init__
_exampleplugin.MyRMSDForce_swiginit(self, _exampleplugin.new_MyRMSDForce(*args))
TypeError: Wrong number or type of arguments for overloaded function 'new_MyRMSDForce'.
Possible C/C++ prototypes are:
ExamplePlugin::MyRMSDForce::MyRMSDForce(std::vector< OpenMM::Vec3,std::allocator< OpenMM::Vec3 > > const &,std::vector< int,std::allocator< int > > const &)
ExamplePlugin::MyRMSDForce::MyRMSDForce(std::vector< OpenMM::Vec3,std::allocator< OpenMM::Vec3 > > const &)

I think that the issue is related to the swig interface file
Should I add something in exampleplugin.i to handle <vector>Vec3? Thanks!

PythonInstall uses different compilers on Mac

@peastman I've found an annoying problem with the sample plugin on Mac.

The CMake machinery to do PythonInstall is simplified in the example plugin compared to in the full OpenMM install. Unfortunately, this causes the example plugin's python module to be compiled with gcc and libstdc++, whereas the rest of the plugin is compiled with clang++ and libc++. This apparently doesn't cause any problems with the current example plugin, but when you modify the plugin so that some of the API takes std::vectors, this causes name-mangling issues and you get run-time dylib errors.

Long story short, would it be possible to call "python setup.py install" in the example plugin in the same way as for the full OpenMM build? I don't know enough about CMake or the build process OpenMM uses to make this change.

"LangevinIntegrator is not a member of OpenMM" error on make PythonInstall

I have come across an error that is really perplexing me.

I have tried to create a custom integrator. It compiles, and tests are all successful. But when I come to make the python wrappers i run into issues with this error code:

ExamplePluginWrapper.cpp: In function ‘void* _p_OpenMM__LangevinIntegratorTo_p_OpenMM__Integrator(void*, int*)’:
ExamplePluginWrapper.cpp:10474:55: error: ‘LangevinIntegrator’ is not a member of ‘OpenMM’
     return (void *)((OpenMM::Integrator *)  ((OpenMM::LangevinIntegrator *) x));
                                                       ^~~~~~~~~~~~~~~~~~
ExamplePluginWrapper.cpp:10474:55: note: suggested alternative: ‘DrudeLangevinIntegrator’
     return (void *)((OpenMM::Integrator *)  ((OpenMM::LangevinIntegrator *) x));
                                                       ^~~~~~~~~~~~~~~~~~
                                                       DrudeLangevinIntegrator
ExamplePluginWrapper.cpp:10474:75: error: expected primary-expression before ‘)’ token
     return (void *)((OpenMM::Integrator *)  ((OpenMM::LangevinIntegrator *) x));
                                                                           ^
ExamplePluginWrapper.cpp:10474:77: error: expected ‘)’ before ‘x’
     return (void *)((OpenMM::Integrator *)  ((OpenMM::LangevinIntegrator *) x));
                                                                             ^
ExamplePluginWrapper.cpp:10474:80: error: expected ‘)’ before ‘;’ token
     return (void *)((OpenMM::Integrator *)  ((OpenMM::LangevinIntegrator *) x));
                                                                                ^

I haven't touched OpenMM::LangevinIntegrator and it doesn't have a problem with anything else

An error occurs when making test

When I unzip the file and do the following:

$mkair build
$cd build
$ccmake ..
CMAKE_BUILD_TYPE
 CMAKE_INSTALL_PREFIX             /usr/local/openmm
 CUDA_HOST_COMPILER               /usr/bin/cc
 CUDA_SDK_ROOT_DIR                CUDA_SDK_ROOT_DIR-NOTFOUND
 CUDA_TOOLKIT_ROOT_DIR            /usr/local/cuda-12.3
 CUDA_USE_STATIC_CUDA_RUNTIME     ON
 CUDA_rt_LIBRARY                  /usr/lib/x86_64-linux-gnu/librt.a
 EXAMPLE_BUILD_CUDA_LIB           ON
 EXAMPLE_BUILD_OPENCL_LIB         OFF
 EXAMPLE_BUILD_PYTHON_WRAPPERS    OFF
 OPENCL_DIR                       OPENCL_DIR-NOTFOUND
 OPENMM_DIR                       /usr/local/openmm
 PYTHON_EXECUTABLE                PYTHON_EXECUTABLE-NOTFOUND
 SWIG_EXECUTABLE                  /usr/bin/swig

After I "Configure" and "Genrate" I installed "sudo make install"
But when I test "make test"

The following tests FAILED:
          3 - TestCudaExampleForceSingle (Failed)
          4 - TestCudaExampleForceMixed (Failed)
          5 - TestCudaExampleForceDouble (Failed)

All errors are reported about cuda, and when I enter the directory "build/platforms/cuda/tests" and run "TestCudaExampleForce", I receive such an error

exception: Error uploading array bondParams: CUDA_ERROR_INVALID_CONTEXT (201) ’
I restarted my computer and it didn't work. What should I do?

Tue Jan 23 02:38:02 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 545.36                 Driver Version: 546.33       CUDA Version: 12.3     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 4060 ...    On  | 00000000:01:00.0 Off |                  N/A |
| N/A   41C    P0              15W / 140W |      0MiB /  8188MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+

Why is "Context.h" misplaced and missing during installation?

When I install https://github.com/openmm/openmmexampleplugin?tab=readme-ov-file,
After I downloaded and unzipped the file, I renamed it openmm, and then ran the commands in sequence
$ cd openmm $ mkdir build && cd build $ make
The following error will occur
[ 8%] Building CXX object CMakeFiles/ExamplePlugin.dir/openmmapi/src/ExampleForce.cpp.o In file included from /home/user/software/openmm/openmmapi/src/ExampleForce.cpp:32: /home/user/software/openmm/openmmapi/include/ExampleForce.h:35:10: fatal error: openmm/Context.h: No such file or directory 35 | #include "openmm/Context.h" | ^~~~~~~~~~~~~~~~~~ compilation terminated. make[2]: *** [CMakeFiles/ExamplePlugin.dir/build.make:76: CMakeFiles/ExamplePlugin.dir/openmmapi/src/ExampleForce.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:153: CMakeFiles/ExamplePlugin.dir/all] Error 2 make: *** [Makefile:146: all] Error 2
What it means is that Context.h cannot be found, which has nothing to do with the path, because there is no such file in the original github folder. How should I install openMM correctly

compilation errors for openmm 7.5

I am trying to compile the plugin for openmm 7.5, but I am getting "undefined reference" errors (please see below). I was able to compile with openmm 7.2.1. Is there a version more recent than 7.2.1 for which the plugin will work? Is there something I could do to make it work for the 7.5 version? Thanks!

Scanning dependencies of target TestSerializeExampleForce
[ 27%] Building CXX object serialization/tests/CMakeFiles/TestSerializeExampleForce.dir/TestSerializeExampleForce.cpp.o
Linking CXX executable TestSerializeExampleForce
CMakeFiles/TestSerializeExampleForce.dir/TestSerializeExampleForce.cpp.o: In function `testSerialization()':
/home/silveira/openmmexampleplugin/serialization/tests/TestSerializeExampleForce.cpp:63: undefined reference to `OpenMM::throwException(char const*, int, std::string const&)'
/home/silveira/openmmexampleplugin/serialization/tests/TestSerializeExampleForce.cpp:69: undefined reference to `OpenMM::throwException(char const*, int, std::string const&)'
/home/silveira/openmmexampleplugin/serialization/tests/TestSerializeExampleForce.cpp:70: undefined reference to `OpenMM::throwException(char const*, int, std::string const&)'
/home/silveira/openmmexampleplugin/serialization/tests/TestSerializeExampleForce.cpp:71: undefined reference to `OpenMM::throwException(char const*, int, std::string const&)'
/home/silveira/openmmexampleplugin/serialization/tests/TestSerializeExampleForce.cpp:72: undefined reference to `OpenMM::throwException(char const*, int, std::string const&)'
CMakeFiles/TestSerializeExampleForce.dir/TestSerializeExampleForce.cpp.o: In function `void OpenMM::XmlSerializer::serialize<ExamplePlugin::ExampleForce>(ExamplePlugin::ExampleForce const*, std::string const&, std::ostream&)':
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/include/openmm/serialization/XmlSerializer.h:60: undefined reference to `OpenMM::SerializationNode::setName(std::string const&)'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/include/openmm/serialization/XmlSerializer.h:62: undefined reference to `OpenMM::SerializationNode::hasProperty(std::string const&) const'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/include/openmm/serialization/XmlSerializer.h:63: undefined reference to `OpenMM::SerializationProxy::getTypeName() const'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/include/openmm/serialization/XmlSerializer.h:64: undefined reference to `OpenMM::SerializationProxy::getTypeName() const'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/include/openmm/serialization/XmlSerializer.h:64: undefined reference to `OpenMM::SerializationNode::setStringProperty(std::string const&, std::string const&)'
../../libExamplePlugin.so: undefined reference to `OpenMM::SerializationNode::createChildNode(std::string const&)'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `VTT for std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
../../libExamplePlugin.so: undefined reference to `OpenMM::SerializationProxy::SerializationProxy(std::string const&)'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::reserve(unsigned long)@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_last_of(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21'
../../libExamplePlugin.so: undefined reference to `OpenMM::SerializationNode::setDoubleProperty(std::string const&, double)'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::copy(char*, unsigned long, unsigned long) const@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__throw_out_of_range_fmt(char const*, ...)@GLIBCXX_3.4.20'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::_Ios_Openmode)@GLIBCXX_3.4.21'
../../libExamplePlugin.so: undefined reference to `OpenMM::SerializationNode::setIntProperty(std::string const&, int)'
../../libExamplePlugin.so: undefined reference to `OpenMM::SerializationNode::getDoubleProperty(std::string const&) const'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_append(char const*, unsigned long)@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find(char, unsigned long) const@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::~basic_stringstream()@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct(unsigned long, char)@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `__cxa_throw_bad_array_new_length@CXXABI_1.3.8'
../../libExamplePlugin.so: undefined reference to `OpenMM::SerializationNode::getIntProperty(std::string const&) const'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `vtable for std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `vtable for std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace_aux(unsigned long, unsigned long, unsigned long, char)@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::basic_istream<char, std::char_traits<char> >& std::getline<char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char)@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::_M_sync(char*, unsigned long, unsigned long)@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream(std::_Ios_Openmode)@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(char const*) const@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_stringbuf<char, std::char_traits<char>, std::allocator<char> >::str() const@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::swap(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find_first_of(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21'
../../libExamplePlugin.so: undefined reference to `OpenMM::Platform::createKernel(std::string const&, OpenMM::ContextImpl&) const'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_mutate(unsigned long, unsigned long, char const*, unsigned long)@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace(unsigned long, unsigned long, char const*, unsigned long)@GLIBCXX_3.4.21'
../../libExamplePlugin.so: undefined reference to `OpenMM::SerializationNode::getChildNode(std::string const&) const'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find(char const*, unsigned long, unsigned long) const@GLIBCXX_3.4.21'
/home/silveira/miniconda3/pkgs/openmm-7.5.0-py36_cuda102_debug_0/lib/libOpenMM.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::rfind(char, unsigned long) const@GLIBCXX_3.4.21'
collect2: error: ld returned 1 exit status
make[2]: *** [serialization/tests/TestSerializeExampleForce] Error 1
make[1]: *** [serialization/tests/CMakeFiles/TestSerializeExampleForce.dir/all] Error 2
make: *** [all] Error 2

Missing OpenMMSwigHeaders.i

Building the Python wrapper of openmmexampleplugin with OpenMM 6.0.1 gives this error:

 openmmexampleplugin/python/exampleplugin.i:3: Error: Unable to find 'OpenMMSwigHeaders.i'

I commented out the line and it looks like it works.

Python wrapper error

openmm built like:

$ conda install -c conda-forge cmake make cython swig fftw doxygen numpy
$ git clone https://github.com/openmm/openmm.git
$ cd openmm
$ mkdir build
$ cd build
$ ccmake ..
configure, CPU only build (unset CUDA and OpenCL options), generate

$ make
$ sudo make install
$ make test 
#all good
$ make PythonInstall   #conda doesn't require sudo
$ python  -m openmm.testInstallation   
#all good

openmmexampleplugin built like:

$ git close https://github.com/openmm/openmmexampleplugin.git
$ cd openmmexampleplugin
$ mkdir build
$ cd build
$ ccmake .. 
configure, CPU only build (unset CUDA and OpenCL options), other options already correct, generate
$ make
$ sudo make install
$ make test 
#all good
$ make PythonInstall

in ipython session:

In [1]:  from openmm import system
In [2]:  from exampleplugin import ExampleForce

giving following error:

ImportError                               Traceback (most recent call last) 
ImportError                               Traceback (most recent call last)                                                                                                                                                                  Input In [2], in <cell line: 1>()
----> 1 from openmmtorch import TorchForce

File ~/miniconda3/envs/torch_openmm/lib/python3.9/site-packages/openmmtorch.py:15, in <module>
       13     from . import _openmmtorch
       14 else:
---> 15     import _openmmtorch
       17 try:
       18     import builtins as __builtin__

ImportError: libOpenMMTorch.so: cannot open shared object file: No such file or directory           

I'm working on ubuntu 18.04.6 LTS
clean miniconda python3.9 environment.
Looks like swig is failing, don't know if this is an easy fix or I'm doing something wrong.

How to add a testInstallation function?

Hi Peter. As you know, OpenMM has such a convenient call to run some quick tests after installation:

python -m openmm.testInstallation

How would be the best way to craft and run such tests in this example plugin?

Example:

python -m openmmexampleplugin.testInstallation

CPU platform

do you have any plan to add the CPU platform to this example plugin?

Common platform

It would be great to have an example implementation of the Common platform for a plugin.

Python bindings are broken

OpenMM changed how units are handled in b0baa00d77e2b5b8a43cabe932c1ffca9a7dd7fc. This plugin wasn't updated accordingly.

Library / path problem

  1. Fresh install of OpenMM from master. Passes tests.
  2. Fresh install of example plugin from master.
  % make test                                                                                                                                                                                                                              !10215
Running tests...
Test project /Users/jlmaccal/Build/SamplePlugin
    Start 1: TestSerializeExampleForce
1/5 Test #1: TestSerializeExampleForce ........   Passed    0.00 sec
    Start 2: TestReferenceExampleForce
2/5 Test #2: TestReferenceExampleForce ........   Passed    0.00 sec
    Start 3: TestCudaExampleForceSingle
3/5 Test #3: TestCudaExampleForceSingle .......***Exception: Other  0.08 sec
    Start 4: TestCudaExampleForceMixed
4/5 Test #4: TestCudaExampleForceMixed ........***Exception: Other  0.05 sec
    Start 5: TestCudaExampleForceDouble
5/5 Test #5: TestCudaExampleForceDouble .......***Exception: Other  0.04 sec

40% tests passed, 3 tests failed out of 5

Total Test time (real) =   0.18 sec

The following tests FAILED:
      3 - TestCudaExampleForceSingle (OTHER_FAULT)
      4 - TestCudaExampleForceMixed (OTHER_FAULT)
      5 - TestCudaExampleForceDouble (OTHER_FAULT)
Errors while running CTest
make: *** [test] Error 8
  % platforms/cuda/tests/TestCudaExampleForce                                                                                                                                                                                              !10216
dyld: Library not loaded: @rpath/libOpenMMCUDA.dylib
  Referenced from: /Users/jlmaccal/Build/SamplePlugin/platforms/cuda/tests/TestCudaExampleForce
  Reason: image not found
[1]    14860 trace trap  platforms/cuda/tests/TestCudaExampleForce

I have the OpenMM lib dir in my path. I have also tried with and without setting OPENMM_PLUGIN_DIR with the same failure.

Windows support - DLL not found

What steps are necessary to get this example plugin working on Windows, wrapped with python?

I've finally gotten around to writing an OpenMM plugin for interactive visualization & simulation. It would be nice if it worked on Windows, for dev with VR! However, I can't seem to get it the example plugin to work on Windows.

Steps taken:

  • Fresh conda environment with OpenMM installed (see attached conda_environment.yml.txt)
  • Set up cmake (see attached CMakeCache.txt):
    • Skip OpenCL and CUDA - we're missing pthreads, but that's ok for now.
    • Generator: Visual Studio 15 2017 x64 bit
  • build, install, python install, output from that looks like it's all installed fine (see attached build.log)

Attempt import:

>>> import exampleplugin
  File "<stdin>", line 1, in <module>
  File "[....]\lib\site-packages\exampleplugin.py", line 15, in <module>
    import _exampleplugin
ImportError: DLL load failed: The specified module could not be found.

I've run dependency walker on ExamplePlugin.dll and it all looks ok, so not sure what's causing the problem.

more examples?

Hey, I had some fun with the archive but the kernel is just this:

real3 delta = make_real3(pos2.x-pos1.x, pos2.y-pos1.y, pos2.z-pos1.z);
real r = SQRT(delta.x*delta.x + delta.y*delta.y + delta.z*delta.z);
float2 bondParams = PARAMS[index];
real deltaIdeal = r-bondParams.x;
real deltaIdeal2 = deltaIdeal*deltaIdeal;
energy += bondParams.y*deltaIdeal2*deltaIdeal2;
real dEdR = 4*bondParams.y*deltaIdeal2*deltaIdeal;
dEdR = (r > 0) ? (dEdR/r) : 0;
delta *= dEdR;
real3 force1 = delta;
real3 force2 = -delta;

So a lot of the rest is a sort of boilerplate you need, I like that you used the ternary ? : (fun in JavaScript too with React), and I suppose I could understand how since you probably also have some definition defining "real double" (or float depending on precision mode) somewhere in the main source that you might paste this inside a CUDA or OpenCL kernel for compilation. But no .cl file here to work with at all.

But it basically does close to nothing 😺 are there some more examples floating around anywhere or should I go back to the main source openmm/openmm and just dig further into the full source code? I am trying to look for some more sophisticated examples where, for example, we are declaring some memory on the GPU in OpenCL. I have this issue where I'm trying to make a faster solution than just a loop that does 1 simulation step and then saves some global variables and I have very little to go on here.

I do like, however, that you can skip the Lepton. I was trying to implement a Lowe-Andersen thermostat and realized that the limitations of the Lepton sort of makes it close to impossible to just make a "simple" solution in it. I need atoms within certain distances and could piggyback off of existing code there.

So an example where say the kernels are more detailed and work with memory and/or existing cutoff implementations might be more helpful for me to see what the options are for the two use cases (saving global variables regularly and Lowe-Andersen). This is nice as a start though.

Python import error

I have followed the readme for openmm and openmmexampleplugin as exactly as possible doing the following:

$ git clone openmm
$ sudo apt update
$ sudo apt install clang
$ sudo apt-get install cmake-curses-gui
$ sudo apt install swig
$ sudo apt-get install doxygen
$ pip install cython # this is python3.8
$ sudo apt-get install libfftw3-dev libfftw3-doc

$ mkdir build_openmm

~/build_openmm$ ccmake ../openmm # cpu only install, generate with g
~/build_openmm$ make
~/build_openmm$ make install
~/build_openmm$ make PythonInstall
~/build_openmm$ make test

~$ git clone https://github.com/openmm/openmmexampleplugin.git
~$ mkdir example_build
~/example_build$ ccmake ../openmmexampleplugin #cpu only, generate
~/example_build$ make install
~/example_build$ make test #all fine
~/example_build$ make PythonInstall

~$ python
>>> from simtk.openmm import System #fine
>>> from exampleplugin import ExampleForce

gives following error:

Traceback (most recent call last):
  File "<stdin>", line1, in <module>
  File "/home/scm/miniconda3/lib/python3.8/site-packages/exampleplugin.py", line15, in <module>
    import _exampleplugin
ImportError: libExamplePlugin.so: cannot open shared object file: No such file or directory

Best case scenario I'm being thick and have missed something.
Worst case scenario the python plugin doesn't work out of the box

CUDA tests failing

The ExampleForce tests fail in the CUDA platform when executing the following line:

I compiled both OpenMM and this plugin with the same GCC compiler (version 11.2.0) and CudaToolkit installation (version 11.7).

The error message I get is:

exception: Error uploading array bondParams: CUDA_ERROR_INVALID_CONTEXT (201)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.