Last active
December 14, 2023 14:55
-
-
Save crabba/ea7466c56047e3009da225204ff40b46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Process to build R with MKL support on Amazon Linux 2 | |
# Install R v4 | |
sudo amazon-linux-extras install R4 | |
wget https://mac.r-project.org/benchmarks/R-benchmark-25.R | |
which R # /usr/bin/R | |
R --version # 4.0.2 | |
# Install Intel MKL library | |
# https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-download.html?operatingsystem=linux&distributions=yumpackagemanager | |
tee > /tmp/oneAPI.repo << EOF | |
[oneAPI] | |
name=Intel® oneAPI repository | |
baseurl=https://yum.repos.intel.com/oneapi | |
enabled=1 | |
gpgcheck=1 | |
repo_gpgcheck=1 | |
gpgkey=https://yum.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | |
EOF | |
sudo mv /tmp/oneAPI.repo /etc/yum.repos.d | |
sudo yum install -y intel-basekit # Not necessary? | |
sudo yum install -y intel-oneapi-mkl | |
# Build tools | |
sudo yum groupinstall -y "Development Tools" | |
sudo yum install -y readline-devel libXt-devel libcurl-devel | |
# Hack for make install. Need to be present before ./configure. | |
sudo mkdir -p /opt/intel/oneapi/{2024.0/lib,redist/lib} | |
sudo ln -s /opt/intel/oneapi/mkl/2024.0/lib/libmkl_gf_lp64.so.2 /opt/intel/oneapi/2024.0/lib/libmkl_gf_lp64.so.2 | |
sudo ln -s /opt/intel/oneapi/mkl/2024.0/lib/libmkl_gf_lp64.so.2 /opt/intel/oneapi/redist/lib/libmkl_gf_lp64.so.2 | |
# Build R with MKL support | |
# https://www.intel.com/content/www/us/en/developer/articles/technical/using-onemkl-with-r.html | |
wget https://cran.r-project.org/src/base/R-4/R-4.3.2.tar.gz | |
gunzip --force R-4.3.2.tar.gz | |
tar xf R-4.3.2.tar | |
cd R-4.3.2 | |
source /opt/intel/oneapi/setvars.sh intel64 ## NOTE key difference from Intel instructions on above page | |
MKL="-Wl,--no-as-needed -lmkl_gf_lp64 -Wl,--start-group -lmkl_gnu_thread -lmkl_core -Wl,--end-group -fopenmp -ldl -lpthread -lm" | |
./configure --with-blas="$MKL" --with-lapack | |
make || exit | |
sudo make install | |
# Tests | |
cd | |
time /usr/bin/R < R-benchmark-25.R --save # System R | |
time /usr/local/bin/R < R-benchmark-25.R --save # Compiled R | |
# Are we using MKL? | |
/usr/bin/R -q -e 'sessionInfo()' # System R | |
/usr/local/bin/R -q -e 'sessionInfo()' # Compiled R |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
systemInfo()
:BLAS/LAPACK: /opt/intel/oneapi/mkl/2024.0/lib/libmkl_gf_lp64.so.2; LAPACK version 3.10.1
BLAS: /usr/local/lib64/R/lib/libRblas.so
LAPACK: /usr/local/lib64/R/lib/libRlapack.so; LAPACK version 3.11.0
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so