How to get Math Libraries in
Vanilla R like MicRosoft R
❇ The Bottom Line (at the top)
Revolutions R came along around 2007 and provided more powerful R computing... it was freeware, but as I recall you had to register to get it. A few years later, Microsoft bought it and called it Microsoft R Open. It was freeware, no registration needed. The version has been stuck at 3.5.3 since April 2019 with no word from the company about future support. Here are some alternatives from the discussion Stackoverflow [Linking Intel's Math Kernel Library (MKL) to R on Windows].
This discussion may be moot as there are signs of life:
https://twitter.com/revodavid/status/1290779094087380992.
BUT I found this from 2019, so it all may be BS: Microsoft R Open 3.6.0, based on the recently-released R 3.6.0, is currently under development, and we'll make an announcement here when it's available too:
from this page... never happened.
At this point you have 4 choices. First, is to just use Microsoft R Open v3.5.3 (and email them daily asking about its status). I still have and use it - it's the fastest choice so far. Second, you can update it easily to R version 3.6. Third, you can update it to R version 4.0 (and possibly beyond) but there's a drawback in that Intel doesn't just give the MKL library away. You have register and maybe pay for it. Or fourth, do nothing now and keep waiting.
These notes are for Windows. If you run Linux, then go to MKL4DEB for details.
❇ Just Use Microsoft R Open v3.5.3
This is almost as easy as doing nothing. Install Microsoft R Open from https://mran.microsoft.com/download, which comes with the outdated R version 3.5.3 but also with the Intel MKL multithreaded BLAS libraries. I should mention that packages are frozen in time, so if it worked then, it will work now (see reproducibility). Most likely any suggestion below this one violates Intel's or Microsoft's terms of agreement.
❇ Enhance R version 3.6
I'm listing the method that worked for me and was easy because I already had Microsoft R installed. Other solutions exist that are more robust, but this version is easy if you just want to stay at R v3.6. The solution listed here is due to Tom Wenseleers, but there are others listed on that page.
- Install Microsoft R Open v3.5.3 from https://mran.microsoft.com/download. (skip this step if you have it)
- Install version 3.6.3 of R from https://cran.r-project.org/bin/windows/base/old/. (skip this step if you have it)
- Copy files
libiomp5md.dll
,Rblas.dll
andRlapack.dll
fromC:\Program Files\Microsoft\R Open\R-3.5.3\bin\x64
toC:\Program Files\R\R-3.6.3\bin\x64
(you can back up your existing default non-hyperthreaded Rblas.dll to Rblas.dll.bak and Rlapack.dll to Rlapack.dll.bak first if you like). - Copy Microsoft R Open libraries/packages
MicrosoftR
,RevoIOQ
,RevoMods
,RevoUtils
,RevoUtilsMath
anddoParallel
fromC:\Program Files\Microsoft\R Open\R-3.5.5\library
to your default package directory, e.g.C:\Documents\R\win-library\3.6
- Copy files
Rprofile.site
andRenviron.site
from directoryC:\Program Files\Microsoft\R Open\R-3.5.3\etc
toC:\Program Files\R\R-3.6.3\etc
- Replace line 24 in file
Rprofile.site
options(repos=r)
withoptions(repos="https://cran.rstudio.com")
[or your favourite CRAN repository - you can also use "https://cran.revolutionanalytics.com", the repository that has the latest daily builds of all packages] to make sure that it will install the latest CRAN packages as opposed to the outdated mran.microsoft.com mirror that has outdated package versions, frozen at the 15th of April 2019. Also comment out lines 153, 154 and 155 with a #. Note that this will end the reproducibility guarantee. - Install Intel MKL library. Go over there and look around to see your options, but the bottom line is you have to register and wait for approval even if you just want to try it.
- Go to the folder
C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_XXX\windows\redist\intel64\
whereXXX
is the latest version date (for me,XXX = 2020.2.254
). Paste all the CONTENT from the folderscomplier
andmkl
into the directory where R is installed, something likeC:\Program Files\R\R-4.0.??\bin\x64\
- Change
Rlapack.dll
andRblas.dll
toRlapack.dll.bak
andRblas.dll.bak
, respectively as backups. - Inside the destination folder, create 2 copies of
mkl_rt.dll
and rename the new files asRlapack.dll
andRblas.dll
and keepmkl_rt.dll
.
❇ Enhance R version 4
This is an easy update mentioned in the discussion on Stackoverflow [Linking Intel's Math Kernel Library (MKL) to R on Windows]. The big drawback is Intel's MKL library is not freeware anymore, although you may be able to get it without cost.
I got rid of v3.6, but here's a comparison of the benchmark with MRO v3.5.3 and enhanced R v4.0.0. I'm not showing what happens without the MKL libraries ... just check out the old discussion on Stackoverflow - my results were similar, about 8-10 times slower without MKL.
# Microsoft R Open 3.5.3 # The enhanced R distribution from Microsoft # Microsoft packages Copyright (C) 2019 Microsoft Corporation # # Using the Intel MKL for parallel mathematical computing (using 8 cores). # # Default CRAN mirror snapshot taken on 2019-04-15. # See: https://mran.microsoft.com/. # Singular Value Decomposition m <- 10000 n <- 2000 A <- matrix (runif (m*n),m,n) system.time (S <- svd (A,nu=0,nv=0)) user system elapsed 13.44 0.25 2.02and enhanced version 4:
# R version 4.0.0 (2020-04-24) -- "Arbor Day" # Copyright (C) 2020 The R Foundation for Statistical Computing # Platform: x86_64-w64-mingw32/x64 (64-bit) parallel::detectCores(logical = FALSE) [1] 8 # Singular Value Decomposition m <- 10000 n <- 2000 A <- matrix (runif (m*n),m,n) system.time (S <- svd (A,nu=0,nv=0)) user system elapsed 17.14 0.80 2.78