microsoft / microsoft-r-open

Microsoft R Open Source
212 stars 74 forks source link

Build R 4.0 with MKL #116

Open ixxmu opened 4 years ago

ixxmu commented 4 years ago

Update: sessionInfo shows sucess, but still work as R regular! Maybe certain environment variables failure, please help!!!

Have tested, it worked!
Not responsible for solving problems, just Goolge it!
R version 4.0.1 (2020-06-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 8 (Core)
Matrix products: default
BLAS:   /opt/biosoft/R/4.0.1/lib64/R/lib/libRblas.so
LAPACK: /opt/biosoft/R/4.0.1/lib64/R/lib/libRlapack.so
locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
loaded via a namespace (and not attached):
[1] compiler_4.0.1 tools_4.0.1   

Outline 4 steps to do

Start here

$ tar -xzvf R-4.0.1.tar.gz
$ cd R-4.0.1
$ ./configure --enable-R-shlib --prefix=/opt/xxx/R/4.0.1 --with-readline=yes --with-libpng=yes --with-readline=no --with-x=no
// **_--enable-R-shlib_  for rstudio server working, _--prefix=_ for location setting, you must set install your _R_ in _opt_ or sub except you are a Rstudio Server Pro user**
$ make
$ ldd bin/exec/R
(To make sure it will link libRblas.so although it may show that libRblas.so => not found , 
if is all right, just _sudo make install_  )
$ find / -name libRblas.so
$ cd & vi .bashrc
_export LD_LIBRARY_PATH="R-install-location/lib65/R/lib:$LD_LIBRARY_PATH"_
$ cd R-4.0.1
$ ldd bin/exec/R
$ sudo make install

type $ /opt/xxx/R/4.0.1/bin/R in your terminal, if all steps work, you will get new R with MKL specified. $ SessionInfo()

ixxmu commented 4 years ago

sessionInfo shows sucess, but still work with R regular! Maybe certain environment variables failure, please help!!!

m <- 10000 n <- 2000 A <- matrix (runif (m*n),m,n) system.time (S <- svd (A,nu=0,nv=0))

dazhwu commented 4 years ago

According to your session info, your R is base R and is not using MKL. “BLAS: /opt/biosoft/R/4.0.1/lib64/R/lib/libRblas.so LAPACK: /opt/biosoft/R/4.0.1/lib64/R/lib/libRlapack.so”

Check this: https://github.com/alexisph/high_performance_r

ixxmu commented 4 years ago

According to your session info, your R is base R and is not using MKL. “BLAS: /opt/biosoft/R/4.0.1/lib64/R/lib/libRblas.so LAPACK: /opt/biosoft/R/4.0.1/lib64/R/lib/libRlapack.so”

Check this: https://github.com/alexisph/high_performance_r

yes, i found the problem and then rebuild latest-R with intel MKL on CentOS 7

R version 4.0.1 (2020-06-06) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS Linux 7 (Core)

Matrix products: default BLAS/LAPACK: /opt/intel/compilers_and_libraries_2020.1.217/linux/mkl/lib/intel64_lin/libmkl_gf_lp64.so

mmekarnia commented 2 years ago

Hi Guys

I have the same issue that ixxmu described above .I see that he already fixed his issue but its not clear to me how he did it. I need help.

In my case i have R 3.6.3 that was build outside the box using docker and brought to the server because of root restrictions .The mkl is configured on this version and multithreading is working fine see below.

sessionInfo() R version 3.6.3 (2020-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Red Hat Enterprise Linux Server 7.9 (Maipo)

Matrix products: default BLAS/LAPACK: /app/r/lib64/R/lib/libRblas.so

locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8
[5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
[7] LC_PAPER=en_CA.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] compiler_3.6.3 tools_3.6.3

I build a new version R4.1.1 but the mkl multithreading is not working see below.

sessionInfo() R version 4.1.1 (2021-08-10) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Red Hat Enterprise Linux Server 7.9 (Maipo)

Matrix products: default BLAS: /app/R4/lib64/R/lib/libRblas.so LAPACK: /app/R4/lib64/R/lib/libRlapack.so

locale: [1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8
[5] LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
[7] LC_PAPER=en_CA.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached): [1] compiler_4.1.1 tools_4.1.1