/amazon-sagemaker-local-mode

Amazon SageMaker Local Mode Examples

Primary LanguagePythonMIT No AttributionMIT-0

Amazon SageMaker Local Mode Examples

This repository contains examples and related resources showing you how to preprocess, train, debug your training script with breakpoints, and serve on your local machine using Amazon SageMaker Local mode for processing jobs, training and serving.

Overview

The local mode in the Amazon SageMaker Python SDK can emulate CPU (single and multi-instance) and GPU (single instance) SageMaker training jobs by changing a single argument in the TensorFlow, PyTorch or MXNet estimators. To do this, it uses Docker compose and NVIDIA Docker. It will also pull the Amazon SageMaker TensorFlow, PyTorch or MXNet containers from Amazon ECS, so you’ll need to be able to access a public Amazon ECR repository from your local environment.

For full details on how this works:

SageMaker local mode training and serving in PyCharm

This repository examples will work in any IDE on your local machine.

Here you can see a TensorFlow example running on PyCharm. The data for training and serving is also located on your local machine file system.

SageMaker local mode training in PyCharm

SageMaker local mode training in PyCharm

SageMaker local mode serving in PyCharm

SageMaker local mode serving in PyCharm

SageMaker local mode processing jobs in PyCharm

SageMaker local mode processing jobs in PyCharm

Debugging your training script running SageMaker local mode training in PyCharm

Debug your application

Repository Structure

The repository contains the following resources:

  • scikit-learn resources:

  • XGBoost resources:

  • TensorFlow resources:

  • PyTorch resources:

  • Bring Your Own Container resources:

    • Bring Your Own Container TensorFlow Algorithm - Train/Serve: This example provides a detailed walkthrough on how to package a Tensorflow 2.5.0 algorithm for training and production-ready hosting. We have included also a Python file for local training and serving that can run on your local computer, for faster development.
    • Bring Your Own Container TensorFlow Algorithm - Train/Batch Transform: This example provides a detailed walkthrough on how to package a Tensorflow 2.5.0 algorithm for training, and then run a Batch Transform job on a CSV file. We have included also a Python file for local training and serving that can run on your local computer, for faster development.
    • Bring Your Own Container CatBoost Algorithm: This example provides a detailed walkthrough on how to package a CatBoost algorithm for training and production-ready hosting. We have included also a Python file for local training and serving that can run on your local computer, for faster development.
    • Bring Your Own Container LightGBM Algorithm: This example provides a detailed walkthrough on how to package a LightGBM algorithm for training and production-ready hosting. We have included also a Python file for local training and serving that can run on your local computer, for faster development.
    • Bring Your Own Container Prophet Algorithm: This example provides a detailed walkthrough on how to package a Prophet algorithm for training and production-ready hosting. We have included also a Python file for local training and serving that can run on your local computer, for faster development.
    • Bring Your Own Container HDBSCAN Algorithm: This example provides a detailed walkthrough on how to package a HDBSCAN algorithm for training. We have included also a Python file for local training that can run on your local computer, for faster development.
  • Built-in scikit-learn Processing Job :

    • Built-in scikit-learn Processing Job: This example provides a detailed walkthrough on how to use the built-in scikit-learn Docker image for processing jobs. We have included also a Python file for processing jobs that can run on your local computer, for faster development.
  • Bring Your Own Container scikit-learn Processing Job :

    • Bring Your Own Container scikit-learn Processing Job: This example provides a detailed walkthrough on how to package a scikit-learn Docker image for processing jobs. We have included also a Python file for processing jobs that can run on your local computer, for faster development.

Note: Those examples were tested on macOS and Linux.

Installation Instructions

  1. Create an AWS account if you do not already have one and login.

  2. Install Docker Desktop for Mac

  3. Install the AWS CLI and Configure AWS credentials.

  4. Clone the repo onto your local development machine using git clone.

  5. Open the project in any IDE of your choice in order to run the example Python files.

  6. Follow the instructions on which Python packages to install in each of the example Python file.

Questions?

Please contact @e_sela or raise an issue on this repo.

License

This library is licensed under the MIT-0 License. See the LICENSE file.