Compiling R with multi-threaded linear algebra libraries on Ubuntu


You may have an R setup that is not using hardware resources in an efficient way.

Linear algebra libraries such as OpenBLAS and Intel MKL can compute matrix/vector operations with all available processing power to significantly reduce computation times.

Use apt-get instead of compiling sources

If you prefer to use apt-get there is an option. Intel MKL is hardware specific while OpenBLAS boosts operations both for Intel and AMD

To install R linked to Intel MKL, Dirk Eddelbuettel’s blog provides detailed instructions.

To install R linked to OpenBLAS you only need this:

sudo apt-get update
sudo apt-get install libopenblas-base r-base

Compiling sources

I’ll stick to R 3.4.2 that is what I use at work.

R linked to MKL

You need to install MKL first. You can either use apt-get or download the installer. I have downloaded the installer.

Install MKL

Compile R

R linked to OpenBLAS

Compile R