OML4Py Client on Ubuntu

May 13, 2024

ai, database, oracle, Python

How to install OML4Py Client on Ubuntu 22.04

I needed the Oracle Machine Learning for Python (OML4Py) Client (not the Server) in order to convert a pretrained model so that I could import it into the newly released Oracle database 23ai.

I wrote this from information I found in the User’s Guide and a lot of internet search. The PC I am using for this runs Ubuntu, so I adapted the installation for Ubuntu 22.04 (Jammy Jellyfish). After I completed the whole procedure I decided to verify it on a fresh Vagrant box:

mkdir ubuntu2204
cd ubuntu2204
vagrant init ubuntu/jammy64
vagrant up
vagrant ssh
sudo apt-get update
sudo apt-get upgrade

Note, for some work later I needed to increase the memory available to the VM. I changed the Vagrantfile to include:

config.vm.provider "virtualbox" do |vb|
  vb.memory = "4096"

These lines are commented out in the generated Vagrantfile.

Compile Python 3.12

Some packages listed in the User’s Guide were already installed. I installed these:

sudo apt install libffi-dev libbz2-dev libssl-dev \
  pkg-config libreadline-dev tk-dev unzip

Download the source code for Python 3.12, configure and compile with:

tar xvf Python-3.12.0.tar.xz
export PREFIX=`pwd`/Python-3.12.0
./configure --prefix=$PREFIX --enable-shared --enable-optimizations

make clean
make -j6
make altinstall

The -j6 option to the second-last make command starts six compiler jobs in parallell. Compiling does take some time on old hardware, but this option requires more memory.

I added the following in an environment file (called foo.env) in the directory above Python-3.12.0

export PREFIX=`pwd`/Python-3.12.0

and sourced it with: . ./foo.env.

I added a link:

ln -s python3.12 python3

Upgrade pip:

python3 -m pip install --upgrade pip

Python packages

I had to install a bunch of packages (The Python community clearly does not mind breaking things so version numbers can be important, numpy must be removed and installed with a lower version):

pip3.12 install pandas==2.1.1
pip3.12 install scipy==1.11.3
pip3.12 install matplotlib==3.7.2
pip3.12 install oracledb==2.0.1
pip3.12 install threadpoolctl==3.1.0
pip3.12 install joblib==1.2.0
pip3.12 install setuptools
pip3.12 install scipy==1.12.0

pip3.12 uninstall numpy
pip3.12 install numpy==1.26.4
pip3.12 install scikit-learn==1.3

pip3.12 install onnx
pip3.12 install onnxruntime_extensions
pip3.12 install onnxruntime
pip3.12 install transformers==4.38.1
pip3.12 install sentencepiece==0.2.0
pip3.12 install torch

OML4Py Client

Download the OML4Py Client . Unzip it somewhere with:


It contains one folder client. Install it with:

perl -Iclient client/

If all the prerequisites are in place you should see something like this (you have to confirm yes at some point):

Oracle Machine Learning for Python 2.0 Client.

Copyright (c) 2018, 2024 Oracle and/or its affiliates. All rights reserved.
Checking platform .................. Pass
Checking Python .................... Pass
Checking dependencies .............. /home/vagrant/ DeprecationWarning: pkg_resources is deprecated as an API. See
  from pkg_resources import WorkingSet, VersionConflict, DistributionNotFound
Checking OML4P version ............. Pass
Current configuration
  Python Version ................... 3.12.0
  PYTHONHOME ....................... /home/vagrant/Python-3.12.0
  Existing OML4P module version .... None

  Operation ........................ Install/Upgrade

Proceed? [yes]

Processing ./client/oml-2.0-cp312-cp312-linux_x86_64.whl
Installing collected packages: oml
Successfully installed oml-2.0


Now, let’s see if it works. Execute python3 and run:

import oml

It can actually take a few seconds to load.

One more check:

from oml.utils import EmbeddingModel, EmbeddingModelConfig

In next post I will do the actual export of a model, load it into a Oracle Database 23ai Free and explore the Oracle AI Vector Search a bit.