r_tist
r_tist

Reputation: 41

Set libblas and liblapack used by R per user (not global/systemwide) Debian Linux 10

I can set the default BLAS/LAPACK for my system and subsequently used by R via:

sudo update-alternatives --config libblas.so.3-x86_64-linux-gnu
sudo update-alternatives --config liblapack.so.3-x86_64-linux-gnu

which updates the BLAS/LAPACK used for all users. I would like to pick a BLAS/LAPACK without effecting the BLAS/LAPACK usage in R for all other users.

I have also tried changing my $LD_LIBRARY_PATH in my .bashrc to:

LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/openblas:$LD_LIBRARY_PATH"; export LD_LIBRARY_PATH

without changing (even after logging out and in again) the default BLAS/LAPACK used by R (checked by sessionInfo()).

Seperate VMs for users would work and maybe Docker, but I'm hoping for a simpler solution.

Upvotes: 1

Views: 990

Answers (1)

r_tist
r_tist

Reputation: 41

Was able to solve this question using the following sources: https://www.r-bloggers.com/2020/10/installing-and-switching-to-mkl-on-fedora/ and https://www.r-bloggers.com/2020/10/switch-blas-lapack-without-leaving-your-r-session/.

In short, I used R's flexiblast library, itself a wrapper around flexiblas to indicate which BLAS/LAPACK to use for each user. After changing the system-wide BLAS/LAPACK to flexiblas, I included the following lines in my .Rprofile

library(flexiblas)
flexiblas_load_backend('OPENBLASPTHREAD')
# [1] 2
flexiblas_switch(2)

or when I want to load the Intel MKL BLAS/LAPACK which isn't installed under /usr/lib/x86_64-linux-gnu/ and thus not recognized by name like OPENBLASPTHREAD:

library(flexiblas)
flexiblas_load_backend("/opt/intel/mkl/lib/intel64/libmkl_rt.so")
# [1] 2
flexiblas_switch(2)

Upvotes: 3

Related Questions