openmm-plumed icon indicating copy to clipboard operation
openmm-plumed copied to clipboard

Build openmm-plumed in a container

Open gorgW opened this issue 1 year ago • 16 comments

So I was trying to build the plugin on the container using cmake as following :

RUN cd /opt &&
git clone https://github.com/openmm/openmm-plumed.git &&
cd openmm-plumed &&
mkdir build &&
cd build &&
cmake .. &&
export OPENMM_DIR=/usr/local/lib/python3.10/dist-packages/openmm &&
export PLUMED_INCLUDE_DIR=/usr/local/lib/python3.10/dist-packages/openmm-plumed/include/plumed &&
export PLUMED_LIBRARY_DIR=/usr/local/lib/python3.10/dist-packages/openmm-plumed/lib &&
export CMAKE_INSTALL_PREFIX=$OPENMM_DIR RUN cd /opt/openmm-plumed/build &&
make install RUN make PythonInstall

and I was getting this error

`=> ERROR [ 8/17] RUN CD /opt/openmm-plumed/build && make install 0.5s

[ 8/17] RUN    CD /opt/openmm-plumed/build &&      make install: 0.431 [ 11%] Building CXX object CMakeFiles/OpenMMPlumed.dir/openmmapi/src/PlumedForce.cpp.o 0.495 In file included from /opt/openmm-plumed/openmmapi/src/PlumedForce.cpp:34: 0.495 /opt/openmm-plumed/openmmapi/include/internal/PlumedForceImpl.h:38:10: fatal error: wrapper/Plumed.h: No such file or directory 0.495 38 | #include "wrapper/Plumed.h" 0.495 | ^~~~~~~~~~~~~~~~~~ 0.495 compilation terminated. 0.498 make[2]: *** [CMakeFiles/OpenMMPlumed.dir/build.make:76: CMakeFiles/OpenMMPlumed.dir/openmmapi/src/PlumedForce.cpp.o] Error 1 0.498 make[1]: *** [CMakeFiles/Makefile2:136: CMakeFiles/OpenMMPlumed.dir/all] Error 2 0.498 make: *** [Makefile:146: all] Error 2`

is there a way to fix this ?

Thanks.

gorgW avatar May 30 '24 21:05 gorgW

Check whether you have PLUMED_INCLUDE_DIR set correctly. You have it set to /usr/local/lib/python3.10/dist-packages/openmm-plumed/include/plumed. If you look inside that directory, there should be a subdirectory called wrapper, and in that a file called Plumed.h. Is there?

peastman avatar May 30 '24 22:05 peastman

No actually it is not there. well in this case what should I set Plumed_include and library directories to ?

gorgW avatar May 31 '24 02:05 gorgW

You need to figure out where Plumed is installed. How did you install it?

peastman avatar May 31 '24 18:05 peastman

I re-installed it like that RUN cd /opt &&
git clone https://github.com/plumed/plumed2.git RUN pip install cython &&
cd /opt/plumed2/python &&
make pip &&
pip install .

then, found the wrapper file here /opt/plumed2/src/include/plumed and I set export PLUMED_INCLUDE_DIR=/opt/plumed2/src/include/plumed &&
however i face the same error.

gorgW avatar May 31 '24 19:05 gorgW

PLUMED_INCLUDE_DIR is a CMake variable, not an environment variable. You set it in ccmake.

peastman avatar May 31 '24 19:05 peastman

oh, right ! Thanks but i got this time a new error RUN CD /opt/openmm-plumed/build && make install:
0.445 [ 11%] Building CXX object CMakeFiles/OpenMMPlumed.dir/openmmapi/src/PlumedForce.cpp.o
0.718 In file included from /opt/openmm-plumed/openmmapi/include/internal/PlumedForceImpl.h:38,
0.718 from /opt/openmm-plumed/openmmapi/src/PlumedForce.cpp:34: 0.718 /opt/plumed2/src/include/plumed/wrapper/Plumed.h:2995:10: error: 'unique_ptr' in namespace 'std' does not name a template type 0.718 2995 | std::unique_ptr<char[]> dynamic_buffer; 0.718 | ^~~~~~~~~~ 0.718 In file included from /opt/openmm-plumed/openmmapi/include/internal/PlumedForceImpl.h:38, 0.718 from /opt/openmm-plumed/openmmapi/src/PlumedForce.cpp:34: 0.718 /opt/plumed2/src/include/plumed/wrapper/Plumed.h:1761:1: note: 'std::unique_ptr' is defined in header ''; did you forget to '#include '? 0.718 1760 | #include /* numeric_limits */ 0.718 +++ |+#include 0.718 1761 | #if __cplusplus > 199711L && __PLUMED_WRAPPER_LIBCXX11 0.836 make[2]: *** [CMakeFiles/OpenMMPlumed.dir/build.make:76: CMakeFiles/OpenMMPlumed.dir/openmmapi/src/PlumedForce.cpp.o] Error 1 0.837 make[1]: *** [CMakeFiles/Makefile2:136: CMakeFiles/OpenMMPlumed.dir/all] Error 2

i don't know if the way i installed plumed made it install an old version !

gorgW avatar May 31 '24 20:05 gorgW

What compiler are you using? unique_ptr was introduced in C++11.

peastman avatar May 31 '24 20:05 peastman

gcc 11.4 ! should i expect the problem from that ?

gorgW avatar Jun 02 '24 19:06 gorgW

That version should be fine. I have no idea. Does this only happen when building inside a container, not when building natively?

peastman avatar Jun 03 '24 21:06 peastman

When I build it natively i also get the same exact error.

gorgW avatar Jun 06 '24 22:06 gorgW

Does this mean that i build it wrongly, or is it a compatibility issue ?

gorgW avatar Jun 12 '24 18:06 gorgW

I don't know. Can you show the exact sequence of commands you execute for building natively and the full output from them?

peastman avatar Jun 12 '24 21:06 peastman

git clone https://github.com/openmm/openmm-plumed.git

Cloning into 'openmm-plumed'... remote: Enumerating objects: 671, done. remote: Counting objects: 100% (104/104), done. remote: Compressing objects: 100% (18/18), done. remote: Total 671 (delta 91), reused 86 (delta 86), pack-reused 567 Receiving objects: 100% (671/671), 174.46

cd openmm-plumed/ cd build/ cmake .. -DOPENMM_DIR=/usr/local/openmm/ -DPLUMED_INCLUDE_DIR=/home/go/test2/plumed2/src/include/plumed -DPLUMED_LIBRARY_DIR=/home/go/test2/plumed2/src/lib -DCMAKE_INSTALL_PREFIX=/home/go/test2/openmm-plumed where this path /usr/local/openmm/ leads to openmm lib and include /home/go/test2/openmm-plumed is the path of openmm-plumed plugin file itself

the output for this CMake Warning (dev) in CMakeLists.txt: No project() command is present. The top-level CMakeLists.txt file must contain a literal, direct call to the project() command. Add a line of code such as

project(ProjectName)

near the top of the file, but after cmake_minimum_required().

CMake is pretending there is a "project(Project)" command on the first line. This warning is for project developers. Use -Wno-dev to suppress it.

CMake Deprecation Warning at CMakeLists.txt:5 (CMAKE_MINIMUM_REQUIRED): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.

Update the VERSION argument value or use a ... suffix to tell CMake that the project does not need compatibility with older versions.

-- Configuring done -- Generating done -- Build files have been written to: /home/george/NEU/test2/openmm-plumed/build

make install

Consolidate compiler generated dependencies of target OpenMMPlumed [ 11%] Building CXX object CMakeFiles/OpenMMPlumed.dir/openmmapi/src/PlumedForce.cpp.o In file included from /home/george/NEU/test2/openmm-plumed/openmmapi/include/internal/PlumedForceImpl.h:38, from /home/george/NEU/test2/openmm-plumed/openmmapi/src/PlumedForce.cpp:34: /home/george/NEU/test2/plumed2/src/include/plumed/wrapper/Plumed.h:2995:10: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type 2995 | std::unique_ptr<char[]> dynamic_buffer; | ^~~~~~~~~~ In file included from /home/george/NEU/test2/openmm-plumed/openmmapi/include/internal/PlumedForceImpl.h:38, from /home/george/NEU/test2/openmm-plumed/openmmapi/src/PlumedForce.cpp:34: /home/george/NEU/test2/plumed2/src/include/plumed/wrapper/Plumed.h:1761:1: note: ‘std::unique_ptr’ is defined in header ‘’; did you forget to ‘#include ’? 1760 | #include /* numeric_limits */ +++ |+#include 1761 | #if __cplusplus > 199711L && __PLUMED_WRAPPER_LIBCXX11 make[2]: *** [CMakeFiles/OpenMMPlumed.dir/build.make:76: CMakeFiles/OpenMMPlumed.dir/openmmapi/src/PlumedForce.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:118: CMakeFiles/OpenMMPlumed.dir/all] Error 2 make: *** [Makefile:146: all] Error 2

gorgW avatar Jun 13 '24 08:06 gorgW

any ideas ?

gorgW avatar Jun 25 '24 21:06 gorgW

I've never seen that error before, including with recent versions of gcc, so I'm not sure. The specific error is

/home/george/NEU/test2/plumed2/src/include/plumed/wrapper/Plumed.h:2995:10: error: ‘unique_ptr’ in namespace ‘std’ does not name a template type

Plumed.h is the header file Plumed provides that allows other programs to call it. Apparently it uses the unique_ptr template, which is part of the C++ standard template library, and the compiler doesn't recognize it. This line may provide a clue:

/home/george/NEU/test2/plumed2/src/include/plumed/wrapper/Plumed.h:1761:1: note: ‘std::unique_ptr’ is defined in header ‘’; did you forget to ‘#include ’?

That's confusing, because according to the documentation it's actually defined in <memory>. I looked up the source for Plumed.h, and it does #include <memory> in a couple of different places depending on what macros are defined. I notice an inconsistency in how it uses them. The #include is guarded by

#if __cplusplus > 199711L && __PLUMED_WRAPPER_LIBCXX11

But when it actually uses unique_ptr at line 2995, it has a less restrictive guard:

#if __cplusplus > 199711L

So if __cplusplus > 199711L and __PLUMED_WRAPPER_LIBCXX11 is not set, it will try to use the type without including the required header first. That looks like a bug that should be reported to the Plumed developers.

That said, I don't know why this problem is appearing for you but not for our standard builds.

peastman avatar Jun 27 '24 14:06 peastman

I have the same issue when I am trying to install within a conda environment. Any updates, @gorgW ?

jakublala avatar Sep 20 '24 09:09 jakublala