Article Complete
    AIM

    Plug-and-play ML models across platforms using MLCube

    Plug-and-play ML models across platforms using MLCube

    MLCube is an interface which facilitates easy model sharing across platforms and account for increased model usage across platforms.

    Plug-and-play ML models across platforms using MLCube
    darshan.m··Updated DECEMBER 30, 2024, 5:30 AM
    5 min

    A variety of Machine Learning and AI models face the issues of portability and usage on various platforms. Some standard platforms like cloud, Kubernetes, GCP, and many times in localhost, the models developed cannot be deployed and used due to dependency issues. So this is where MLCube as a package is useful for sharing the models across platforms in the form of a simple downloadable and executable package. In this article, we will focus on MLCube and we will understand its importance in this context.

    Table of Contents

    1. Introduction to MLCube
    2. MLCube on different platforms
    3. Case Study of MLCube in Docker
    4. Summary

    Introduction to MLCube

    Machine learning models are developed for various tasks, but sharing the model is sometimes difficult as various platforms would have certain dependency issues. So MLCube is a single shot library that facilitates machine learning researchers and engineers to use models developed from anywhere in the world on their platforms. 

    Are you looking for a complete repository of Python libraries used in data science, check out here.

    MLCube basically operates on the principle of “One model run anywhere”. So using MLCube we can run the trained models on various platforms like your local machines, on cloud-based platforms like  GCP, or even on Kubernetes clusters if required. MLCube supports various platforms in the form of runners and some of the runners include dockers, Kubeflow, SSH, and many more. MLCube can be installed in required formats by using simple pip statements for respective formats. On the whole MLCube acts like a shipping container of ML models that can be used across diverse platforms to share and utilize trained models.

    MLCube has the flexibility to share the trained ML models to various platforms. The sharing of the models on various platforms is handled through “runners”. So in the next section of the article let us try to understand the different MLCube runners.

    MLCube on different platforms

    The MLCube framework is still in the development phase and currently, it supports 6 different types of runners. These runners can be utilized accordingly to the user's choice of the working environment and in the platform, the machine learning engineer or researcher wants to train the model or requires the model to be shared across. Now let us look into the different types of MLCube runners that are made available in the development phase and try to understand the characteristics of each runner.

    MLCube in Docker

    The MLCube package in docker can be used by first installing the MLCube package that is designed for the Docker environment. That can be done through a pip command as shown below.

    !pip install mlcube-docker

    So once the MLCube package is installed in the docker environment the MLCube can be made to run in the docker environment using the mandatory commands. Some of the standard docker supporting commands include configure and run. A trained model can be made available in the docker environment and the model can be used accordingly.

    MLCube in GCP

    The MLCube package in GCP can be used by first installing the MLCube package that is designed for the GCP platform. That can be done through a pip command as shown below.

    !pip install mlcube-gcp

    So once the MLCube package is installed in the GCP platform the MLCube package can be made to run on the GCP platform. In GCP the configuration file parameters and some of the standard instances of the GCP like Compute Engine, and VM instances have to be activated accordingly and the MLCube library in GCP can be used accordingly to use the shared model or to retrain the shared model in the platform.

    MLCube in Kubernetes

    The MLCube package for Kubernetes can be used by first installing the MLCube package that is designed for Kubernetes. That can be done through a pip command as shown below.

    !pip install mlcube-k8s

    So once the MLCube package is installed in Kubernetes, the shared model and the Kubernetes platform can be used to accelerate the model training. Some of the standard functionalities like run commands in the Kubernetes platform can be used to activate the Job manifest. The runner in the Kubernetes platform would then create a cluster to train and use the shared model in Kubernetes. So the job has to be instantiated in Kubernetes according to MLCube requirements and once the training process of the model is completed, the job gets completed. This is how MLCube is used in Kubernetes.

    MLCube in Kubeflow

    The MLCube package for the Kubeflow platform can be used by first installing the MLCube package that is designed for the Kubeflow platform. That can be done through a pip command as shown below.

    !pip install mlcube-kubeflow

    MLCube in Kubeflow is still in development and needs a little improvement. Some of the basic commands supported are run and configure along with some standard arguments like platform and task. The PVC redirection to the MLCube workspace and kubeflow pipelining has to be completed to make complete usage of the MLCube library in Kubeflow.

    MLCube in Singularity

    The MLCube package for the Singularity platform can be used by first installing the MLCube package that is designed for the Singularity platform. That can be done through a pip command as shown below.

    !pip install mlcube-singularity

    The mandatory and standard commands supported by Singularity for MLCubes is similar to Kubeflow. Some of the standard runners designed in the development stage of MLCube include singularity, run {volumes} and {task args}. So these runners can be used accordingly in the Singularity working environment and instantiate MLCube in the working environment to train or use the shared model.

    MLCube in Secure Shell (ssh)

    The MLCube package for Secure Shell (ssh) can be used by first installing the MLCube package that is designed for the ssh. That can be done through a pip command as shown below.

    !pip install mlcube-ssh

    Some of the basic commands that have to be used in Secure Shell are ssh and rsync to activate the MLCube library in the secure shell working environment. The models shared can be made available in the secure shell working environment and the models can be used or trained accordingly by overriding certain ssh command line arguments. The rsync command has to be used efficiently to instantiate and to synchronize the training and running process of the model in the secure shell (ssh) environment.

    Case Study of MLCube in Docker

    In the development phase of MLCube, there are 4 use cases mentioned in the official Github repository.  Some of the use cases of MLCube include MNIST data-based model training and sharing, A simple hello world program, A example of using Electron Microscopy (EMDenoise) dataset, and a simple program to perform matrix multiplication famously known as matmul.

    In this article let us try to understand how MLCube is used for the MNIST data and train it in the docker platform. Consider that you are working in the docker terminal.

    Step-1: Create a python environment in the Docker platform

    Let us create a virtual python environment in the docker platform and activate the virtual environment created using the below lines of code.

    # Create a python virtual environment
    virtualenv -p python3 ./env && source ./env/bin/activate

    Step-2: Installing the MLCube docker package

    Let us install the MLCube docker page in the Docker environment by using the pip command as shown below.

    pip install mlcube mlcube-docker

    Step-3: Check for docker runners

    Once the MLCube docker library is installed in the Docker environment we have to check for all appropriate runners installed for Docker by using the below code.

    mlcube config --get runners

    Step-4: Check for platform configuration

    Once the MLcube docker library is installed in the Docker environment we have to check for platform configurations with respect to MLCube requirements by using the below code.

    mlcube config --get platforms

    Step-5: Cloning to MLCube examples Github repository

    As the MLCube library is still in the development stage currently we can only clone into the example repository of Github. So let us clone into the example repository of MLCube and we have to redirect to the cloned directory. We can use the below code to do the same.

    git clone 'https://github.com/mlcommons/mlcube_examples.git' && cd './mlcube_examples/mnist'

    Step-6: Visualizing the overview of the MLCube docker version

    We have to visualize the overview of the docker version of MLCube to interpret the successful cloning into the Github repository and to validate install of all prerequisites.

    mlcube describe --mlcube

    Step-7: Resolving MLCube configuration for Docker

    We have to validate and resolve MLCube library configurations for the Docker platform using the below code.

    mlcube show_config --resolve --mlcube . --platform docker

    Step-8: Downloading MNIST data from MLCube

    The MNIST data has to be downloaded into the Docker platform using the below code.

    mlcube run --mlcube . --task download --platform docker

    Step-9: Training the MLCube model in the Docker platform

    Now let us train the model for MNIST data in the docker platform using the below code.

    mlcube run --mlcube . --task train --platform docker

    So this is how MLCube has to be used in the Docker platform to make use of the MNIST data and use the trained model from the MLCube library in the Docker platform.

    Summary

    MLCube is a single shot framework that is used to increase the availability of models across platforms. It is still in the development stage and currently, it has the ability to function across 6 platforms flawlessly with the shared models. Through MLCube a single model can be shared anywhere in the world across different platforms right from localhost platforms, cloud-based platforms to Kubernetes clusters and Dockers. Due to MLCube, we can ensure more models active and in action for the desired tasks across various platforms as it is a simple plug-and-play library to share and use models across platforms.

    References

    Your reaction

    Discussion

    What's your take on this story?

    0/1000

    No comments yet — be the first to share your view.

    Explore our newsletters

    Build your routine with some of our top newsletters or view them all here.

    Wake up informed

    Make sense of the day's AI news and breakthroughs with our morning briefing.

    Belamy
    WeeklyBelamySee the latest

    Industry intelligence

    Receive a roundup of AI adoption stories by industry vertical, curated for professionals.

    3x WeeklySector6See the latest

    By signing up, you agree to our Privacy Policy.

    Membership

    Stay ahead with AI insights.

    Unlimited access to premium articles, exclusive analysis, and the stories shaping India's AI economy.

    Subscribe now

    AIM Americas

    1190 Miraloma Way Suite P, Sunnyvale, CA 94085

    AIM India

    1st Floor, Sakti Statesman, Bellandur, Bengaluru – 560103

    © 2026 AIM. All rights reserved.