Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6015

MPI_Comm_size always return 1 after upgrading to Ubuntu 24.04.1 [duplicate]

$
0
0

After upgrading to Ubuntu 24.04.1, I encountered issues with my MPI installation. I am using MPICH and cannot switch to OpenMPI, as it appears to be incompatible a library I use. If I run a C++ program with mpirun -np 4, the result of the function MPI_Comm_size is always 1, while MPI_Comm_rank returns 0.

To highlight the issue, here is a minimal "Hello world" code:

#include <mpi.h>#include <iostream>int main(int argc, char** argv) {MPI_Init(&argc, &argv);int world_size;MPI_Comm_size(MPI_COMM_WORLD, &world_size);int world_rank;MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);std::cout << "Hello from processor " << world_rank;std::cout << " of " << world_size << std::endl;MPI_Finalize();return 0;}

To compile, I run the command mpic++ -o hello_world hello_world.cpp. There is apparently no errors. Then, to execute, I use mpirun -np 4 ./hello_world and obtain the following result:

Hello from processor 0 of 1Hello from processor 0 of 1Hello from processor 0 of 1Hello from processor 0 of 1

I tried mpiexec instead of mpirun but it gives the same result. What I am expecting is something like

Hello from processor 2 of 4Hello from processor 0 of 4Hello from processor 1 of 4Hello from processor 3 of 4

I tried to purge the package mpich using apt-get purge mpich, remove everything left with sudo apt-get autoremove and then reinstall it but I got the same result... I also tried to install OpenMPI instead of MPICH and this gave me the expected result with the minimal code given above. Unfortunately I am using MPI with a library (FreeFem) which seems to not support OpenMPI. I cannot compile it if I have the OpenMPI installation. With MPICH, the compilation of the library works, but then I have the same issue as the one outlined above. So I need to fix my MPICH installation. Everything was perfectly working before the Ubuntu upgrade.


Viewing all articles
Browse latest Browse all 6015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>