Why does AWS SageMaker create an S3 Bucket

Viewed 1047

Upon deploying a custom pytorch model with the boto3 client in python. I noticed that a new S3 bucket had been created with no visible objects. Is there a reason for this?

The bucket that contained my model was named with the keyword "sagemaker" included, so I don't any issue there.

Here is the code that I used for deployment:

remote_model = PyTorchModel(
                     name = model_name, 
                     model_data=model_url,
                     role=role,
                     sagemaker_session = sess,
                     entry_point="inference.py",
                     # image=image, 
                     framework_version="1.5.0",
                     py_version='py3'
                    )

remote_predictor = remote_model.deploy(
                         instance_type='ml.g4dn.xlarge', 
                         initial_instance_count=1,
                         #update_endpoint = True, # comment or False if endpoint doesns't exist
                         endpoint_name=endpoint_name, # define a unique endpoint name; if ommited, Sagemaker will generate it based on used container
                         wait=True
                         )
1 Answers

It was likely created as a default bucket by the SageMaker Python SDK. Note that the code you wrote about is not boto3 (AWS python SDK), but sagemaker (link), the SageMaker-specific Python SDK, that is higher-level than boto3.

The SageMaker Python SDK uses S3 at multiple places, for example to stage training code when using a Framework Estimator, and to stage inference code when deployment with a Framework Model (your case). It gives you control of the S3 location to use, but if you don't specify it, it may use an automatically generated bucket, if it has the permissions to do so.

To control code staging S3 location, you can use the parameter code_location in either your PyTorchEstimator (training) or your PyTorchModel (serving)

Related