Install OpenMPI with GNU Compilers

This guide is for someone who wants to get OpenMPI installed on a 64-bit Linux system or cluster and is still semi-new to Linux. A quick note before I get started is something that I learned along the way. If you are installing this on a cluster, then you need to make sure that you install it into a location that is either mounted across all of the nodes in your cluster (such as a location in your network file system) or that you sync the folder that you install it in across all of the nodes in your cluster (such as using rsync). For this guide, I am going to be assuming that you will be installing on a network-mounted file system (such as /share/apps or /home in Rocks).

Now that you understand that, lets get to installing OpenMPI. For this guide, I will be demonstrating how to install OpenMPI 1.4.5 because I found that many of the scientific applications (at the moment) do not work correctly with the newer versions of OpenMPI (QMCPACK and Linpack in particular).

  1. Make sure that you have the latest version of the GNU compilers installed on your system. You can download and get installation instructions here.
  2. Make sure that the following information is in your .bashrc file (if you are using RHEL or CentOS):

    # Settings
    export PATH=/gnu-dir/bin:$PATH
    export INCLUDE=/gnu-dir/include:$PATH
    export LD_LIBRARY_PATH=/gnu-dir/lib64:$PATH
    export CC=gcc
    export CFLAGS=-O3 export CXX=g++
    export CXXFLAGS=-O3
    export FC=gfortran
    export F77=gfortran
    export F90=gfortran
    export FFLAGS=-O3

  3. Now that we have the pre-requisites set up, we need to make sure that you are getting that information into your environment:
    [root@linux root] $ source /home-dir/.bashrc

  4. Go download the version of OpenMPI that you would like to use from the OpenMPI website. For this guide, I am going to use OpenMPI 1.4.5 (as I stated above).
  5. Go to the folder that you are going to be installing everything to (I will be using the /share/apps directory) and make two different directories:
    [root@linux root] $ cd /share/apps [root@linux root] $ mkdir openmpi-install [root@linux root] $ mkdir openmpi-1.4.5
  6. Untar the files into the openmpi-install directory:
    [root@linux root] $ tar -C openmpi-install -xf openmpi-1.4.5.tar.gz
  7. Go to where you just untar'd those files:
    [root@linux root] $ cd openmpi-install/openmpi-1.4.5
  8. Now we need to configure OpenMPI to make sure that we give it the prefix to where we want to install it:
    [root@linux root] $ ./configure --prefix=/share/apps/openmpi-1.4.5
  9. Now to install everything:
    [root@linux root] $ make all install
  10. Once that is completed, OpenMPI is now installed in the /share/apps/openmpi-1.4.5 directory (assuming that you didn't get any errors). Now we need to add some new things to our .bashrc file in order to allow us to call mpicc or the other compilers from the command line:

    # Settings for OpenMPI 1.4.5 export PATH=/share/apps/openmpi-1.4.5/bin:$PATH export INCLUDE=/share/apps/openmpi-1.4.5/include:$PATH export LD_LIBRARY_PATH=/share/apps/openmpi-1.4.5/lib:$LD_LIBRARY_PATH

  11. For the final step, we just need to make sure that we source our .bashrc file:
    [root@linux root] $ source /home-dir/.bashrc

After you have done all of that, you should be done. If you have any questions, feel free and reach out to me using my contact information listed above. Thanks for reading!