Use FlexiBLAS on RHEL 9 for R 4.3.0 and above
R 4.2.3 and below continue to use shared BLAS - OpenBLAS for backward compat.
This commit is contained in:
parent
aa7531bf47
commit
0ef67edd08
4 changed files with 64 additions and 16 deletions
|
|
@ -11,6 +11,7 @@ RUN dnf -y upgrade \
|
||||||
automake \
|
automake \
|
||||||
bzip2-devel \
|
bzip2-devel \
|
||||||
cairo-devel \
|
cairo-devel \
|
||||||
|
flexiblas-devel \
|
||||||
gcc-c++ \
|
gcc-c++ \
|
||||||
gcc-gfortran \
|
gcc-gfortran \
|
||||||
java-11-openjdk-devel \
|
java-11-openjdk-devel \
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,16 @@ compile_r() {
|
||||||
|
|
||||||
CONFIGURE_OPTIONS=${CONFIGURE_OPTIONS:-$default_configure_options}
|
CONFIGURE_OPTIONS=${CONFIGURE_OPTIONS:-$default_configure_options}
|
||||||
|
|
||||||
|
# For RHEL 9, link to external FlexiBLAS starting from R 4.3.0 to align with EPEL 9
|
||||||
|
if _version_is_greater_than "${R_VERSION}" 4.2.10; then
|
||||||
|
if [[ "${OS_IDENTIFIER}" = "rhel-9" ]]; then
|
||||||
|
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS \
|
||||||
|
--with-blas=flexiblas --with-lapack=flexiblas"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Using CONFIGURE_OPTIONS: ${CONFIGURE_OPTIONS}"
|
||||||
|
|
||||||
# set some common environment variables for the configure step
|
# set some common environment variables for the configure step
|
||||||
AWK=/usr/bin/awk \
|
AWK=/usr/bin/awk \
|
||||||
LIBnn=lib \
|
LIBnn=lib \
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,20 @@ if [[ "${R_VERSION}" =~ ^3 ]]; then
|
||||||
pcre_lib='pcre-devel'
|
pcre_lib='pcre-devel'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create post-install script required for openblas
|
# Create post-install script required for OpenBLAS.
|
||||||
|
#
|
||||||
|
# On RHEL and SUSE, we link R against the internal shared BLAS to make the
|
||||||
|
# R binaries more portable and allow users to switch BLAS implementations without
|
||||||
|
# having to recompile R. We default to OpenBLAS, but users may prefer other implementations.
|
||||||
|
#
|
||||||
|
# Binary packages built against the shared BLAS are also more portable and may be used
|
||||||
|
# with the default R distributed by RHEL/SUSE, or other R installations using
|
||||||
|
# shared BLAS and configured with a different BLAS (such as Microsoft R Open with MKL).
|
||||||
|
# This is especially important for Posit Package Manager's binary packages.
|
||||||
|
#
|
||||||
|
# However, as of R 4.2.3, EPEL 8's R no longer uses shared BLAS and now links to an
|
||||||
|
# external OpenBLAS (OpenMP). This means EPEL R no longer has a swappable BLAS and
|
||||||
|
# is no longer compatible with these R builds.
|
||||||
cat <<EOF >> /post-install.sh
|
cat <<EOF >> /post-install.sh
|
||||||
mv ${R_INSTALL_PATH}/lib/R/lib/libRblas.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so.keep
|
mv ${R_INSTALL_PATH}/lib/R/lib/libRblas.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so.keep
|
||||||
ln -s /usr/lib64/libopenblasp.so.0 ${R_INSTALL_PATH}/lib/R/lib/libRblas.so
|
ln -s /usr/lib64/libopenblasp.so.0 ${R_INSTALL_PATH}/lib/R/lib/libRblas.so
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ if [[ "${R_VERSION}" =~ ^3 ]]; then
|
||||||
- pcre-devel'
|
- pcre-devel'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create post-install script required for OpenBLAS.
|
|
||||||
#
|
|
||||||
# On RHEL and SUSE, we link R against the internal shared BLAS to make the
|
# On RHEL and SUSE, we link R against the internal shared BLAS to make the
|
||||||
# R binaries more portable and allow users to switch BLAS implementations without
|
# R binaries more portable and allow users to switch BLAS implementations without
|
||||||
# having to recompile R. We default to OpenBLAS, but users may prefer other implementations.
|
# having to recompile R. We default to OpenBLAS, but users may prefer other implementations.
|
||||||
|
|
@ -20,7 +18,12 @@ fi
|
||||||
# Binary packages built against the shared BLAS are also more portable and may be used
|
# Binary packages built against the shared BLAS are also more portable and may be used
|
||||||
# with the default R distributed by RHEL/SUSE, or other R installations using
|
# with the default R distributed by RHEL/SUSE, or other R installations using
|
||||||
# shared BLAS and configured with a different BLAS (such as Microsoft R Open with MKL).
|
# shared BLAS and configured with a different BLAS (such as Microsoft R Open with MKL).
|
||||||
# This is especially important for RSPM's binary packages.
|
# This is especially important for Posit Package Manager's binary packages.
|
||||||
|
#
|
||||||
|
# However, EPEL 9's R now links externally against FlexiBLAS, which provides a
|
||||||
|
# native BLAS switching mechanism for Fedora/RHEL. Starting with R 4.3.0, we also
|
||||||
|
# link to external FlexiBLAS for compatibility.
|
||||||
|
# https://fedoraproject.org/wiki/Changes/FlexiBLAS_as_BLAS/LAPACK_manager
|
||||||
#
|
#
|
||||||
# On Ubuntu/Debian, we link R against the external BLAS instead (--with-blas/--with-lapack),
|
# On Ubuntu/Debian, we link R against the external BLAS instead (--with-blas/--with-lapack),
|
||||||
# as those distributions use the alternatives system to swap BLAS libraries at runtime.
|
# as those distributions use the alternatives system to swap BLAS libraries at runtime.
|
||||||
|
|
@ -28,18 +31,41 @@ fi
|
||||||
# for portability.
|
# for portability.
|
||||||
#
|
#
|
||||||
# https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Shared-BLAS
|
# https://cran.r-project.org/doc/manuals/r-release/R-admin.html#Shared-BLAS
|
||||||
cat <<EOF >> /post-install.sh
|
if [[ "$("${R_INSTALL_PATH}/bin/R" CMD config BLAS_LIBS)" == "-lflexiblas" ]]; then
|
||||||
mv ${R_INSTALL_PATH}/lib/R/lib/libRblas.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so.keep
|
blas_lib='flexiblas-devel'
|
||||||
ln -s /usr/lib64/libopenblasp.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so
|
|
||||||
|
# Create postremove script to remove empty directories, as nFPM doesn't include them in the RPM files.
|
||||||
|
cat <<EOF >> /after-remove.sh
|
||||||
|
if [ -d ${R_INSTALL_PATH} ]; then
|
||||||
|
rm -r ${R_INSTALL_PATH}
|
||||||
|
fi
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Create after-remove script to remove internal BLAS, which won't be cleaned up automatically.
|
scripts="scripts:
|
||||||
cat <<EOF >> /after-remove.sh
|
postremove: /after-remove.sh
|
||||||
if [ -d ${R_INSTALL_PATH} ]; then
|
"
|
||||||
rm -r ${R_INSTALL_PATH}
|
else
|
||||||
fi
|
blas_lib='openblas-devel'
|
||||||
|
|
||||||
|
# Create post-install script required for OpenBLAS.
|
||||||
|
cat <<EOF >> /post-install.sh
|
||||||
|
mv ${R_INSTALL_PATH}/lib/R/lib/libRblas.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so.keep
|
||||||
|
ln -s /usr/lib64/libopenblasp.so ${R_INSTALL_PATH}/lib/R/lib/libRblas.so
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# Create after-remove script to remove internal BLAS, which won't be cleaned up automatically.
|
||||||
|
cat <<EOF >> /after-remove.sh
|
||||||
|
if [ -d ${R_INSTALL_PATH} ]; then
|
||||||
|
rm -r ${R_INSTALL_PATH}
|
||||||
|
fi
|
||||||
|
EOF
|
||||||
|
|
||||||
|
scripts="scripts:
|
||||||
|
postinstall: /post-install.sh
|
||||||
|
postremove: /after-remove.sh
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$(arch)" == "aarch64" ]; then echo arm64; else echo amd64; fi > /tmp/arch
|
if [ "$(arch)" == "aarch64" ]; then echo arm64; else echo amd64; fi > /tmp/arch
|
||||||
|
|
||||||
cat <<EOF > /tmp/nfpm.yml
|
cat <<EOF > /tmp/nfpm.yml
|
||||||
|
|
@ -66,7 +92,7 @@ depends:
|
||||||
- libXmu
|
- libXmu
|
||||||
- libXt
|
- libXt
|
||||||
- make
|
- make
|
||||||
- openblas-devel
|
- ${blas_lib}
|
||||||
- pango
|
- pango
|
||||||
${pcre_libs}
|
${pcre_libs}
|
||||||
- tcl
|
- tcl
|
||||||
|
|
@ -79,9 +105,7 @@ ${pcre_libs}
|
||||||
contents:
|
contents:
|
||||||
- src: ${R_INSTALL_PATH}
|
- src: ${R_INSTALL_PATH}
|
||||||
dst: ${R_INSTALL_PATH}
|
dst: ${R_INSTALL_PATH}
|
||||||
scripts:
|
${scripts}
|
||||||
postinstall: /post-install.sh
|
|
||||||
postremove: /after-remove.sh
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
nfpm package \
|
nfpm package \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue