3 Install R for Oracle Machine Learning for R on On-Premises Oracle Database
This chapter explains how to install R for OML4R on On-Premises Oracle Database.
This chapter contains these topics:
- About R and Oracle Machine Learning for R for On-Premises Database
OML4R requires an installation of R on the server computer and on each client computer that interacts with the server. - Install Oracle R Distribution on Linux
Instructions for installing Oracle R Distribution on Oracle Linux and on Redhat Enterprise Linux. - Configure Oracle R Distribution to Use MKL on the Client
Instructions for configuring Oracle R Distribution to use MKL on a Linux client. - Uninstall Oracle R Distribution
Instructions for uninstalling Oracle R Distribution.
3.1 About R and Oracle Machine Learning for R for On-Premises Database
OML4R requires an installation of R on the server computer and on each client computer that interacts with the server.
R is third-party, open source software. Open source R is governed by GNU General Public License (GPL) and not by Oracle licensing.
Note:
The version of R must be the same on the server and on each client computer. Also, the version of OML4R must be the same on the server and on each client computer.- About ROracle
ROracle is an open source R package that enables interaction between R and an Oracle database. - Oracle R Distribution and OML4R
Oracle recommends that you use Oracle R Distribution, Oracle's free distribution of R, with OML4R.
See Also:
3.1.1 About ROracle
ROracle is an open source R package that enables interaction between R and an Oracle database.
ROracle is maintained and supported by Oracle.
ROracle is one of the open source supporting packages that is used by Oracle Machine Learning for R. The supporting packages are introduced in Client and Server Components of Oracle Machine Learning for R for On-Premises Database and described in Table 6-2.
3.1.2 Oracle R Distribution and OML4R
Oracle recommends that you use Oracle R Distribution, Oracle's free distribution of R, with OML4R.
Oracle R Distribution offers significant advantages for OML4R.
Why Oracle R Distribution?
-
Oracle R Distribution simplifies the installation of R for OML4R.
-
Oracle R Distribution is supported by Oracle for customers of Oracle Machine Learning, Oracle Linux, and Oracle Big Data Appliance.
-
On Linux, Oracle R Distribution simplifies integration with the Intel Math Kernel Library (MKL). MKL greatly improves the performance of many mathematical computations in R, including highly vectorized and threaded Linear Algebra, Fast Fourier Transforms (FFT), Vector Math, and Statistics functions. (See Enable MKL Support for Oracle R Distribution on a Linux Client.)
3.2 Install Oracle R Distribution on Linux
Instructions for installing Oracle R Distribution on Oracle Linux and on Redhat Enterprise Linux.
Before you begin the installation, verify that your Linux version is supported by Oracle Machine Learning for R, as described in the table of platform requirements in Oracle Machine Learning for R System Requirements for On-Premises Database. You can use this command to verify the Linux version:
# uname -r
Note:
For Oracle Linux systems that have access to the internet, Oracle recommends installing Oracle R Distribution from the Oracle Linux Yum Server.
The following topics describe installing Oracle R Distribution:
- Install Oracle R Distribution on Oracle Linux 8 Using Yum or Dnf
Oracle recommends using dnf to install Oracle R Distribution on Linux 8. - Install Oracle R Distribution on Oracle Linux 7 Using Yum
Oracle recommends using yum to install Oracle R Distribution on Linux 7. - Install Oracle R Distribution on Oracle Linux Using RPMs
If yum is not available due to lack of internet access, then you can install the RPMs directly and resolve the dependencies manually. - Install Oracle R Distribution on Red Hat Enterprise Linux
Instructions on rebuilding the Oracle R Distribution RPMs on a Red Hat Linux system.
3.2.1 Install Oracle R Distribution on Oracle Linux 8 Using Yum or Dnf
Oracle recommends using dnf to install Oracle R Distribution on Linux 8.
To install Oracle R Distribution on Oracle Linux 8 Using Yum or Dnf:
-
Log in to the Linux server as root and change to the
/etc/yum.repos.d
directory:# cd /etc/yum.repos.d
-
Use dnf to install the Oracle Linux 8 yum repository:
dnf install oraclelinux-release-el8
The repository oracle-linux-ol8.repo will be saved in /etc/yum.repos.d.
-
For Oracle Linux 8, in addition to the Oracle Linux 8 main repository, the appstream, codereadybuilder, and addons repositories are required. Open
oracle-linux-ol8.repo
in a text editor and specifyenabled=1
forol8_baseos_latest
,o18_appstream
,o18_ codereadybuilder
andol8_addons
:-
Locate the section for
baseos_latest
repository and changeenabled=0
toenabled=1
.[ol8_baseos_latest] enabled=1
The result will look similar like the following:
[ol8_baseos_latest] name=Oracle Linux $releasever BaseOS ($basearch) baseurl=https://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/$basearch gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle gpgcheck=1 enabled=1
-
Locate the section for
appstream
repository and changeenabled=0
toenabled=1
.[ol8_appstream] enabled=1
The result will look similar like the following:
[ol8_appstream] name=Oracle Linux $releasever Application Stream ($basearch) baseurl=https://yum.oracle.com/repo/OracleLinux/OL8/appstream/$basearch gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle gpgcheck=1 enabled=1
-
Locate the section for
codereadybuilder
repository and changeenabled=0
toenabled=1
.[ol8_codereadybuilder] enabled=1
The result will look similar like the following:
[ol8_codereadybuilder] name=Oracle Linux $releasever Code Ready Builder ($basearch) baseurl=https://yum.oracle.com/repo/OracleLinux/OL8/codeready/builder/$basearch gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle gpgcheck=1 enabled=1
-
Locate the section for
addons
repository and changeenabled=0
toenabled=1
.[ol8_addons] enabled=1
The result will look similar like the following:
[ol8_addons] name=Oracle Linux $releasever Add ons ($basearch) baseurl=https://yum.oracle.com/repo/OracleLinux/OL8/addons/$basearch/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle gpgcheck=1 enabled=1
-
- As root, install R-4.0.5 for Linux 8 using the dnf command. Run the
dnf
command to install R.
.# dnf install R-4.0.5
Note:
In newer Oracle Linux versions, the yum package manager has been replaced by dnf package manager.
Parent topic: Install Oracle R Distribution on Linux
3.2.2 Install Oracle R Distribution on Oracle Linux 7 Using Yum
Oracle recommends using yum to install Oracle R Distribution on Linux 7.
To install Oracle R Distribution on Oracle Linux 7 Using Yum:
-
Log in to the Linux server as root and change to the
/etc/yum.repos.d
directory:# cd /etc/yum.repos.d
-
List the contents of the directory to determine if the Oracle Linux 7 yum configuration file is present. The name of the configuration file is
public-yum-ol7.repo
.If the Oracle Linux 7 yum configuration file is not present, then download it from Oracle public yum by executing the
wget
command for your Linux platform:# wget https://public-yum.oracle.com/public-yum-ol7.repo
-
Open
public-yum-ol7.repo
in a text editor and specifyenabled=1
forol7_latest
,ol7_addons
andol7_optional_latest
:[ol7_latest] enabled=1 [ol7_addons] enabled=1 [ol7_optional_latest] enabled = 1
The location of the Oracle R Distribution packages is specified in
ol7_addons
. The location of the dependencies for the Oracle R Distribution RPMs is specified inol7_latest
and several dependencies are inoptional_latest
.The URLs for the Oracle R Distribution RPMs in the addons repository are shown in the example at the end of this topic.
Note:
If you are not using the most recent version of Oracle Linux and you want to install dependent packages that are specific to your version, then you must enable the corresponding Oracle Linux repository.
For example, to enable the Oracle Linux 7 base repository open
public-yum-ol7.repo
in a text editor and specifyenabled=1
forol7_latest
:[ol7_base] enabled=1
The output will look similar to the following:
[ol7_base] name=Oracle Linux $releasever installation media copy ($basearch) baseurl=https://public-yum.oracle.com/repo/OracleLinux/OL7/ base/$basearch/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle gpgcheck=1 enabled=1
-
Run the
yum
install
command to install R. Specify the version number to install for Rversion. For example, to install R-3.6.1, use the commandyum install R-3.6.1
.# yum install R-Rversion
To install the most recent version of R that is available on Oracle public yum:
# yum install R.x86_64
Note:
Do not assume that the most recent version of R on Oracle public yum is supported by your version of Oracle Machine Learning for R. Consult the table of configuration requirements and server support in Oracle Machine Learning for R System Requirements for On-Premises Database to determine which version of R you should use.
Parent topic: Install Oracle R Distribution on Linux
3.2.3 Install Oracle R Distribution on Oracle Linux Using RPMs
If yum is not available due to lack of internet access, then you can install the RPMs directly and resolve the dependencies manually.
However, Oracle recommends that you use yum to install Oracle R Distribution, because yum automatically resolves RPM dependencies.
To download and install the RPMs, log in as root and run the command rpm -Uvh rpm_name
for each RPM listed in the following sections:
- Oracle R Distribution 4.0.5 RPMs for Oracle Linux 8
Lists the Oracle R Distribution RPMs for Oracle Linux 8. - Oracle R Distribution 4.0.5 RPMs for Oracle Linux 7
Lists the Oracle R Distribution RPMs for Oracle Linux 7. - Oracle R Distribution 3.6.1 RPMs for Oracle Linux 7
Lists the Oracle R Distribution RPMs for Oracle Linux 7. - Oracle R Distribution 3.3.0 RPMs for Oracle Linux 7
Lists the Oracle R Distribution RPMs for Oracle Linux 7.
Parent topic: Install Oracle R Distribution on Linux
3.2.3.1 Oracle R Distribution 4.0.5 RPMs for Oracle Linux 8
Lists the Oracle R Distribution RPMs for Oracle Linux 8.
The Oracle R Distribution RPMs for Oracle Linux 8 are listed as follows:
https://yum.oracle.com/repo/OracleLinux/OL8/addons/x86_64/getPackage/R-4.0.5-1.0.1.el8.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL8/addons/x86_64/getPackage/R-core-4.0.5-1.0.1.el8.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL8/addons/x86_64/getPackage/R-devel-4.0.5-1.0.1.el8.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL8/addons/x86_64/getPackage/libRmath-4.0.5-1.0.1.el8.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL8/addons/x86_64/getPackage/libRmath-devel-4.0.5-1.0.1.el8.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL8/addons/x86_64/getPackage/libRmath-static-4.0.5-1.0.1.el8.x86_64.rpm
Parent topic: Install Oracle R Distribution on Oracle Linux Using RPMs
3.2.3.2 Oracle R Distribution 4.0.5 RPMs for Oracle Linux 7
Lists the Oracle R Distribution RPMs for Oracle Linux 7.
The Oracle R Distribution RPMs for Oracle Linux 7 are listed as follows:
https://yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-4.0.5-1.el7.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-core-4.0.5-1.el7.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-devel-4.0.5-1.el7.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-4.0.5-1.el7.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-devel-4.0.5-1.el7.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-static-4.0.5-1.el7.x86_64.rpm
Parent topic: Install Oracle R Distribution on Oracle Linux Using RPMs
3.2.3.3 Oracle R Distribution 3.6.1 RPMs for Oracle Linux 7
Lists the Oracle R Distribution RPMs for Oracle Linux 7.
The Oracle R Distribution RPMs for Oracle Linux 7 are listed as follows:
https://yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-3.6.1-1.el7.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-core-3.6.1-1.el7.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-devel-3.6.1-1.el7.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-3.6.1-1.el7.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-devel-3.6.1-1.el7.x86_64.rpm
https://yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-static-3.6.1-1.el7.x86_64.rpm
Parent topic: Install Oracle R Distribution on Oracle Linux Using RPMs
3.2.3.4 Oracle R Distribution 3.3.0 RPMs for Oracle Linux 7
Lists the Oracle R Distribution RPMs for Oracle Linux 7.
The Oracle R Distribution RPMs for Oracle Linux 7 are listed as follows:
https://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-3.3.0-2.el7.x86_64.rpm https://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-core-3.3.0-2.el7.x86_64.rpm https://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-core-extra-3.3.0-2.el7.x86_64.rpm https://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/R-devel-3.3.0-2.el7.x86_64.rpm https://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-3.3.0-2.el7.x86_64.rpm https://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-devel-3.3.0-2.el7.x86_64.rpm https://public-yum.oracle.com/repo/OracleLinux/OL7/addons/x86_64/getPackage/libRmath-static-3.3.0-2.el7.x86_64.rpm
Parent topic: Install Oracle R Distribution on Oracle Linux Using RPMs
3.2.4 Install Oracle R Distribution on Red Hat Enterprise Linux
Instructions on rebuilding the Oracle R Distribution RPMs on a Red Hat Linux system.
The Oracle Linux RPMs can be installed on Red Hat Linux systems. However, if you want to rebuild the Oracle R Distribution RPMs on a Red Hat Linux system, follow these instructions.
To install Oracle R Distribution on Red Hat Enterprise Linux:
-
Create an RPM build directory structure:
mkdir -p /rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
-
Set up RPM tools to use your own build tree (to avoid
root
):echo '%_topdir %(echo $HOME)/rpmbuild' > /.rpmmacros
-
From Oracle public yum, download the source RPM (
Rversion
.olx.src.rpm
where Rversion is the R version you are using and x is the Oracle Linux version you are using).Save the source RPM to the
rpmbuild/SRPMS
directory. -
Rebuild Red Hat Enterprise Linux using
rpmbuild
.rpmbuild --rebuild /rpmbuild/SRPMS/R-Rversion.elx.src.rpm
Note:
If any dependencies are missing, install them as root.
The binary RPMs are built and saved under
/rpmbuild/RPMS.
-
Log in as root and run these commands to install R:
# rpm -i path/rpmbuild/RPMS/R-Rversion.olx.x86_64.rpm # rpm -i path/rpmbuild/RPMS/R-core-Rversion.olx.x86_64.rpm # rpm -i path/rpmbuild/RPMS/libRmath-Rversion.olx.x86_64.rpm # rpm -i path/rpmbuild/RPMS/libRmath-devel-Rversion.olx.x86_64.rpm # rpm -i path/rpmbuild/RPMS/libRmath-static-Rversion.olx.x86_64.rpm # rpm -i path/rpmbuild/RPMS/R-devel-Rversion.olx.x86_64.rpm
For example, this command installs R-4.0.5 on Red Hat Enterprise Linux x86-64 version 7, where the path to
rpmbuild
is/user/home/
.rpm -i /user/home/rpmbuild/RPMS/x86_64/R-core-4.0.5-1.el7.x86_64.rpm
Parent topic: Install Oracle R Distribution on Linux
3.3 Configure Oracle R Distribution to Use MKL on the Client
Instructions for configuring Oracle R Distribution to use MKL on a Linux client.
With this simple configuration step, Oracle R Distribution dynamically uses MKL if it is installed on your system.
This topic contains these sections:
- Enable MKL Support for Oracle R Distribution on a Linux Client
Follow these steps to enable MKL for Oracle R Distribution on a Linux Client.
3.3.1 Enable MKL Support for Oracle R Distribution on a Linux Client
Follow these steps to enable MKL for Oracle R Distribution on a Linux Client.
-
Install MKL. You can download MKL from the Intel® Math Kernel Library website.
Note: To install MKL on your computer, you must have an MKL license.
-
Add
libmkl_rt.so
,$RHOME/lib
, and$ORACLE_HOME/lib
to theLD_LIBRARY_PATH
system environment variable. For example, in the Bash shell:export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}: /path_to/libmkl_rt.so: ${RHOME}/lib: ${ORACLE_HOME}/lib
-
Start R and run the
Sys.BlasLapack
function:Sys.BlasLapack() $vendor [1] "Intel Math Kernel Library (Intel MKL)" $nthreads [1] -1
The returned value of $vendor
indicates that MKL has replaced the BLAS
and LAPACK
that are native to R.
The returned value of nthreads
indicates the number of threads to be used by MKL. By default all available threads are used ($nthreads
= -1).
Parent topic: Configure Oracle R Distribution to Use MKL on the Client
3.3.1.1 Modifying the Number of Threads for MKL on Linux
You can change the number of threads to be used by MKL by editing the system environment variable MKL_NUM_THREADS
. For example, the following statement in the Bash shell, causes MKL to use 3 threads:
export MKL_NUM_THREADS=3
After setting MKL_NUM_THREADS
to 3, the output of Sys.BlasLapack
shows a value of 3 for $nthreads
.
R> Sys.BlasLapack() $vendor [1] "Intel Math Kernel Library (Intel MKL)" $nthreads [1] 3
3.4 Uninstall Oracle R Distribution
Instructions for uninstalling Oracle R Distribution.
To uninstall Oracle R Distribution, follow the instructions in the following sections:
- Uninstall Oracle R Distribution on Linux
Instructions for uninstalling Oracle R Distribution on Linux.
3.4.1 Uninstall Oracle R Distribution on Linux
Instructions for uninstalling Oracle R Distribution on Linux.
To uninstall Oracle R Distribution on Linux, log in as root and run the commands in the example in the order shown. This example uninstalls R-4.0.5. To uninstall a different version of R, replace the R version in the example with the number of the version you want to uninstall.
Example 3-1 Linux Commands for Uninstalling Oracle R Distribution
Run the rpm -e rpmname
command, where rpmname is the name of the RPM you want to remove.
For example, to remove R-4.0.5 on Oracle Linux 7:
rpm -e R-4.0.5-1.el7
rpm -e R-devel
rpm -e R-core
rpm -e R-core-extra
rpm -e libRmath-devel
rpm -e libRmath
rpm -e libRmath-static
Parent topic: Uninstall Oracle R Distribution