This project demonstrates how to deploy a TensorFlow model on Amazon SageMaker, a fully managed machine learning platform. SageMaker simplifies the process of training, deploying, and managing machine learning models at scale.
├── notebooks
│ └── deploy-sagemaker-tensorflow.ipynb
└── src
├── __init__.py
├── mnist_tf2.py
LICENSE
contains the project's licensing information.- The
notebooks/
directory includes Jupyter notebooks for data exploration and model deployment. README.md
is this document.- The
src/
folder contains the source code for the TensorFlow model and any associated files.
This notebook demonstrates how to create a TensorFlow estimator on SageMaker, configure hyperparameters, train a model, and deploy it as an endpoint for inference using SageMaker.
The TensorFlow model source code is located in src/mnist_tf2.py
. This script contains the model definition, training logic, and model saving.
To run this notebook successfully, follow these steps:
-
Set Up an AWS Account:
- If you don't have an AWS account, sign up for an AWS account.
- Make sure to configure your AWS CLI with the necessary credentials using
aws configure
.
-
Clone the Repository:
-
Clone this GitHub repository to your local environment:
git clone https://github.com/Pedro-A-D-S/sagemaker-deploy.git cd sagemaker-deploy
-
-
Install Requirements:
-
Install the required Python packages by running:
pip install -r requirements.txt
This will ensure you have all the necessary libraries and dependencies to run the notebook.
-
-
Configure SageMaker Execution Role:
- Ensure that you have an appropriate SageMaker execution role with the necessary permissions to create and manage SageMaker resources. You can specify the execution role using the
get_execution_role()
function in the notebook.
- Ensure that you have an appropriate SageMaker execution role with the necessary permissions to create and manage SageMaker resources. You can specify the execution role using the
-
Accessing MNIST Training Data:
- In the notebook, we access the MNIST dataset from an S3 location. Ensure that your AWS account has sufficient permissions to access this data.
-
Running the Notebooks:
- Execute the Jupyter notebooks in the provided sequence:
deploy-sagemaker-tensorflow.ipynb
for model training and deployment.
- Execute the Jupyter notebooks in the provided sequence:
-
Clean Up Resources:
- After running the notebook, it's essential to delete any SageMaker endpoints to avoid incurring additional costs. This can be done using the
predictor.delete_endpoint()
function in the notebook.
- After running the notebook, it's essential to delete any SageMaker endpoints to avoid incurring additional costs. This can be done using the
By following these steps, you can successfully run and experiment with the TensorFlow model deployment on SageMaker. Enjoy your machine learning journey!
- Amazon SageMaker Documentation: Explore comprehensive documentation on Amazon SageMaker and its capabilities.
- TensorFlow on SageMaker Guide: Detailed instructions for using TensorFlow on Amazon SageMaker, including setup and best practices.
- Managed Spot Instances Example: Learn how to leverage Amazon EC2 Spot Instances for cost savings in SageMaker training jobs with this practical example.
Feel free to explore these resources to enhance your understanding of Amazon SageMaker and TensorFlow integration for machine learning projects.
This project is distributed under the MIT License. You are free to use, modify, and distribute this code for both commercial and non-commercial purposes. For more details, please see the LICENSE file.