Skip to content

Instantly share code, notes, and snippets.

@seananderson
Last active May 31, 2024 18:36
Show Gist options
  • Save seananderson/08a51e296a854f227a908ddd365fb9c1 to your computer and use it in GitHub Desktop.
Save seananderson/08a51e296a854f227a908ddd365fb9c1 to your computer and use it in GitHub Desktop.
OpenBLAS on in Windows without admin privileges

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:

  1. Download the latest R installer.
  2. Run the installer and select a user folder for installation when prompted, e.g. C:\Users\USERNAME\SUBFOLDER.
  3. 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.
  4. Download OpenBLAS following these instructions. A summarized version of this and subsequent steps follows.
  5. Extract libopenblas.dll from the OpenBLAS zip file.
  6. Rename or move Rblas.dll and Rlapack.dll from the R\R-4.X.X\bin\x64 subfolder (where X.X represents version numbers). Make sure you are doing so from the R installation in your user folder that you just made.
  7. Paste two copies of libopenblas.dll into the same folder as above and rename them Rblas.dll and Rlapack.dll.
  8. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment