SSAGESproject / SSAGES

Software Suite for Advanced General Ensemble Simulations
GNU General Public License v3.0
85 stars 29 forks source link

Error building with gromacs #20

Closed AMPsUSC closed 4 years ago

AMPsUSC commented 4 years ago

I have sucessfully installed and tested SSAGES with LAMMPS. Then I tried with GROMACS using a local source code v 2018 and also the default option -DGROMACS=YES but I am getting some errors that I am not able to solve. I am copying below the last lines of the cmake output. Any idea on how to solve this?

[ 39%] Building C object src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/conformation-utilities.c.o
[ 39%] Building CXX object src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/copyrite.cpp.o
[ 40%] Building C object src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/disre.c.o
[ 40%] Building C object src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/gmx_cpuid.c.o
[ 40%] Building CXX object src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/gmx_detect_hardware.cpp.o
[ 40%] Building C object src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/gmx_omp_nthreads.c.o
[ 40%] Building C object src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/gmx_thread_affinity.c.o
[ 40%] Building C object src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/ifunc.c.o
[ 40%] Building C object src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/inputrec.c.o
[ 40%] Building CXX object src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/main.cpp.o
In file included from /home/fangel/SSAGES-public/include/Eigen/Core:372:0,
                 from /home/fangel/SSAGES-public/include/Eigen/Dense:1,
                 from /home/fangel/SSAGES-public/src/types.h:21,
                 from /home/fangel/SSAGES-public/src/EventListener.h:24,
                 from /home/fangel/SSAGES-public/src/Hook.h:23,
                 from /home/fangel/SSAGES-public/hooks/gromacs/GromacsHook.h:5,
                 from /home/fangel/SSAGES-public/build/hooks/gromacs/gromacs-download-prefix/src/gromacs-download/src/gromacs/gmxlib/main.cpp:64:
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h: In function ‘Packet Eigen::internal::pmul(const Packet&, const Packet&) [with Packet = std::complex<float>]’:
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:527:36: error: invalid cast from type ‘const std::complex<float>’ to type ‘real {aka float}’
 { return std::complex<float>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                    ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:527:44: error: invalid cast from type ‘const std::complex<float>’ to type ‘real {aka float}’
 { return std::complex<float>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                            ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:527:79: error: invalid cast from type ‘const std::complex<float>’ to type ‘real {aka float}’
 { return std::complex<float>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                                                               ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:527:89: error: invalid cast from type ‘const std::complex<float>’ to type ‘real {aka float}’
 { return std::complex<float>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                                                                         ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h: In function ‘Packet Eigen::internal::pmul(const Packet&, const Packet&) [with Packet = std::complex<double>]’:
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:530:37: error: invalid cast from type ‘const std::complex<double>’ to type ‘real {aka float}’
 { return std::complex<double>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                     ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:530:45: error: invalid cast from type ‘const std::complex<double>’ to type ‘real {aka float}’
 { return std::complex<double>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                             ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:530:80: error: invalid cast from type ‘const std::complex<double>’ to type ‘real {aka float}’
 { return std::complex<double>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                                                                ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:530:90: error: invalid cast from type ‘const std::complex<double>’ to type ‘real {aka float}’
 { return std::complex<double>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                                                                          ^
src/gromacs/CMakeFiles/libgromacs.dir/build.make:5042: recipe for target 'src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/main.cpp.o' failed
make[5]: *** [src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/main.cpp.o] Error 1
CMakeFiles/Makefile2:3051: recipe for target 'src/gromacs/CMakeFiles/libgromacs.dir/all' failed
make[4]: *** [src/gromacs/CMakeFiles/libgromacs.dir/all] Error 2
Makefile:182: recipe for target 'all' failed
make[3]: *** [all] Error 2
hooks/gromacs/CMakeFiles/gromacs.dir/build.make:133: recipe for target 'hooks/gromacs/gromacs/src/gromacs-stamp/gromacs-build' failed
make[2]: *** [hooks/gromacs/gromacs/src/gromacs-stamp/gromacs-build] Error 2
CMakeFiles/Makefile2:304: recipe for target 'hooks/gromacs/CMakeFiles/gromacs.dir/all' failed
make[1]: *** [hooks/gromacs/CMakeFiles/gromacs.dir/all] Error 2
Makefile:103: recipe for target 'all' failed
make: *** [all] Error 2
mquevill commented 4 years ago

This is due to a conflict in the real() functions that GROMACS and Eigen use. SSAGES should have patched the Eigen source to use std::real() to avoid this conflict. It seems like this patching step did not happen for you. Please ensure you have the most up-to-date version of SSAGES (v0.9.1). [If you cloned the repository, run git checkout release-0.9 and git pull to ensure the source code is up to date.]

To fix this in SSAGES v0.9.1, please remove the directory /home/fangel/SSAGES-public/include/Eigen and /home/fangel/SSAGES-public/build/eigen-prefix and try to build again. It should set up Eigen as an external project and download and patch it for you when building.

cd /home/fangel/SSAGES-public/build/
rm -r ../include/Eigen/
rm -r eigen-prefix/
make

Let me know if you are still having issues.

AMPsUSC commented 4 years ago

Thanks for the tip. I followed exactly your instructions but I am still getting the same error. I checked that I am using version 0.9.1. I tried again with my local version of GROMACS and using -DGROMACS=YES. The lines I got are almost the same as before... but not exactly, I am copying them here:

[ 76%] Building CXX object CMakeFiles/libssages.dir/src/ResourceHandler.cpp.o
[ 78%] Building CXX object CMakeFiles/libssages.dir/include/nnet/nnet.cpp.o
[ 79%] Linking CXX static library libssages.a
[ 84%] Built target libssages
[ 85%] Performing forcebuild step for 'gromacs'
Force build gromacs
[ 87%] Performing build step for 'gromacs'
[  0%] Built target view_objlib
[  1%] Built target fftwBuild
[  1%] Generating git version information
[  1%] Built target git-version-info
[  1%] Building CXX object src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/main.cpp.o
In file included from /home/fangel/SSAGES-public/include/Eigen/Core:372:0,
                 from /home/fangel/SSAGES-public/include/Eigen/Dense:1,
                 from /home/fangel/SSAGES-public/src/types.h:21,
                 from /home/fangel/SSAGES-public/src/EventListener.h:24,
                 from /home/fangel/SSAGES-public/src/Hook.h:23,
                 from /home/fangel/SSAGES-public/hooks/gromacs/GromacsHook.h:5,
                 from /home/fangel/SSAGES-public/build/hooks/gromacs/gromacs-download-prefix/src/gromacs-download/src/gromacs/gmxlib/main.cpp:64:
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h: In function ‘Packet Eigen::internal::pmul(const Packet&, const Packet&) [with Packet = std::complex<float>]’:
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:527:36: error: invalid cast from type ‘const std::complex<float>’ to type ‘real {aka float}’
 { return std::complex<float>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                    ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:527:44: error: invalid cast from type ‘const std::complex<float>’ to type ‘real {aka float}’
 { return std::complex<float>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                            ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:527:79: error: invalid cast from type ‘const std::complex<float>’ to type ‘real {aka float}’
 { return std::complex<float>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                                                               ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:527:89: error: invalid cast from type ‘const std::complex<float>’ to type ‘real {aka float}’
 { return std::complex<float>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                                                                         ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h: In function ‘Packet Eigen::internal::pmul(const Packet&, const Packet&) [with Packet = std::complex<double>]’:
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:530:37: error: invalid cast from type ‘const std::complex<double>’ to type ‘real {aka float}’
 { return std::complex<double>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                     ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:530:45: error: invalid cast from type ‘const std::complex<double>’ to type ‘real {aka float}’
 { return std::complex<double>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                             ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:530:80: error: invalid cast from type ‘const std::complex<double>’ to type ‘real {aka float}’
 { return std::complex<double>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                                                                ^
/home/fangel/SSAGES-public/include/Eigen/src/Core/GenericPacketMath.h:530:90: error: invalid cast from type ‘const std::complex<double>’ to type ‘real {aka float}’
 { return std::complex<double>(real(a)*real(b) - imag(a)*imag(b), imag(a)*real(b) + real(a)*imag(b)); }
                                                                                          ^
src/gromacs/CMakeFiles/libgromacs.dir/build.make:5042: recipe for target 'src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/main.cpp.o' failed
make[5]: *** [src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/main.cpp.o] Error 1
CMakeFiles/Makefile2:3051: recipe for target 'src/gromacs/CMakeFiles/libgromacs.dir/all' failed
make[4]: *** [src/gromacs/CMakeFiles/libgromacs.dir/all] Error 2
Makefile:182: recipe for target 'all' failed
make[3]: *** [all] Error 2
hooks/gromacs/CMakeFiles/gromacs.dir/build.make:133: recipe for target 'hooks/gromacs/gromacs/src/gromacs-stamp/gromacs-build' failed
make[2]: *** [hooks/gromacs/gromacs/src/gromacs-stamp/gromacs-build] Error 2
CMakeFiles/Makefile2:304: recipe for target 'hooks/gromacs/CMakeFiles/gromacs.dir/all' failed
make[1]: *** [hooks/gromacs/CMakeFiles/gromacs.dir/all] Error 2
Makefile:103: recipe for target 'all' failed
make: *** [all] Error 2
mquevill commented 4 years ago

Does your source have a file located at /home/fangel/SSAGES-public/include/patches/eigen-using-std-real.patch? If not, that would explain why it's not working.

As a workaround, could you apply the following patch to /home/fangel/SSAGES-public/include/Eigen/Core? You should only have to add the using std::real; line:

@@ -305,6 +305,8 @@
/** \brief Namespace containing all symbols from the %Eigen library. */
 namespace Eigen {

+using std::real;
+
 inline static const char *SimdInstructionSetsInUse(void) {
 #if defined(EIGEN_VECTORIZE_AVX512)
   return "AVX512, FMA, AVX2, AVX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2";
AMPsUSC commented 4 years ago

I tried all your suggestions but I still have problems... although with different errors. Below the errors with the adding to SSAGES-public/include/Eigen/Core.

-- Performing Test HAS_NO_UNUSED_VARIABLE
-- Performing Test HAS_NO_UNUSED_VARIABLE - Success
-- Check if the system is big endian
-- Searching 16 bit integer
-- Searching 16 bit integer - Using unsigned short
-- Check if the system is big endian - little endian
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Performing Test HAS_NO_UNUSED_PARAMETER
-- Performing Test HAS_NO_UNUSED_PARAMETER - Success
-- Performing Test HAS_NO_DEPRECATED_REGISTER
-- Performing Test HAS_NO_DEPRECATED_REGISTER - Success
-- Configuring done
-- Generating done
-- Build files have been written to: /home/fangel/SSAGES-public/build/hooks/gromacs/gromacs/src/gromacs-build
[ 87%] Performing forcebuild step for 'gromacs'
Force build gromacs
[ 88%] Performing build step for 'gromacs'
Scanning dependencies of target view_objlib
[  0%] Building CXX object src/programs/CMakeFiles/view_objlib.dir/view/view.cpp.o
[  0%] Built target view_objlib
[  1%] Built target fftwBuild
Scanning dependencies of target git-version-info
[  1%] Generating git version information
[  1%] Built target git-version-info
[  1%] Building NVCC (Device) object src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/cuda_tools/libgromacs_generated_copyrite_gpu.cu.o
nvcc fatal   : Unsupported gpu architecture 'compute_20'
CMake Error at libgromacs_generated_copyrite_gpu.cu.o.Release.cmake:216 (message):
  Error generating
  /home/fangel/SSAGES-public/build/hooks/gromacs/gromacs/src/gromacs-build/src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/cuda_tools/./libgromacs_generated_copyrite_gpu.cu.o

src/gromacs/CMakeFiles/libgromacs.dir/build.make:83: recipe for target 'src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/cuda_tools/libgromacs_generated_copyrite_gpu.cu.o' failed
make[5]: *** [src/gromacs/CMakeFiles/libgromacs.dir/gmxlib/cuda_tools/libgromacs_generated_copyrite_gpu.cu.o] Error 1
CMakeFiles/Makefile2:3093: recipe for target 'src/gromacs/CMakeFiles/libgromacs.dir/all' failed
make[4]: *** [src/gromacs/CMakeFiles/libgromacs.dir/all] Error 2
Makefile:182: recipe for target 'all' failed
make[3]: *** [all] Error 2
hooks/gromacs/CMakeFiles/gromacs.dir/build.make:133: recipe for target 'hooks/gromacs/gromacs/src/gromacs-stamp/gromacs-build' failed
make[2]: *** [hooks/gromacs/gromacs/src/gromacs-stamp/gromacs-build] Error 2
CMakeFiles/Makefile2:304: recipe for target 'hooks/gromacs/CMakeFiles/gromacs.dir/all' failed
make[1]: *** [hooks/gromacs/CMakeFiles/gromacs.dir/all] Error 2
Makefile:103: recipe for target 'all' failed
make: *** [all] Error 2
mquevill commented 4 years ago

Thank you for pointing this out. There's definitely something weird going on with the Eigen patching that might require additional debugging....

The newer messages are related to GPU builds with GROMACS. It appears your GPU architecture is not supported by the version of GROMACS you are using. I would suggest using an older version of GROMACS, or turning off the GPU build with -DGMX_GPU=OFF.

AMPsUSC commented 4 years ago

Thank you a lot for your help. With the edition you suggested in SSAGES-public/include/Eigen/Core and turning off the GPU I was able to compile it for the default version of gromacs. I will try now with gromacs 2018.

AMPsUSC commented 4 years ago

Also GROMACS 2018 with local code works fine with that edition in SSAGES-public/include/Eigen/Core. I tested one of the examples with no problem. Thanks again!

mquevill commented 4 years ago

Glad you were able to get it built! We will definitely need to release a fix for this so that other people do not have the same issue.

AMPsUSC commented 4 years ago

Happy to help! I asked for the installation of SSAGES to the administrators of the supercomputer where I usually do my calculations and they found a problem. It seems that the required patch for the installation with GROMACS is in this path: SSAGES-public/include/patches/eigen-using-std-real.patch This is causing a problem because they use EasyBuild to automate the installations and it is not recognizing that path to apply the patch. Could you help with this? I do not know which would be the right path for EasyBuild.

mquevill commented 4 years ago

As far as I know, we do not support EasyBuild. (That's not to say that it won't work with it, it just hasn't been tested.) The patch should be in the SSAGES source directory under include/patches/eigen-using-std-real.patch but perhaps they have the source directory in a different location than you were using?

We use CMake to build, which should automate most things, but I don't know if there are direct EasyBuild analogs since I've never used EasyBuild before.

pabloferz commented 4 years ago

SSAGES-public was the previous name of the repository, which then changed to https://github.com/SSAGESproject/SSAGES. Maybe there is and issue related to git or the cloning or the repository. Or are they designating SSAGES-public as the name of the path where it gets installed?

That said, as @mquevill pointed out. We haven't build using EasyBuild so we do not know if it would work, but we are happy to follow up on the issue.

AMPsUSC commented 4 years ago

Thank you for your answers. Our administrator told me that the problem is not EasyBuild. He says that the problem appears when "make" calls "cmake/Modules/FetchEigen.cmake" This file has the following line: PATCH_COMMAND ${GIT_EXECUTABLE} apply ${EIGEN_PATCH} and the patch is not correctly generated. Perhaps this is the reason why it is necessary to edit the file by adding "using std::real;"

This is what our administrator told me...

AMPsUSC commented 4 years ago

Our administrators finally solved the problem by modifying the file FetchEigen.cmake that is in cmake/Modules. They edited the following line:

PATCH_COMMAND ${GIT_EXECUTABLE} apply ${EIGEN_PATCH}

to:

PATCH_COMMAND ${GIT_EXECUTABLE} apply ${EIGEN_PATCH} && cd ${CMAKE_CURRENT_SOURCE_DIR}/include && ${GIT_EXECUTABLE} apply ${EIGEN_PATCH}

mquevill commented 4 years ago

The issue comes from a slightly incorrect chain of commands within CMake. We have fixed the issue and will be releasing a new version (v0.9.2) soon that will address this bug. However, the version that you have now compiled should be functionally the same.