Search code examples
rcondaintel-mklmicrosoft-r

Conda install r-essentials with MKL


On my RHEL-server I do not have admin rights, but I can create Conda environments. I would like to create a Conda environment running R with Intel MKL (Intel® Math Kernel Library).

I create the environment with R_defaults.yml, running $> conda env create --file R_defaults.yml:

name: R_defaults
channels:
  - defaults
  - conda-forge
dependencies:
  - pkgs/r::r-essentials=3.6.0=r36_0

Activating the environment, starting R, and sessionInfo() I get that MKL is not used:

R version 3.6.1 (2019-07-05)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server 7.7 (Maipo)

Matrix products: default
BLAS/LAPACK: /home/geiringe/miniconda3/envs/R_r/lib/R/lib/libRblas.so

Microsoft R Open (https://mran.microsoft.com/download) can be installed with MKL.

It seems Anaconda has changed opinions about Microsoft R Open. In June 2018 it was said to become default R for the Anaconda distribution (https://www.anaconda.com/introducing-microsoft-r-open-as-default-r-for-anaconda-distribution/). Now they want us to migrate away from Microsoft R Open, and they will not update MRO packages (https://docs.anaconda.com/anaconda/user-guide/tasks/using-r-language/#switch-an-environment-from-r-to-mro). The latest version of r::mro-base is 3.5.1, and is more than 1 year old. The latest version of r::r-essentials is 3.6.0

Is there a way for me to create a Conda environment with an updated version of R and with MKL?


Solution

  • The Anaconda r channel has been not updated in years - do not use it. Conda R users should use Conda Forge as their priority channel. To specify a BLAS/LAPACK variant, one can use the blas metapackage. The following YAML implements these recommendations:

    r_mkl.yaml

    name: r_mkl
    channels:
      - conda-forge
      - defaults
    dependencies:
      - r-base=4.2    ## specify desired R version
      - r-essentials
      - blas=*=*mkl*
    

    which can then be used like:

    conda create -n r42_mkl -f r_mkl.yaml
    

    Running this on osx-64, the output from R -e "sessionInfo()" in the activated environment shows:

    R version 4.2.2 (2022-10-31)
    Platform: x86_64-apple-darwin13.4.0 (64-bit)
    Running under: macOS Big Sur ... 10.16
    
    Matrix products: default
    BLAS/LAPACK: /Users/mfansler/miniconda3/envs/r42_mkl/lib/libmkl_rt.dylib
    
    locale:
    [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    loaded via a namespace (and not attached):
    [1] compiler_4.2.2
    

    This should behave very similarly on linux-64.