Amazon Web Services (AWS) Sagemaker is a powerful machine learning service that allows you to build, train, and deploy machine learning models quickly and easily. However, by default, AWS Sagemaker charges you based on the number of hours you use the service. This can be expensive, especially if you only use Sagemaker sporadically or for short periods of time. In this article, we will show you how to use AWS Sagemaker based on usage, rather than on an hourly basis, to help you save costs.
Before we dive into the details, it's important to understand the difference between using Sagemaker based on usage versus on an hourly basis. When you use Sagemaker on an hourly basis, you are charged for the entire hour, regardless of how much time you actually spend using the service. On the other hand, using Sagemaker based on usage means that you are only charged for the actual amount of time you spend using the service, down to the second.
Now let's see how you can configure AWS Sagemaker to be billed based on usage:
Step 1: Enable Detailed Billing Reports
The first step is to enable detailed billing reports in your AWS account. This will allow you to see the usage of individual services, including Sagemaker, in your billing reports.
- Sign in to the AWS Management Console.
- Open the Billing and Cost Management console.
- In the navigation pane, choose "Preferences".
- Under "Reports", select "Receive Billing Reports".
- Enable "Detailed Billing Reports" and choose a delivery method (e.g., S3 bucket).
- Save your preferences.
Step 2: Monitor Sagemaker Usage
Once you have enabled detailed billing reports, you can start monitoring your Sagemaker usage to understand how much time you are actually spending using the service.
- Open the AWS Management Console.
- Open the Sagemaker console.
- In the navigation pane, choose "Notebook instances".
- Select the notebook instance you want to monitor.
- Choose the "Monitoring" tab.
- Under "Monitoring", you will find information about the duration of each usage session, including start and end times.
Step 3: Stop and Start Notebook Instances
Now that you are monitoring your Sagemaker usage, you can start optimizing your costs by stopping and starting your notebook instances as needed.
- Open the AWS Management Console.
- Open the Sagemaker console.
- In the navigation pane, choose "Notebook instances".
- Select the notebook instance you want to stop.
- Choose "Actions" and then "Stop".
- When you want to use the notebook instance again, simply choose "Actions" and then "Start".
By stopping notebook instances when you are not using them, you can significantly reduce your costs, as you will only be charged for the actual time you spend using the service.
It's important to note that stopping a notebook instance will not delete any data or models stored on the instance. When you start the instance again, it will resume from where you left off.
Step 4: Automate Start and Stop
To make it even easier to manage your Sagemaker costs, you can automate the start and stop process using AWS Lambda and CloudWatch Events.
- Open the AWS Management Console.
- Open the Lambda console.
- Create a new Lambda function.
- Choose a blueprint that suits your needs (e.g., "Blank Function").
- Configure the function to start and stop the notebook instance based on a schedule.
- Save and test your Lambda function.
- Open the CloudWatch console.
- Create a new rule.
- Set the rule to trigger the Lambda function at the desired start and stop times.
- Save the rule.
By automating the start and stop process, you can ensure that your notebook instances are only running when you need them, saving you even more costs.
Using AWS Sagemaker based on usage, rather than on an hourly basis, can help you optimize your costs and make the most out of this powerful machine learning service. By enabling detailed billing reports, monitoring your usage, stopping and starting notebook instances, and automating the process, you can save money while still benefiting from the capabilities of AWS Sagemaker.
References
| Reference | Link |
|---|---|
| AWS Sagemaker Documentation | https://docs.aws.amazon.com/sagemaker/ |
| AWS Billing and Cost Management Documentation | https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/billing-what-is.html |
| AWS Lambda Documentation | https://docs.aws.amazon.com/lambda/ |
| AWS CloudWatch Documentation | https://docs.aws.amazon.com/cloudwatch/ |