Cmake doesnot find the correct path for open-mpi - performs multiple runs when using mpi

I am trying to use lammps in my university’s HPC cluster. I have a local installation of lammps(Nov 2023 ver) in my user account which I got from the git repository. I load the gnu12 and the open-mpi modules and tried to build my lammps with cmake. When running the script, the machine runs multiple instances of lammps instead of MPI. (shown below)

OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task
LAMMPS (21 Nov 2023)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task
New timer settings: style=normal mode=nosync timeout=00:00:00
New timer settings: style=normal mode=nosync timeout=00:00:00
New timer settings: style=normal mode=nosync timeout=00:00:00
New timer settings: style=normal mode=nosync timeout=00:00:00
LAMMPS (21 Nov 2023)
New timer settings: style=normal mode=nosync timeout=00:00:00
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task
LAMMPS (21 Nov 2023)
New timer settings: style=normal mode=nosync timeout=00:00:00
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task
LAMMPS (21 Nov 2023)
New timer settings: style=normal mode=nosync timeout=00:00:00
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
using 1 OpenMP thread(s) per MPI task
New timer settings: style=normal mode=nosync timeout=00:00:00
New timer settings: style=normal mode=nosync timeout=00:00:00
.
.
.

Now when I try it with traditional make it works as expected with n x n x m processor grid. The problem only arises when building through cmake and when running in the computing nodes; if I run the cmake-built lammps in the user node it it works as expected too.

Below I have the information that was in the CMakeCache.txt file

//Executable for running MPI programs.
MPIEXEC_EXECUTABLE:FILEPATH=/users/username/miniconda3/bin/mpiexec

//Maximum number of processors available to run MPI applications.
MPIEXEC_MAX_NUMPROCS:STRING=20

//Flag used by MPI to specify the number of processes for mpiexec;
// the next option will be the number of processes.
MPIEXEC_NUMPROC_FLAG:STRING=-n

//These flags will be placed after all flags passed to mpiexec.
MPIEXEC_POSTFLAGS:STRING=

//These flags will be directly before the executable that is being
// run by mpiexec.
MPIEXEC_PREFLAGS:STRING=

//MPI CXX additional include directories
MPI_CXX_ADDITIONAL_INCLUDE_DIRS:STRING=

//MPI compiler for CXX
MPI_CXX_COMPILER:FILEPATH=/users/username/miniconda3/bin/mpicxx

//MPI CXX compiler wrapper include directories
MPI_CXX_COMPILER_INCLUDE_DIRS:STRING=/users/username/miniconda3/include;/users/username/miniconda3/include;/users/username/miniconda3/include

//MPI CXX compilation definitions
MPI_CXX_COMPILE_DEFINITIONS:STRING=MPICH_SKIP_MPICXX;OMPI_SKIP_MPICXX;_MPICC_H

//MPI CXX compilation options
MPI_CXX_COMPILE_OPTIONS:STRING=

//Path to a file.
MPI_CXX_HEADER_DIR:PATH=/users/username/miniconda3/include

//MPI CXX libraries to link against
MPI_CXX_LIB_NAMES:STRING=mpicxx;mpi

//MPI CXX linker flags
MPI_CXX_LINK_FLAGS:STRING=-Wl,-rpath,/users/username/miniconda3/lib -Wl,-rpath -Wl,/users/username/miniconda3/lib -Wl,–enable-new-dtags

//If true, the MPI-2 C++ bindings are disabled using definitions.
MPI_CXX_SKIP_MPICXX:BOOL=FALSE

//Location of the mpi library for MPI
MPI_mpi_LIBRARY:FILEPATH=/users/username/miniconda3/lib/libmpi.so

//Location of the mpicxx library for MPI
MPI_mpicxx_LIBRARY:FILEPATH=/users/username/miniconda3/lib/libmpicxx.so

//CXX compiler flags for OpenMP parallelization
OpenMP_CXX_FLAGS:STRING=-fopenmp

//CXX compiler libraries for OpenMP parallelization
OpenMP_CXX_LIB_NAMES:STRING=gomp;pthread

//Path to the gomp library for OpenMP
OpenMP_gomp_LIBRARY:FILEPATH=/users/username/miniconda3/lib/libgomp.so

//Path to the pthread library for OpenMP
OpenMP_pthread_LIBRARY:FILEPATH=/users/username/miniconda3/x86_64-conda-linux-gnu/sysroot/usr/lib64/libpthread.so

It seems like Cmake is not being able to find the loaded open-mpi modules provided by my university cluster and instead uses the version of MPICH and OPEMMPI from conda. Is that what is causing the problem? I also do not understand why building using traditional make works perfectly.

Don’t use conda on a cluster, or - better yet - don’t use conda at all. While convenient, it keeps messing up things all the time and thus causing more trouble than what it solves.

CMake picks up what is the apparent default MPI at the moment you run it. You can find in the CMake documentation how you can direct it how to find the MPI installation you want (make sure you look at the documentation for your version of CMake): FindMPI — CMake 3.28.3 Documentation

1 Like

Thank you so much for the help! I removed miniconda and reinstalled and rebuilt lammps with my HPC’s modules only. Now it is working!!

2 Likes

Thanks for reporting back.

1 Like