Skip to content

Instantly share code, notes, and snippets.

@ozooxo
Last active May 15, 2019 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozooxo/9280304 to your computer and use it in GitHub Desktop.
Save ozooxo/9280304 to your computer and use it in GitHub Desktop.
MPI always gives rank=0, size = 1

I accidentally installed multiple versions of MPI's (openmpi, mpich2, ...) in my Ubuntu 12.04 machine. I removed them all, and installed openmpi again; however, after fixing that (I never try before that), my MPI always gives rank=0, size = 1. The reason is that the removal process is incomplete, hence causes file sharing conflict. It can be seen from the following test

beta@landmark:~$ whereis mpicc
mpicc: /usr/bin/mpicc.mpich2 /usr/bin/mpicc.openmpi /usr/bin/mpicc 
/usr/bin/X11/mpicc.mpich2 /usr/bin/X11/mpicc.openmpi /usr/bin/X11/mpicc 
/usr/share/man/man1/mpicc.1.gz

It turns out that the packages libmpich2-3 and libmpich2-dev failed to be removed. So after apt-get remove libmpich2-3 libmpich2-dev, everything goes fine.

beta@landmark:~$ mpicc -o hello_mpi hello_mpi.c
beta@landmark:~$ mpirun -np 4 ./hello_mpi
Hello World from processor 0 out of 4, executing on landmark
Hello World from processor 1 out of 4, executing on landmark
Hello World from processor 2 out of 4, executing on landmark
Hello World from processor 3 out of 4, executing on landmark
@VSMent
Copy link

VSMent commented May 15, 2019

Thanks. It worked for me too. However, my packages were little different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment