In this tutorial, we describe the recommended way to train a simple machine learning model on the Apolo platform. As our ML engineers prefer PyTorch over other ML frameworks, we show the training and evaluation of one of the basic PyTorch examples.
We assume that you have already signed up to the platform, installed the Apolo CLI, and logged in to the platform (see Getting Started).
To simplify working with Apolo Platform and to help establish the best practices in the ML environment, we provide a flow template. This template consists of the recommended directories and files. It's designed to operate smoothly with our base environment.
To use it, install the cookiecutter package and initialize cookiecutter-neuro-project:
Download data from here, extract the ZIP’s content and put it in your data folder:
Training and evaluating the model
When you start working with a flow on the Apolo platform, the basic flow looks as follows: you set up the remote environment, upload data and code to your storage, run training, and evaluate the results.
To set up the remote environment, run
This command will run a lightweight job (via apolo run), upload the files containing your dependencies apt.txt and requirements.txt (via apolo cp), install the dependencies (using apolo exec), do other preparatory steps, and then create the base image from this job and push it to the platform (via apolo save, which works similarly to docker commit).
To upload data and code to your storage, run
To run training job, you need to specify the training script in .neuro/live.yaml, and then run apolo-flow run train:
open .neuro/live.yaml in an editor,
find the following lines (make sure you're looking at the train job, not multitrain which has a very similar section):
and replace it with the following lines:
Now, you can run
and observe the output. You will see how some checks are made at the beginning of the script, and then the model is being trained and evaluated:
apolo-tutorial
├── .github/ <- Github workflows and a dependabot.yml file
├── .neuro/ <- apolo and apolo-flow CLI configuration files
├── config/ <- configuration files for various integrations
├── data/ <- training and testing datasets (we don't keep it under source control)
├── notebooks/ <- Jupyter notebooks
├── rnn/ <- models' source code
├── results/ <- training artifacts
├── .gitignore <- default .gitignore file for a Python ML project
├── .neuro.toml <- autogenerated config file
├── .neuroignore <- a file telling apolo to ignore the results/ folder
├── HELP.md <- autogenerated template reference
├── README.md <- autogenerated informational file
├── Dockerfile <- description of the base image used for your project
├── apt.txt <- list of system packages to be installed in the training environment
├── requirements.txt <- list of Python dependencies to be installed in the training environment
├── setup.cfg <- linter settings (Python code quality checking)
└── update_actions.py <- instructions on update actions