
MLflow is a versatile open-source Machine Learning (ML) platform for model lifecycle management. It supports experimentation, duplicability, deployment, and a central model registry. MLflow is used to track machine learning workload experiments, packaging and deployment of code, and collaborative management. Frequently used by data scientists and by MLOps professionals.
This article explains how to deploy MLflow on a Vultr Kubernetes Engine (VKE) cluster with a working environment and demo application.
Before you begin:
Deploy a Vultr Kubernetes Engine(VKE) cluster
Deploy a Vultr Ubuntu instance to use as your management server
Using SSH, access the server
Install and configure Kubectl to access the cluster
Install the Helm package manager
MLflow requires persistent storage to store artifacts and experiment data. In this section, deploy a PV and PVC to the cluster as described in the steps below.
Create a new file mlflow-pv-pvc.yaml
Using a text editor such as nano, edit the file
Add the following contents to the file
Save the file
Apply the configuration to your cluster
Verify the deployed Cluster PVs
Output:
Verify the deployed Cluster PVCs
Output:
Using Helm, add community-charts to your repositories
Update the Helm repository index
Install MLflow. Replace vultr with your desired MLflow label
View the cluster deployment to verify that MLflow is ready and available
Your output should look like the one below:
To access your MLflow deployment over the Internet, set up a forwarding service to expose the application for external access as described in the steps below.
Create a new file mlflow-service.yaml
Edit the file
Add the following contents to the file
Apply the service to your cluster
Wait for at least 3 minutes, view the cluster services, and verify the MLflow External IP value
Your output should look like the one below:
To test the MLflow functionalities, create a sample linear regression experiment as described in the steps below.
Create a new directory Models
Switch to the directory
Using pip, install the necessary experiment dependencies
When using Conda, install the dependencies in your environment:
Create a new environment variable with your desired experiment name
Export a new mlflow_TRACKING_URI with your MLflow service external IP HTTP URL as the value. For example 192.0.2.100
Create a new file main.py
Edit the file
Add the following contents to the file
Save and close the file.
The above Python application imports all necessary libraries and uses the diabetes dataset for training data. The dataset contains a total of 442 samples. Then, the model is trained and an explanation is logged to MLflow using SHAP (Shapley Additive Explanations) that plots the output for a visual representation of the data.
Run the Python application
Using a web browser such as Chrome, visit your MLflow external IP address
Verify that the application is included in your MLflow experiments. It uses a linear regression statistical approach to model a relationship between a scalar response and one or more variables.
You have deployed MLflow on a Vultr Kubernetes Engine (VKE) cluster. To test the service operations, implement more examples from the MLflow repository. For more information about MLflow, visit the following documentation resources:
To implement more solutions, visit the following resources:
0 Comments
Be the first to comment and share your perspective with the community.