Advanced: Distributed training sample project
Last updated
Last updated
One of the areas that we focus on with Gradient is distributed training which can be extremely valuable in terms of decreasing training time but is notoriously difficult to orchestrate. We put together a sample project which provides example code for both singlenode and multinode (distributed) training to showcase how easy it is to take a basic training job and scale it up across multiple instances on Gradient.
The sample project is an object detection demo based on Detectron using PyTorch and the COCO dataset. It also includes a step at the end to take your trained model and deploy it as an API endpoint. Here is a link the project on GitHub:
We provide an example script in "training/train_net.py" that is made to train your model. You can use this as a reference to write your own training script.
This demo has built-in support for a few datasets. Please check out docs on using Datasets with Gradient
The datasets are assumed to exist in a directory /data/DATASET
. Under this directory, the script will look for datasets in the structure described below, if needed.
Expected dataset structure for COCO instance/keypoint detection:
You can download a tiny version of the COCO dataset, with training/download_coco.sh
.
Probably the most widely used dataset today for object localization is COCO: Common Objects in Context. Provided here are all the files from the 2017 version, along with an additional subset dataset created by fast.ai. Details of each COCO dataset is available from the COCO dataset page. The fast.ai subset contains all images that contain one of five selected categories, restricting objects to just those five categories; the categories are: chair couch tv remote book vase.
How to install Gradient CLI - docs
Then make sure to obtain an API Key, and then:
Note: training on a single will take a long time, so be prepared to wait!
The coco dataset is downloaded to the ./data/coco/traing2017
directory. Model results are stored in the ./models
directory.
In order to run an experiment on a Gradient private cluster, we need to add a few additional parameters:
This example will load the previously trained model and launch a web app application with a simple interface for making predictions.