Skip to content
Get Started for Free

SageMaker

Amazon SageMaker is a fully managed service provided by Amazon Web Services (AWS) that provides the tools to build, train, and deploy machine-learning models in the cloud for predictive analytics applications. It streamlines the machine learning development process, reduces the time and effort required to build and deploy models, and offers the scalability and flexibility needed for large-scale machine learning projects in the AWS cloud.

LocalStack provides a local version of the SageMaker API, which allows running jobs to create machine learning models (e.g., using PyTorch) and to deploy them. The supported APIs are available on our API Coverage section, which provides information on the extent of Sagemaker’s integration with LocalStack.

This guide is designed for users new to SageMaker and assumes basic knowledge of Python3 and AWS SDK for Python (Boto3).

We will demonstrate an application illustrating running a machine learning job using the SageMaker API locally that perform the following:

  • Set up an MNIST model in SageMaker using LocalStack.
  • Creates a SageMaker Endpoint for accessing the model
  • Invokes the endpoint directly on the container via Boto3

You can download the sample application from GitHub or by running the following commands:

Terminal window
mkdir localstack-samples && cd localstack-samples
git init
git remote add origin -f git@github.com:localstack/localstack-pro-samples.git
git config core.sparseCheckout true
echo sagemaker-inference >> .git/info/sparse-checkout
git pull origin master

After downloading the sample application, you can set up your Docker Client to pull the AWS Deep Learning images by running the following command:

Terminal window
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 763104351884.dkr.ecr.us-east-1.amazonaws.com

Since the images are quite large (several gigabytes), it’s a good idea to pull the images using Docker in advance.

Terminal window
docker pull 763104351884.dkr.ecr.us-east-1.amazonaws.com/pytorch-inference:1.5.0-cpu-py3

Start your LocalStack container using your preferred method. Run the sample application by executing the following command:

Terminal window
python3 main.py
Output
Creating bucket...
Uploading model data to bucket...
Creating model in SageMaker...
Adding endpoint configuration...
Creating endpoint...
Checking endpoint status...
Endpoint not ready - waiting...
Checking endpoint status...
Endpoint ready!
Invoking via boto...
Predicted digits: [7, 3]
Invoking endpoint directly...
Predicted digits: [2, 6]

You can also invoke a serverless endpoint, by navigating to main.py and uncommenting the run_serverless function call.

The LocalStack Web Application provides a Resource Browser for managing Sagemaker resources. You can access the Resource Browser by opening the LocalStack Web Application in your browser, navigating to the Resources section, and then clicking on Sagemaker under the Compute section.

The Resource Browser displays Models, Endpoint Configurations and Endpoint. You can click on individual resources to view their details.

Sagemaker Resource Browser

The Resource Browser allows you to perform the following actions:

  • Create and Remove Models: You can remove existing model and create a new model with the required configuration

    Sagemaker Create Model

  • Endpoint Configurations & Endpoints: You can create endpoints from the resource browser that hosts your deployed machine learning model. You can also create endpoint configuration that specifies the type and number of instances that will be used to serve your model on an endpoint.

The following code snippets and sample applications provide practical examples of how to use Sagemaker in LocalStack for various use cases:

Currently, GPU models are not supported by the LocalStack SageMaker implementation.

119 of 404 operations implemented

Available from the Ultimate plan. Licensing details

Find an API

Search the full operation list, then sort the table to compare current support.

Loading operations…

Verified on Kubernetes
Loading operations…
Complete static API list All 404 operations and their current support status
OperationStatus
AddAssociationNot implemented
AddTagsImplemented
AssociateTrialComponentImplemented
AttachClusterNodeNetworkInterfaceNot implemented
AttachClusterNodeVolumeNot implemented
BatchAddClusterNodesNot implemented
BatchDeleteClusterNodesNot implemented
BatchDescribeModelPackageNot implemented
BatchRebootClusterNodesNot implemented
BatchReplaceClusterNodesNot implemented
CreateAIBenchmarkJobNot implemented
CreateAIRecommendationJobNot implemented
CreateAIWorkloadConfigNot implemented
CreateActionNot implemented
CreateAlgorithmNot implemented
CreateAppNot implemented
CreateAppImageConfigNot implemented
CreateArtifactNot implemented
CreateAutoMLJobNot implemented
CreateAutoMLJobV2Implemented
CreateClusterImplemented
CreateClusterSchedulerConfigNot implemented
CreateCodeRepositoryNot implemented
CreateCompilationJobImplemented
CreateComputeQuotaNot implemented
CreateContextNot implemented
CreateDataQualityJobDefinitionImplemented
CreateDeviceFleetNot implemented
CreateDomainImplemented
CreateEdgeDeploymentPlanNot implemented
CreateEdgeDeploymentStageNot implemented
CreateEdgePackagingJobNot implemented
CreateEndpointImplemented
CreateEndpointConfigImplemented
CreateExperimentImplemented
CreateFeatureGroupImplemented
CreateFlowDefinitionNot implemented
CreateHubNot implemented
CreateHubContentPresignedUrlsNot implemented
CreateHubContentReferenceNot implemented
CreateHumanTaskUiNot implemented
CreateHyperParameterTuningJobImplemented
CreateImageNot implemented
CreateImageVersionNot implemented
CreateInferenceComponentNot implemented
CreateInferenceExperimentNot implemented
CreateInferenceRecommendationsJobNot implemented
CreateJobNot implemented
CreateLabelingJobNot implemented
CreateMlflowAppNot implemented
CreateMlflowTrackingServerNot implemented
CreateModelImplemented
CreateModelBiasJobDefinitionImplemented
CreateModelCardImplemented
CreateModelCardExportJobNot implemented
CreateModelExplainabilityJobDefinitionImplemented
CreateModelPackageImplemented
CreateModelPackageGroupImplemented
CreateModelQualityJobDefinitionImplemented
CreateMonitoringScheduleNot implemented
CreateNotebookInstanceImplemented
CreateNotebookInstanceLifecycleConfigImplemented
CreateOptimizationJobNot implemented
CreatePartnerAppNot implemented
CreatePartnerAppPresignedUrlNot implemented
CreatePipelineImplemented
CreatePresignedDomainUrlNot implemented
CreatePresignedMlflowAppUrlNot implemented
CreatePresignedMlflowTrackingServerUrlNot implemented
CreatePresignedNotebookInstanceUrlNot implemented
CreateProcessingJobImplemented
CreateProjectNot implemented
CreateSpaceNot implemented
CreateStudioLifecycleConfigNot implemented
CreateTrainingJobImplemented
CreateTrainingPlanNot implemented
CreateTransformJobImplemented
CreateTrialImplemented
CreateTrialComponentImplemented
CreateUserProfileImplemented
CreateWorkforceNot implemented
CreateWorkteamNot implemented
DeleteAIBenchmarkJobNot implemented
DeleteAIRecommendationJobNot implemented
DeleteAIWorkloadConfigNot implemented
DeleteActionNot implemented
DeleteAlgorithmNot implemented
DeleteAppNot implemented
DeleteAppImageConfigNot implemented
DeleteArtifactNot implemented
DeleteAssociationNot implemented
DeleteClusterImplemented
DeleteClusterSchedulerConfigNot implemented
DeleteCodeRepositoryNot implemented
DeleteCompilationJobImplemented
DeleteComputeQuotaNot implemented
DeleteContextNot implemented
DeleteDataQualityJobDefinitionImplemented
DeleteDeviceFleetNot implemented
DeleteDomainImplemented
DeleteEdgeDeploymentPlanNot implemented
DeleteEdgeDeploymentStageNot implemented
DeleteEndpointImplemented
DeleteEndpointConfigImplemented
DeleteExperimentImplemented
DeleteFeatureGroupNot implemented
DeleteFlowDefinitionNot implemented
DeleteHubNot implemented
DeleteHubContentNot implemented
DeleteHubContentReferenceNot implemented
DeleteHumanTaskUiNot implemented
DeleteHyperParameterTuningJobImplemented
DeleteImageNot implemented
DeleteImageVersionNot implemented
DeleteInferenceComponentNot implemented
DeleteInferenceExperimentNot implemented
DeleteJobNot implemented
DeleteMlflowAppNot implemented
DeleteMlflowTrackingServerNot implemented
DeleteModelImplemented
DeleteModelBiasJobDefinitionImplemented
DeleteModelCardImplemented
DeleteModelExplainabilityJobDefinitionImplemented
DeleteModelPackageNot implemented
DeleteModelPackageGroupNot implemented
DeleteModelPackageGroupPolicyNot implemented
DeleteModelQualityJobDefinitionImplemented
DeleteMonitoringScheduleNot implemented
DeleteNotebookInstanceImplemented
DeleteNotebookInstanceLifecycleConfigImplemented
DeleteOptimizationJobNot implemented
DeletePartnerAppNot implemented
DeletePipelineImplemented
DeleteProcessingJobNot implemented
DeleteProjectNot implemented
DeleteSpaceNot implemented
DeleteStudioLifecycleConfigNot implemented
DeleteTagsImplemented
DeleteTrainingJobNot implemented
DeleteTrialImplemented
DeleteTrialComponentImplemented
DeleteUserProfileImplemented
DeleteWorkforceNot implemented
DeleteWorkteamNot implemented
DeregisterDevicesNot implemented
DescribeAIBenchmarkJobNot implemented
DescribeAIRecommendationJobNot implemented
DescribeAIWorkloadConfigNot implemented
DescribeActionNot implemented
DescribeAlgorithmNot implemented
DescribeAppNot implemented
DescribeAppImageConfigNot implemented
DescribeArtifactNot implemented
DescribeAutoMLJobNot implemented
DescribeAutoMLJobV2Implemented
DescribeClusterImplemented
DescribeClusterEventNot implemented
DescribeClusterNodeImplemented
DescribeClusterSchedulerConfigNot implemented
DescribeCodeRepositoryNot implemented
DescribeCompilationJobImplemented
DescribeComputeQuotaNot implemented
DescribeContextNot implemented
DescribeDataQualityJobDefinitionImplemented
DescribeDeviceNot implemented
DescribeDeviceFleetNot implemented
DescribeDomainImplemented
DescribeEdgeDeploymentPlanNot implemented
DescribeEdgePackagingJobNot implemented
DescribeEndpointImplemented
DescribeEndpointConfigImplemented
DescribeExperimentImplemented
DescribeFeatureGroupImplemented
DescribeFeatureMetadataNot implemented
DescribeFlowDefinitionNot implemented
DescribeHubNot implemented
DescribeHubContentNot implemented
DescribeHumanTaskUiNot implemented
DescribeHyperParameterTuningJobImplemented
DescribeImageNot implemented
DescribeImageVersionNot implemented
DescribeInferenceComponentNot implemented
DescribeInferenceExperimentNot implemented
DescribeInferenceRecommendationsJobNot implemented
DescribeJobNot implemented
DescribeJobSchemaVersionNot implemented
DescribeLabelingJobNot implemented
DescribeLineageGroupNot implemented
DescribeMlflowAppNot implemented
DescribeMlflowTrackingServerNot implemented
DescribeModelImplemented
DescribeModelBiasJobDefinitionImplemented
DescribeModelCardImplemented
DescribeModelCardExportJobNot implemented
DescribeModelExplainabilityJobDefinitionImplemented
DescribeModelPackageImplemented
DescribeModelPackageGroupImplemented
DescribeModelQualityJobDefinitionImplemented
DescribeMonitoringScheduleNot implemented
DescribeNotebookInstanceImplemented
DescribeNotebookInstanceLifecycleConfigImplemented
DescribeOptimizationJobNot implemented
DescribePartnerAppNot implemented
DescribePipelineImplemented
DescribePipelineDefinitionForExecutionImplemented
DescribePipelineExecutionImplemented
DescribeProcessingJobImplemented
DescribeProjectNot implemented
DescribeReservedCapacityNot implemented
DescribeSpaceNot implemented
DescribeStudioLifecycleConfigNot implemented
DescribeSubscribedWorkteamNot implemented
DescribeTrainingJobImplemented
DescribeTrainingPlanNot implemented
DescribeTrainingPlanExtensionHistoryNot implemented
DescribeTransformJobImplemented
DescribeTrialImplemented
DescribeTrialComponentImplemented
DescribeUserProfileImplemented
DescribeWorkforceNot implemented
DescribeWorkteamNot implemented
DetachClusterNodeVolumeNot implemented
DisableSagemakerServicecatalogPortfolioNot implemented
DisassociateTrialComponentImplemented
EnableSagemakerServicecatalogPortfolioNot implemented
ExtendTrainingPlanNot implemented
GetDeviceFleetReportNot implemented
GetLineageGroupPolicyNot implemented
GetModelPackageGroupPolicyNot implemented
GetSagemakerServicecatalogPortfolioStatusNot implemented
GetScalingConfigurationRecommendationNot implemented
GetSearchSuggestionsNot implemented
ImportHubContentNot implemented
ListAIBenchmarkJobsNot implemented
ListAIRecommendationJobsNot implemented
ListAIWorkloadConfigsNot implemented
ListActionsNot implemented
ListAlgorithmsNot implemented
ListAliasesNot implemented
ListAppImageConfigsNot implemented
ListAppsNot implemented
ListArtifactsNot implemented
ListAssociationsNot implemented
ListAutoMLJobsImplemented
ListCandidatesForAutoMLJobNot implemented
ListClusterEventsNot implemented
ListClusterNodesImplemented
ListClusterSchedulerConfigsNot implemented
ListClustersImplemented
ListCodeRepositoriesNot implemented
ListCompilationJobsImplemented
ListComputeQuotasNot implemented
ListContextsNot implemented
ListDataQualityJobDefinitionsImplemented
ListDeviceFleetsNot implemented
ListDevicesNot implemented
ListDomainsImplemented
ListEdgeDeploymentPlansNot implemented
ListEdgePackagingJobsNot implemented
ListEndpointConfigsImplemented
ListEndpointsImplemented
ListExperimentsImplemented
ListFeatureGroupsNot implemented
ListFlowDefinitionsNot implemented
ListHubContentVersionsNot implemented
ListHubContentsNot implemented
ListHubsNot implemented
ListHumanTaskUisNot implemented
ListHyperParameterTuningJobsImplemented
ListImageVersionsNot implemented
ListImagesNot implemented
ListInferenceComponentsNot implemented
ListInferenceExperimentsNot implemented
ListInferenceRecommendationsJobStepsNot implemented
ListInferenceRecommendationsJobsNot implemented
ListJobSchemaVersionsNot implemented
ListJobsNot implemented
ListLabelingJobsNot implemented
ListLabelingJobsForWorkteamNot implemented
ListLineageGroupsNot implemented
ListMlflowAppsNot implemented
ListMlflowTrackingServersNot implemented
ListModelBiasJobDefinitionsImplemented
ListModelCardExportJobsNot implemented
ListModelCardVersionsImplemented
ListModelCardsImplemented
ListModelExplainabilityJobDefinitionsImplemented
ListModelMetadataNot implemented
ListModelPackageGroupsImplemented
ListModelPackagesImplemented
ListModelQualityJobDefinitionsImplemented
ListModelsImplemented
ListMonitoringAlertHistoryNot implemented
ListMonitoringAlertsNot implemented
ListMonitoringExecutionsNot implemented
ListMonitoringSchedulesNot implemented
ListNotebookInstanceLifecycleConfigsNot implemented
ListNotebookInstancesImplemented
ListOptimizationJobsNot implemented
ListPartnerAppsNot implemented
ListPipelineExecutionStepsNot implemented
ListPipelineExecutionsImplemented
ListPipelineParametersForExecutionImplemented
ListPipelineVersionsNot implemented
ListPipelinesImplemented
ListProcessingJobsImplemented
ListProjectsNot implemented
ListResourceCatalogsNot implemented
ListSpacesNot implemented
ListStageDevicesNot implemented
ListStudioLifecycleConfigsNot implemented
ListSubscribedWorkteamsNot implemented
ListTagsImplemented
ListTrainingJobsImplemented
ListTrainingJobsForHyperParameterTuningJobNot implemented
ListTrainingPlansNot implemented
ListTransformJobsImplemented
ListTrialComponentsImplemented
ListTrialsImplemented
ListUltraServersByReservedCapacityNot implemented
ListUserProfilesImplemented
ListWorkforcesNot implemented
ListWorkteamsNot implemented
PutModelPackageGroupPolicyNot implemented
QueryLineageNot implemented
RegisterDevicesNot implemented
RenderUiTemplateNot implemented
RetryPipelineExecutionNot implemented
SearchImplemented
SearchTrainingPlanOfferingsNot implemented
SendPipelineExecutionStepFailureNot implemented
SendPipelineExecutionStepSuccessNot implemented
StartClusterHealthCheckNot implemented
StartEdgeDeploymentStageNot implemented
StartInferenceExperimentNot implemented
StartMlflowTrackingServerNot implemented
StartMonitoringScheduleNot implemented
StartNotebookInstanceImplemented
StartPipelineExecutionImplemented
StartSessionNot implemented
StopAIBenchmarkJobNot implemented
StopAIRecommendationJobNot implemented
StopAutoMLJobImplemented
StopCompilationJobNot implemented
StopEdgeDeploymentStageNot implemented
StopEdgePackagingJobNot implemented
StopHyperParameterTuningJobNot implemented
StopInferenceExperimentNot implemented
StopInferenceRecommendationsJobNot implemented
StopJobNot implemented
StopLabelingJobNot implemented
StopMlflowTrackingServerNot implemented
StopMonitoringScheduleNot implemented
StopNotebookInstanceImplemented
StopOptimizationJobNot implemented
StopPipelineExecutionNot implemented
StopProcessingJobNot implemented
StopTrainingJobNot implemented
StopTransformJobNot implemented
UpdateActionNot implemented
UpdateAppImageConfigNot implemented
UpdateArtifactNot implemented
UpdateClusterNot implemented
UpdateClusterSchedulerConfigNot implemented
UpdateClusterSoftwareNot implemented
UpdateCodeRepositoryNot implemented
UpdateComputeQuotaNot implemented
UpdateContextNot implemented
UpdateDeviceFleetNot implemented
UpdateDevicesNot implemented
UpdateDomainImplemented
UpdateEndpointNot implemented
UpdateEndpointWeightsAndCapacitiesImplemented
UpdateExperimentNot implemented
UpdateFeatureGroupNot implemented
UpdateFeatureMetadataNot implemented
UpdateHubNot implemented
UpdateHubContentNot implemented
UpdateHubContentReferenceNot implemented
UpdateImageNot implemented
UpdateImageVersionNot implemented
UpdateInferenceComponentNot implemented
UpdateInferenceComponentRuntimeConfigNot implemented
UpdateInferenceExperimentNot implemented
UpdateMlflowAppNot implemented
UpdateMlflowTrackingServerNot implemented
UpdateModelCardImplemented
UpdateModelPackageImplemented
UpdateMonitoringAlertNot implemented
UpdateMonitoringScheduleNot implemented
UpdateNotebookInstanceNot implemented
UpdateNotebookInstanceLifecycleConfigNot implemented
UpdatePartnerAppNot implemented
UpdatePipelineImplemented
UpdatePipelineExecutionNot implemented
UpdatePipelineVersionNot implemented
UpdateProjectNot implemented
UpdateSpaceNot implemented
UpdateTrainingJobNot implemented
UpdateTrialNot implemented
UpdateTrialComponentImplemented
UpdateUserProfileImplemented
UpdateWorkforceNot implemented
UpdateWorkteamNot implemented

1 of 3 operations implemented

Available from the Ultimate plan. Licensing details

Find an API

Search the full operation list, then sort the table to compare current support.

Loading operations…

Verified on Kubernetes
Loading operations…
Complete static API list All 3 operations and their current support status
OperationStatus
InvokeEndpointImplemented
InvokeEndpointAsyncNot implemented
InvokeEndpointWithResponseStreamNot implemented
Was this page helpful?