4

I am quite new to BLAS and Lapack setup. Executing

sessioninfo()

always returns

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

I was wondering how BLAS can be called? Because I see many forks' default matrix products have both BLAS and LAPACK.

Also, how Intel MKI can be called? I have installed it on my macOS, but still wonder how to use it.

Also, my R is 4.0.5 and macOS is macOS Big Sur 11.2.3

tobinz
  • 117
  • 1
  • 9
  • See the R Mac FAQ: https://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#Which-BLAS-is-used-and-how-can-it-be-changed_003f To use MKL on your mac I think you'll have to compile R from source with the correct configuration. (https://software.intel.com/content/www/us/en/develop/articles/using-intel-mkl-with-r.html) – MrFlick Apr 01 '21 at 19:02
  • 1
    Thanks. The first FAQ is for changing BLAS. My problem is that BLAS does not show up. – tobinz Apr 01 '21 at 19:17
  • How did you install R initially? – MrFlick Apr 01 '21 at 19:18
  • I downloaed the file ```R-4.0.5.pkg``` from https://cran.r-project.org/bin/macosx/ – tobinz Apr 01 '21 at 19:20
  • 1
    Are you using RStudio? Try running R in the terminal. Sometimes RStudio's startup environment interferes with sessionInfo/extSoftVersion BLAS detection. – PNMNS May 08 '22 at 00:42
  • @PNMNS yes, indeed, it seems RStudio interferes with the paths in R: In R terminal BLAS is found, but not in RStudio. How to fix??? – Emile Zäkiev Oct 19 '22 at 01:42

1 Answers1

-2

Please follow the below instructions, to build R with default BLAS, LAPACK using gnu compiler chain.

$ tar -xzvf R-4.0.5.tar.gz

$ cd R-4.0.5

$ ./configure

(or $./configure --with-readline=no --with-x=no if package readline and X11 is not installed)

$make

(not $ make install, so, we do not pollute system directory)

$ ldd bin/exec/R

(To make sure it will link libRblas.so although it may show that libRblas.so => not found)

For developers who have installed R, please locate the path of libRblas.so and libRlapack.so (or libR.so), for example, $cd /usr/local/lib64/R

$ cd lib

$ mv libRblas.so libRblas.so.keep

$ln –s $(MKLROOT)/mkl/lib/intel64/libmkl_rt.so libRblas.so

The same way, you can replace the LAPACK libRlapack.so library too

($mv libRlapack.so libRlapack.so.keep $ln –s $(MKLROOT)/mkl/lib/intel64/libmkl_rt.so libRlapack.so)

If you have prebuilt R with libR.so, replace it with $(MKLROOT)/mkl/lib/intel64/libmkl_rt.so

Also you can go through the below links

https://software.intel.com/content/www/us/en/develop/articles/quick-linking-intel-mkl-blas-lapack-to-r.html

https://software.intel.com/content/www/us/en/develop/articles/using-intel-mkl-with-r.html

Arpita - Intel
  • 37
  • 1
  • 10
  • OP asked for Mac OS X instructions; linux shared objects don't apply (along with general paths to BLAS libs) – Nafis S. Aug 20 '21 at 16:59