alexcombessie / example-seldon

Example for end-to-end machine learning on Kubernetes using Kubeflow and Seldon Core

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

End-To-End Train and Deploy Machine Learning Model on Kubernetes (on GKE)

Using:

The example will be the MNIST handwriiten digit classification task.

MNIST

In the follow we will:

  1. Do the data science
  2. Train the model
  3. Serve the model
  4. Get predictions

Prerequisites

Either :

  1. Follow the kubeflow docs to
    1. Create a persistent disk for NFS. Call it nfs-1.
    2. Install kubeflow with an NFS volume, Argo and seldon-core onto your cluster.
  2. Follow a consolidated guide to do the steps in 1.

Data Science

In this demo we provide some example models for MNIST classification. Firstly, a Tensorflow model

We also provide a simple scikit-learn random forest model which is used in the notebooks to illustrate A-B tests and multi-armed bandits.

Train Model

The training and serving steps are written as Argo jobs.

argo submit workflows/training-tf-mnist-workflow.yaml -p tfjob-version-hack=$RANDOM

To understand the workflow in detail and run it with optional parameters to build and push to your own repo see here.

To check on your Argo jobs use argo list and argo get or the Argo UI discussed above.

Serve Model

To wrap our model as a Docker container and launch we create:

argo submit workflows/serving-tf-mnist-workflow.yaml
  • See here for detailed comments on workflow

Get Predictions

The cluster is using Ambassador so your model will be exposed by REST and gRPC on the Ambassador reverse proxy.

To expose the ambassador reverse proxy to a local port do

kubectl port-forward $(kubectl get pods -n kubeflow-seldon -l service=ambassador -o jsonpath='{.items[0].metadata.name}') -n kubeflow-seldon 8002:80

You can test the service by following the example jupyter notebook

cd notebooks
jupyter notebook

Next Steps

There is a second model for mnist using an sklearn random forest which can be found in models/sk_mnist.

See Next Steps in jupyter notebook

About

Example for end-to-end machine learning on Kubernetes using Kubeflow and Seldon Core

License:Apache License 2.0


Languages

Language:Jupyter Notebook 92.7%Language:Python 4.3%Language:Shell 2.5%Language:Makefile 0.3%Language:Smarty 0.2%