Installing open-mpi on Mac

October 24 2013

This is a guide for installing open-mpi and Rmpi on Mac OSX.
Open-mpi is open source mpi library such allows scalable and parallel processing. To install open-mpi, you will need to install Homebrew first. Then install gfortran and open-mpi

brew install gfortran
brew install open-mpi

You will need a C complier. For OSX 10.9, see Configuring complier for R 3.0.1 on OSX 10.9 Mavericks. For previous OS, the default llvm-gcc complier should work fine most of the time.

Final step, either open R in terminal or R GUI, and run

install.packages("Rmpi", type="source")

This should install Rmpi.

To test Rmpi

library(Rmpi)
mpi.spawn.Rslaves()
mpi.iparReplicate(100, mean(rnorm(1000000)))
mpi.close.Rslaves()

Note: If you compile your own R, or install R via Homebrew or macport, it is more likely that Rmpi will fail to detect number of cores via mpi.universe.size(). In this case, you may need to specify the number of salves.

library(Rmpi)
mpi.spawn.Rslaves(nslaves=3)
mpi.iparReplicate(100, mean(rnorm(1000000)))
mpi.close.Rslaves()

blog comments powered by Disqus