If you work on a Windows computer without admin privileges to modify system files (e.g., many government employees), you can likely still install R in your user folder and replace the default BLAS library there.* Instructions:
- Download the latest R installer.
- Run the installer and select a user folder for installation when prompted, e.g.
C:\Users\USERNAME\SUBFOLDER
. - In RStudio go to 'Tools' > 'Global Options' > 'General' > 'R version' to change the R installation being used to the one you just installed in your user folder.
- Download OpenBLAS following these instructions. A summarized version of this and subsequent steps follows.
- Extract
libopenblas.dll
from the OpenBLAS zip file. - Rename or move
Rblas.dll
andRlapack.dll
from theR\R-4.X.X\bin\x64
subfolder (whereX.X
represents version numbers). Make sure you are doing so from the R installation in your user folder that you just made. - Paste two copies of
libopenblas.dll
into the same folder as above and rename themRblas.dll
andRlapack.dll
. - Restart R/RStudio.
More detailed instructions from step 3 onwards are available here.
Test to make sure OpenBLAS is being used:
m <- 1e4; n <- 1e3; k <- 3e2
X <- matrix(rnorm(m*k), nrow=m); Y <- matrix(rnorm(n*k), ncol=n)
system.time(X %*% Y)
The result should look something like:
## user system elapsed
## 0.169 0.011 0.165
The standard BLAS shipped with R will likely take 1-2 seconds for the above.
*Thanks to Paul Regular and Semra Yalcin for figuring this out and to Seb Pardo for drafting the step-by-step instructions.