xcfem / xc

finite element analysis package for civil engineering structures.
http://www.xcengineering.xyz/html_files/software.html
GNU General Public License v3.0
270 stars 54 forks source link

Could not find MPI (missing: MPI_Fortran_FOUND) error in CMake. #133

Closed lokitkhemka closed 1 day ago

lokitkhemka commented 3 days ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Just trying to build the library

Expected behavior Should build, but not because CMake never finds MPI Fortran.

Screenshots

CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find MPI (missing: MPI_Fortran_FOUND) (found version "3.1")
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.22/Modules/FindMPI.cmake:1830 (find_package_handle_standard_args)
  /home/loki/Desktop/xc/CMake/find_packages.cmake:67 (find_package)
  CMakeLists.txt:79 (INCLUDE)

Desktop (please complete the following information):

Additional context I have MPI installed from Intel OneAPI toolkit, but I don't know how to properly set those variables. CMake nevers finds MPI Fortran ever.

lcpt commented 3 days ago

Hello.

I think the problem could be related to the "flavor" of your MPI libraries (aka Intel OneAPI toolkit). I've found some related information here, but, apparently, there is nothing to do to "adapt" the CMake setup.

On the other hand, if you make a Google search for cmake mpi_fortran intel one api it gives some results that seem "promising". Could you take a look and see if someone has solved the same problem before?

Which FORTRAN compiler do you use, Intel or GNU?

lokitkhemka commented 3 days ago

I don't use any FORTRAN compiler. I have gfortran installed in my machine. However, I don't know to include anything in CMake. It is not clear.

lokitkhemka commented 3 days ago

mpi_fortran These are my mpi_fortran settings if it helps.

lokitkhemka commented 2 days ago

I removed the MPI required from findpackages.cmake, just to see if it will build.

I get the error:

[ 18%] Building CXX object CMakeFiles/XcBib.dir/utility/actor/address/MPI_ChannelAddress.cpp.o
In file included from /usr/include/x86_64-linux-gnu/mpi/mpi.h:2887,
                 from /home/loki/Desktop/xc/src/utility/actor/address/MPI_ChannelAddress.h:66,
                 from /home/loki/Desktop/xc/src/utility/actor/address/MPI_ChannelAddress.cpp:62:
/usr/include/x86_64-linux-gnu/mpi/openmpi/ompi/mpi/cxx/mpicxx.h:191:10: fatal error: openmpi/ompi/mpi/cxx/constants.h: No such file or directory
  191 | #include "openmpi/ompi/mpi/cxx/constants.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I have tried setting the following as MPI CXX variables:

//MPI CXX additional include directories
MPI_CXX_ADDITIONAL_INCLUDE_DIRS:STRING=/usr/include/x86_64-linux-gnu/mpi

//MPI compiler for CXX
MPI_CXX_COMPILER:FILEPATH=/usr/local/bin/mpicxx

//MPI CXX compiler wrapper include directories
MPI_CXX_COMPILER_INCLUDE_DIRS:STRING=/usr/include/x86_64-linux-gnu/mpi/openmpi/ompi/mpi/cxx

//MPI CXX compilation definitions
MPI_CXX_COMPILE_DEFINITIONS:STRING=

//MPI CXX compilation options
MPI_CXX_COMPILE_OPTIONS:STRING=

//Path to a file.
MPI_CXX_HEADER_DIR:PATH=/usr/local/include

I hope this gives you more information.

lcpt commented 2 days ago

mpi_fortran These are my mpi_fortran settings if it helps.

As you can see, all the variables point to openmpi directories, so CMake expects to found the MPI related stuff there. I suppose the Intel OneAPI toolkit installs those libraries elsewhere (perhaps under the /opt or the /usr/local directories). It would be useful to know where are installed those libraries. If necessary, you can always write an alternate FindMPI.cmake.

lcpt commented 2 days ago

I removed the MPI required from findpackages.cmake, just to see if it will build.

I get the error:

[ 18%] Building CXX object CMakeFiles/XcBib.dir/utility/actor/address/MPI_ChannelAddress.cpp.o
In file included from /usr/include/x86_64-linux-gnu/mpi/mpi.h:2887,
                 from /home/loki/Desktop/xc/src/utility/actor/address/MPI_ChannelAddress.h:66,
                 from /home/loki/Desktop/xc/src/utility/actor/address/MPI_ChannelAddress.cpp:62:
/usr/include/x86_64-linux-gnu/mpi/openmpi/ompi/mpi/cxx/mpicxx.h:191:10: fatal error: openmpi/ompi/mpi/cxx/constants.h: No such file or directory
  191 | #include "openmpi/ompi/mpi/cxx/constants.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I have tried setting the following as MPI CXX variables:

//MPI CXX additional include directories
MPI_CXX_ADDITIONAL_INCLUDE_DIRS:STRING=/usr/include/x86_64-linux-gnu/mpi

//MPI compiler for CXX
MPI_CXX_COMPILER:FILEPATH=/usr/local/bin/mpicxx

//MPI CXX compiler wrapper include directories
MPI_CXX_COMPILER_INCLUDE_DIRS:STRING=/usr/include/x86_64-linux-gnu/mpi/openmpi/ompi/mpi/cxx

//MPI CXX compilation definitions
MPI_CXX_COMPILE_DEFINITIONS:STRING=

//MPI CXX compilation options
MPI_CXX_COMPILE_OPTIONS:STRING=

//Path to a file.
MPI_CXX_HEADER_DIR:PATH=/usr/local/include

I hope this gives you more information.

Have you installed openmpi (I mean the libopenmpi-dev package and its companion)? In this case, maybe there is a conflict with the Intel OneAPI counterpart.

lcpt commented 2 days ago

Concerning the FORTRAN compiler, a small part of the code is written in FORTRAN, that's why I asked about it.

lokitkhemka commented 2 days ago

I removed every thing related to MPI, i.e., both libopenmpi-dev and Intel OneAPI. and then installed libopenmpi-dev. However, I get the following warnings and errors:

CMake Warning at /home/loki/Desktop/xc/build/CMakeFiles/CMakeTmp/CMakeLists.txt:18 (add_executable):
  Cannot generate a safe runtime search path for target cmTC_dc04d because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libhwloc.so.15] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_core-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_pthreads-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib

  Some of these libraries may not be found correctly.

CMake Warning at /home/loki/Desktop/xc/build/CMakeFiles/CMakeTmp/CMakeLists.txt:18 (add_executable):
  Cannot generate a safe runtime search path for target cmTC_b87a8 because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libhwloc.so.15] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_core-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_pthreads-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib

  Some of these libraries may not be found correctly.

CMake Warning at /home/loki/Desktop/xc/build/CMakeFiles/CMakeTmp/CMakeLists.txt:18 (add_executable):
  Cannot generate a safe runtime search path for target cmTC_8fad2 because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libhwloc.so.15] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_core-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_pthreads-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib

  Some of these libraries may not be found correctly.

CMake Warning at /home/loki/Desktop/xc/build/CMakeFiles/CMakeTmp/CMakeLists.txt:18 (add_executable):
  Cannot generate a safe runtime search path for target cmTC_0e2c8 because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libhwloc.so.15] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_core-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_pthreads-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib

  Some of these libraries may not be found correctly.

Could NOT find MPI_Fortran (missing: MPI_Fortran_WORKS) 
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find MPI (missing: MPI_Fortran_FOUND) (found version "3.1")
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.22/Modules/FindMPI.cmake:1830 (find_package_handle_standard_args)
  /home/loki/Desktop/xc/CMake/find_packages.cmake:67 (find_package)
  CMakeLists.txt:79 (INCLUDE)

In the end, the error is the same.

lokitkhemka commented 2 days ago

Is there no way to build without MPI? It is just not worth the effort.

lcpt commented 2 days ago

I removed every thing related to MPI, i.e., both libopenmpi-dev and Intel OneAPI. and then installed libopenmpi-dev. However, I get the following warnings and errors:

CMake Warning at /home/loki/Desktop/xc/build/CMakeFiles/CMakeTmp/CMakeLists.txt:18 (add_executable):
  Cannot generate a safe runtime search path for target cmTC_dc04d because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libhwloc.so.15] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_core-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_pthreads-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib

  Some of these libraries may not be found correctly.

CMake Warning at /home/loki/Desktop/xc/build/CMakeFiles/CMakeTmp/CMakeLists.txt:18 (add_executable):
  Cannot generate a safe runtime search path for target cmTC_b87a8 because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libhwloc.so.15] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_core-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_pthreads-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib

  Some of these libraries may not be found correctly.

CMake Warning at /home/loki/Desktop/xc/build/CMakeFiles/CMakeTmp/CMakeLists.txt:18 (add_executable):
  Cannot generate a safe runtime search path for target cmTC_8fad2 because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libhwloc.so.15] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_core-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_pthreads-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib

  Some of these libraries may not be found correctly.

CMake Warning at /home/loki/Desktop/xc/build/CMakeFiles/CMakeTmp/CMakeLists.txt:18 (add_executable):
  Cannot generate a safe runtime search path for target cmTC_0e2c8 because
  files in some directories may conflict with libraries in implicit
  directories:

    runtime library [libhwloc.so.15] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_core-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libevent_pthreads-2.1.so.7] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib
    runtime library [libz.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
      /usr/local/lib

  Some of these libraries may not be found correctly.

Could NOT find MPI_Fortran (missing: MPI_Fortran_WORKS) 
CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find MPI (missing: MPI_Fortran_FOUND) (found version "3.1")
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.22/Modules/FindMPI.cmake:1830 (find_package_handle_standard_args)
  /home/loki/Desktop/xc/CMake/find_packages.cmake:67 (find_package)
  CMakeLists.txt:79 (INCLUDE)

In the end, the error is the same.

Have you wiped out the build directory? Sometimes the problem is that CMake stores the previous setup in CMakeCache.txt and this gives a lot of headaches. Try to remove everything in the build directory and run CMake again.

lcpt commented 2 days ago

Is there no way to build without MPI? It is just not worth the effort.

Why do you think it is not worth the effort? When FE models become big, MPI can save a lot of computation time.

lokitkhemka commented 2 days ago

I want to run small models, to be honest. Like no more than 10^4 elements. Still, I have some progress, I deleted usr/local/ folder to remove warnings. While CMake is generating the makefile just fine. I get the error:

In file included from /usr/include/x86_64-linux-gnu/mpi/mpi.h:2887,
                 from /home/loki/Desktop/xc/src/utility/actor/channel/MPI_Channel.h:62,
                 from /home/loki/Desktop/xc/src/utility/actor/machineBroker/MPI_MachineBroker.cpp:58:
/usr/include/x86_64-linux-gnu/mpi/openmpi/ompi/mpi/cxx/mpicxx.h:39:10: fatal error: mpi.h: No such file or directory
   39 | #include "mpi.h"
      |          ^~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/XcBib.dir/build.make:664: CMakeFiles/XcBib.dir/utility/actor/channel/MPI_Channel.cpp.o] Error 1

during compilation. Please help. I am really really close.

lcpt commented 2 days ago

Have you installed libopenmpi-dev?

lokitkhemka commented 1 day ago

Yes I did install libopenmpi-dev and openmpi-bin. Should I remove openmpi-bin?

lcpt commented 1 day ago

Yes I did install libopenmpi-dev and openmpi-bin. Should I remove openmpi-bin?

No, the first one contains the required headers, among others, mpi.h.

lcpt commented 1 day ago

I want to run small models, to be honest. Like no more than 10^4 elements. Still, I have some progress, I deleted usr/local/ folder to remove warnings. While CMake is generating the makefile just fine. I get the error:

In file included from /usr/include/x86_64-linux-gnu/mpi/mpi.h:2887,
                 from /home/loki/Desktop/xc/src/utility/actor/channel/MPI_Channel.h:62,
                 from /home/loki/Desktop/xc/src/utility/actor/machineBroker/MPI_MachineBroker.cpp:58:
/usr/include/x86_64-linux-gnu/mpi/openmpi/ompi/mpi/cxx/mpicxx.h:39:10: fatal error: mpi.h: No such file or directory
   39 | #include "mpi.h"
      |          ^~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/XcBib.dir/build.make:664: CMakeFiles/XcBib.dir/utility/actor/channel/MPI_Channel.cpp.o] Error 1

during compilation. Please help. I am really really close.

Have you deleted the whole usr/local directory? No, you deleted only the directory where you perform the compilation, right?

On the other hand, have you restored the find_package(MPI REQUIRED) line in find_packages.cmake?

lokitkhemka commented 1 day ago

Yes. I had done all that. Anyway, I managed to get it working by installing a fresh ubuntu instance on WSL. And now it working fine. Thank you for all your help.

lcpt commented 1 day ago

Yes. I had done all that. Anyway, I managed to get it working by installing a fresh ubuntu instance on WSL. And now it working fine. Thank you for all your help.

Glad to hear that. With pleasure.