Notebooks
A
Amazon Web Services
Sm Training Queues Getting Started With Model Trainer

Sm Training Queues Getting Started With Model Trainer

data-scienceinferenceamazon-sagemaker-examplessm-training-queuesreinforcement-learningmachine-learningawsexamplesdeep-learningsagemakerjupyter-notebooktrainingmlopsbuild_and_train_models

Getting Started with AWS Batch for SageMaker Training jobs


This notebook's CI test result for us-west-2 is as follows. CI test results in other regions can be found at the end of the notebook.

This us-west-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable


This sample notebook will demonstrate how to submit some simple 'hello world' jobs to an AWS Batch job queue using a ModelTrainer. You can run any of the cells in this notebook interactively to experiment with using your queue. Batch will take care of ensuring your jobs run automatically as your service environment capacity becomes available.

Setup and Configure Training Job Variables

We will need a single instance for a short duration for the sample jobs. Change any of the constant variables below to adjust the example to your liking.

[1]
[ ]

Create Sample Resources

The diagram belows shows the Batch resources we'll create for this example.

The Resources to Create

You can use Batch Console to create these resources, or you can run the cell below. The create_resources function below will skip creating any resources that already exist.

[ ]

Create Hello World Model Trainer

Now that our resources are created, we'll construct a simple ModelTrainer.

[ ]

Create TrainingQueue object

Using our queue is as easy as referring to it by name in the TrainingQueue contructor. The TrainingQueue class within the SageMaker Python SDK provides built in support for working with Batch queues.

[ ]

Submit Some Training Jobs

Submitting your job to the queue is done by calling queue.submit. This particular job doesn't require any data, but in general, data should be provided by specifying inputs.

[ ]

Terminate a Job in the Queue

This next cell shows how to terminate an in queue job.

[ ]

Monitor Job Status

This next cell shows how to list the jobs that have been submitted to the TrainingQueue. The TrainingQueue can list jobs by status, and each job can be described individually for more details. Once a TrainingQueuedJob has reached the STARTING status, the logs can be printed from underlying SageMaker training job.

[ ]

Optional: Delete AWS Batch Resources

This shows how to delete the AWS Batch ServiceEnvironment and JobQueue. This step is completely optional, uncomment the code below to delete the resources created a few steps above.

[9]

Notebook CI Test Results

This notebook was tested in multiple regions. The test results are as follows, except for us-west-2 which is shown at the top of the notebook.

This us-east-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This us-east-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This us-west-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This ca-central-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This sa-east-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This eu-west-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This eu-west-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This eu-west-3 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This eu-central-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This eu-north-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This ap-southeast-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This ap-southeast-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This ap-northeast-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This ap-northeast-2 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable

This ap-south-1 badge failed to load. Check your device's internet connectivity, otherwise the service is currently unavailable