X

Set Up a Machine-Learning Workbench on Oracle Cloud Infrastructure

Karan Singh
Director Product Management, Solution Architecture

Machine learning is fast becoming an integral part of enterprise applications and a core competency for enterprises. A basic machine-learning workflow involves collecting, preparing, and curating data, followed by building, training, evaluating, and deploying models by using different machine-learning algorithms, which you can then use to make predictions.

This post focuses on the model development part of the workflow. A rich ecosystem of open source software and managed offerings are available, and I've picked some popular open source offerings to build an example workbench. Using this workbench, you can start coding and building models. I don't cover model development in depth, but I present one example to show how to use the workbench.

Python and R are commonly used languages for machine learning. I use Python 3 here because it supports a robust set of popular machine-learning frameworks, libraries, and packages, such as TensorFlow, scikit-learnMatplotlibSciPyNumPyKeras, and pandas.  

Notebooks like Jupyter and Apache Zeppelin provide integrated environments that incorporate results, visualizations, and documentation inline with code, providing an excellent workbench for data scientists, machine-learning engineers, and other stakeholders to develop, visualize, and share their work. 

I show the steps to set up a basic, cloud native, machine-learning workbench from scratch on Oracle Cloud Infrastructure by using Python 3, TensorFlow, and Jupyter Notebook. I use an Oracle Cloud Infrastructure bare metal instance running Oracle Linux. Let’s get started.

Launch an Instance

  1. Follow the steps in the documentation to launch a bare metal instance in Oracle Cloud Infrastructure. I made the following choices:

    • Region: us-ashburn-1
    • OS: Oracle Linux 7.6
    • Instance shape: BM.Standard2.52
  2. Use SSH to connect to the instance:

    $ ssh –i <path_to_your_private_key> opc@<public_IP_address_of_your_instance>

I used Oracle Linux and a bare metal shape, but you can make other choices. These steps should work for the most part, regardless of your choices, although some commands will change based on the OS, and you need to use the right libraries for your instance shape.

Install Python 3

By default, Oracle Linux 7 comes with Python 2.7. You can continue to use that, but I'm going to show you how to use Python 3. To install Python 3, following these steps:

  1. Install the EPEL repository:

    [opc@ml-workbench ~]$ sudo yum install -y oracle-epel-release-el7 oracle-release-el7
  2. Install Python 3.6:

    [opc@ml-workbench ~]$ sudo yum install -y python36​
  3. Set up a Python virtual environment (venv), called mlenv here:

    [opc@ml-workbench ~]$ python3.6 -m venv mlenv​
  4. Activate the virtual environment:

    [opc@ml-workbench ~]$ source mlenv/bin/activate​

Using pip3, you can install some of the commonly used Python libraries like scikit-learn, Keras, NumPy, Matplotlib, pandas, and SciPy.

Install TensorFlow

Pick the correct TensorFlow package to use. Based on my choices, I can install TensorFlow by using the following command:

(mlenv) [opc@ml-workbench ~]$ pip3 install tensorflow​

Install Jupyter and Run a Notebook

  1. Install Jupyter:

    (mlenv) [ml-workbench ~]$ python3 -m pip install jupyter​
  2. Run a Jupyter notebook:

    (mlenv) [opc@ ml-workbench ~]$ jupyter notebook --ip=0.0.0.0​

    You will see a warning such as No web browser found: could not locate runnable browser.

Connect to Jupyter from Your Local Machine with SSH Tunneling

  1. Open another terminal window, and use the following command with an available port number to access the notebook:

    $ ssh –i <path_to_ your_private_key> opc@<public_IP_address_of_your_instance> -L 8000:localhost:8888​
  2. Open a web browser on your local machine and browse to http://localhost:8000.

  3. When you are prompted for a token, use the token key listed in your previous terminal window to log in to the Jupyter notebook.

Start Coding

Click the New button to create a new Python 3 notebook. You can also upload existing IPython notebooks. Following is an example from a TensorFlow tutorial for a basic image classifier:

Conclusion

In this post, I set up a machine learning workbench with an Oracle Cloud Infrastructure bare metal instance running Oracle Linux. I used TensorFlow, a popular open source, machine-learning framework, and I described how to install and use Python 3 and Jupyter notebooks, which make it easy to build, train, and deploy models using Python. You can follow similar steps to install other languages, tools, and frameworks in the rapidly evolving machine-learning ecosystem. If you don’t have an Oracle Cloud account, you can sign up for a free account and get a $300 credit to start building.

Join the discussion

Comments ( 1 )
  • Jeff Schering Tuesday, April 2, 2019
    Thanks Karan!

    I had a lot of trouble getting this to work, but eventually I found the cause... it seems that the blog software added the HTML entity 8203 at the end of each instruction. 8203 is 'zero width space'. When I copy/pasted the instructions into my shell, the zero width space came along with it and confused the shell to no end.

    I got around that by either copying everything but the last character and pasting it into my shell and then typing the last character, or by typing in the entire instruction.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha