Using precompiled R binaries with Intel MKL

I recently installed a precompiled R binary (from RStudio) on an Ubuntu 22 system with Intel MKL, which was installed using apt and set as the default BLAS via update-alternatives as part of the installation process. As a result, R is using the Intel library for BLAS/LAPACK:

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/libmkl_rt.so

After running a logistic regression and getting absurd results, I realized (to my horror) that R will only provide correct results if the following two environment variables are set:

export MKL_INTERFACE_LAYER=GNU,LP64
export MKL_THREADING_LAYER=GNU

Thus, it seems R might never provide correct output on my system when scripts are run with --vanilla or --no-environ. So, I'm wondering:

  1. Is there a way to make R see these two environment variables no matter how it's launched?
  2. If I decide this setup is too risky, any advice for undoing this and getting back to an R with OpenBLAS or another library that doesn't require specifying environment variables?
  3. There's no warning about this. Installing intel-mkl and then using the precompiled binaries seems to result in a broken setup by default. If I continue using MKL, is there any way to make R stop automatically unless these environment variables are defined?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.