Installing Rmpi under MacOS Sierra

I recently updated my set-up, and because I use a High-Performance cluster from my University (kudos to avakas) to run various simulations and analyses, I have MPI and Rmpi installed on my laptop in order to test my scripts before submitting them to the big cluster. So I installed openmpi from homebrew very easily:

brew update
brew install open-mpi

But then I had extensive trouble installing the Rmpi package…

After extensive investigation (and google searches), I landed on this  stackoverflow thread. It turns out the problem comes from MacOS Sierra, which is generating quite long temporary folder names (by default). The solution is quite simple, simply add the following line in the openmpi-mca-params.conf  file (located in /usr/local/Cellar/open-mpi/2.1.1/etc/ if you installed openmpi from homebrew):

orte_tmpdir_base = /tmp

This avoids having to set TMPDIR every time you use MPI ! After that I was able to install Rmpi and to run it smoothly without further tuning, all from within Rstudio.


CRAN CHECK NOTE sub-directories of 1Mb or more: libs

I just released a new package on CRAN. It’s called NPflow, it performs Dirichlet process mixture of multivariate normal, skew-normal or skew t-distributions  modeling, you should check it out.

I was a little worried because the check from Travis CI was returning a NOTE. And even though the NOTEs seem like mild problems, “you should strive to eliminate all NOTEs” before submitting to CRAN !

Preparing for an email exchange with a member of the R core team, I wrote the following in the submission comments:

It seems that on LINUX architectures, the CHECK returns one NOTE because the libs subdirectory is then above the 1MB threshold. However, it seems that this NOTE only appears under LINUX, but not under Windows or OSX.
My understanding is that this inflation of the libs subdirectory is due to the use of Rcpp. Indeed, some functions of the [package name] package have been written in C++ using Rcpp. They are needed to perform [what the package do]. Without the speed up gained from those C++ functions, this package would become impractical.

Less than 12 hours later, NPflow was instead already on the CRAN. Very smooth.

OpenMP, OS-X and R

This is a quick technical post, that is as much about disseminating the information as putting it in a place where I can find it again in the future. I have been trying to use openMP in an R package that I am currently developing. OpenMP is supported by the popular gcc compiler. However, OS-X Xcode now ship with a clang compiler that does not support openMP. So first one needs to install gcc (from homebrew for instance). The thing is then to get R to actually use this gcc compiler. After many hours of struggle, I got it working by modifying the “~/.R/Makevars” file, in which clang must be replaced by gcc (or gcc-$version).

In the case where there is no .R folder and/or Makevar file, just create one. In order to replace clang by gcc, the two following lines suffice:


gcc-4.9 can of course be replace by any other compiler  you might want to use ( such as another version of gcc for instance), and an absolute path to the compiler can also be specified (see comment from kamvarz below)

RcppAramdillo & OS X Mavericks configuration

I am in the process of speeding up some code, and I have been lured by the promises of Rcpp. Since the functions I am working on are mainly linear algebra, I wanted to try out RcppArmadillo. This put my googling skills to a test as I spent (way) too much time trying to figure out errors until I found this post. Thank you James Balamuta ! Be warned RcppArmadillo, microbenchmarking is on !