I have Ubuntu 20.04 installed and need to install OpenMPI 3.1.6 with gcc 8.4.0.
I downloaded the tar ball from OpenMPI and installed it with the following command
tar-xzf openmpi-3.1.6.tar.gz && cd openmpi-3.1.6
PARGS="env CC=/usr/bin/gcc FC=/usr/bin/gfortran CXX=/usr/bin/g++"
ARGS=" --enable-shared --enable-mpi-fortran=usempi"
ARGS+=" --enable-mpi-thread-multiple"
ARGS+=" --prefix=/openmpi/3.1.6/gcc/8.4.0"
mkdir -p build && cd build
$PARGS ../configure $ARGS
$PARGS make -j8 && make install
It installed just fine, no problems. But when I try
mpirun --version
I get the following error
Command 'mpirun' not found, but can be installed with:
and then gives various options using sudo apt-get (which is how I installed it originally, but it doesn't support 3.1.6).
I assumed it had to do with the environmental variables, that Linux just can't find the software. So I went looking and found that in the OpenMPI FAQ, it mentions the following:
"assuming that you have already adjusted your PATH and/or LD_LIBRARY_PATH environment variables to the new location where Open MPI now resides"
…but then it doesn't say how to do that. I tried searching but it talks about all kinds of different ~/.FILE (where file is bash or lib64 or lib32 or other files).
What do I actually have to change in the environment variables and in which file? I use the Ubuntu terminal for pretty much everything.
============================================
Thank you, ubfan1! I had to add the following to /.profile:
# set the OpenMPI path
export OMPI=/openmpi/3.1.6/gcc/8.4.0
export PATH=$PATH:$OMPI/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OMPI/lib
And now it works! My system can find mpirun and the version is 3.1.6!
Best Answer
Look in your home directory's .profile to see how to add things to your PATH.
Where you installed the openmpi probably has subdirectories named bin, lib64, etc. For example, $HOME/openMPI is where you selected to install it, so add $HOME/openMPI/bin to your PATH at the end of your .profile: export PATH="$HOME/openMPI/bin:$PATH" Then add the line:" export LD_LIBRARY_PATH=$HOME/openMPI/lib64 (assuming you have no existing LD_LIBRARY_PATH.) Now that you have a location ...openMPI/bin early in your PATH, you can override the standard system commands by putting new ones there, like a link named gcc to the gcc-8.4 version (which is available in 20.04). If you needed a version of gcc not available in the standard packages, you could simply put the entire executable (from wherever you get it) in place of the link. Maybe you prefer not to override gcc every time you login. In that case, just set up a script to run instead of putting the changes into your .profile.
The usual gotchas:
Your path addition probably should start with a /, so /home/openmpi/... rather than just openmpi/... However, look in the openmpi directory, and see if there is a bin directory, that is the one I expect if there are actually openmpi executables to run. Into that one you can add the gcc link to the lower level gcc...bin just to keep all the openmpi programs together. Note that the gcc 8.4 is available as a standard package in Ubuntu 20.04, but if your openmpi install has one, it's OK to use it, it just won't get any updates, if any.