Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
For whatever reason, Apple decided not to include OpenMPI in Mac OS X Lion (it was supported in Leopard and Snow Leopard). I found this out the hard way after doing a clean install of Lion.
Here are steps to install OpenMPI and get it working with the Rmpi
package in R
. One benefit of doing it this way is that you get the latest version of OpenMPI.
Step 1 – Install MacPorts
MacPorts is a great tool to compile and install many packages with ease, including OpenMPI. Install MacPorts by following the instructions on this page. Note that you will need to install Xcode off the App Store first.
Step 2 – Install OpenMPI on MacPorts
At the time of this posting, according to this ticket there is a problem compiling OpenMPI on Lion. To get around this, append the following block of code to: /opt/local/var/macports/sources/rsync.macports.org/release/ports/science/openmpi/Portfile
if {${configure.compiler} == "llvm-gcc-4.2"} { configure.compiler clang }
Update: This issue has been fixed.
then in Terminal, run:
sudo port install openmpi
Note that gcc44
and openmpi
will take a while to build (several hours on my Macbook Air).
Step 3 – Compile and Install Rmpi
It’s best to compile the latest version from source. Download the .tar.gz
file from the Rmpi site (at the time of this post, the latest version is 0.6-0 on the developer branch). Then in Terminal, install the package pointing to the proper OpenMPI directory paths with:
R CMD INSTALL --configure-args="--with-Rmpi-include=/opt/local/include/openmpi --with-Rmpi-libpath=/opt/local/lib --with-Rmpi-type=OPENMPI" Rmpi_0.6-0.tar.gz
You can try to load the library in R
and run a few test lines to make sure everything is configured properly.
library(Rmpi) mpi.spawn.Rslaves(nslaves=2) mpi.remote.exec(runif(5)) mpi.close.Rslaves()
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.