Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrosemeier/088115b2e34f319b913a to your computer and use it in GitHub Desktop.
Save mrosemeier/088115b2e34f319b913a to your computer and use it in GitHub Desktop.
How to install OpenMPI, mpi4py, PETSc and petsc4py for use with OpenMDAO on OS X and Ubuntu with Conda
  1. Prerequisites
  • Ubuntu:

    sudo apt-get install libibnetdisc-dev
    sudo apt-get install libblas-dev libatlas-dev liblapack-dev
    
  1. Install OpenMPI
  • Download OpenMPI: https://www.open-mpi.org/software/ompi/v1.10/

  • Extract and configure

    cd ~/Downloads/openmpi-1.10.1
    mkdir build
    cd build
    # I prefer to keep /usr/local clean, so I put it in /opt/openmpi
    ./configure --prefix=/opt/openmpi --with-devel-headers --enable-binaries
    make
    sudo make install
    
  • Add the following to your bash profile

    • OS X:

      export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/opt/openmpi/lib
      export PATH=${PATH}:/opt/openmpi/bin
      
    • Ubuntu:

      export LD_LIBRARY_PATH=LD_LIBRARY_PATH=/opt/openmpi/lib:$LD_LIBRARY_PATH
      export PATH=/opt/openmpi/bin:$PATH
      
  1. Activate your conda environment

  2. Install mpi4py

git clone https://github.com/mpi4py/mpi4py.git ./mpi4py.git
cd mpi4py.git
python setup.py build --mpicc=/opt/openmpi/bin/mpicc
python setup.py install
  1. PETSc and petsc4py
git clone https://bitbucket.org/petsc/petsc.git ./petsc.git
cd petsc.git
python setup.py build
python setup.py install
cd ..
git clone https://bitbucket.org/petsc/petsc4py.git ./petsc4py.git
cd petsc4py.git
python setup.py build
python setup.py install
@TPflumm
Copy link

TPflumm commented Mar 13, 2020

Thank you for your instructions. Those have helped me a lot.
I want to add that the petsc repo moved to https://github.com/petsc/petsc.git and that it has helped me to run ./configure before building/installing petsc. Best regards, Tobi

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