How to access model.tar file before sagemaker uploads it to the output path?

0

I have a training step (sample code below) in my sagemaker pipeline. once the training is done, anything inside the /opt/ml/model file is zipped up into model.tar file and sagemaker uploads it to an s3 location. can one get access this model.tar file before sagemaker uploads it to the s3 bucket. say from my training step, i wanted to access model.tar file , once the training is done and before sagemaker uploads it to the s3 output location . is it saved locally in the training instance , before uploading it to the s3 location ? if this is not possible, can i define another processing step to run after the trainign step , to download this model, wherever sagemaker saved it ( s3 uri) . to do this, can i define a processing step, such that if i give it a s3 location of the model, sagemaker will automatically download the model , or do i need to write code to download the model?


from sagemaker.estimator import Estimator
from sagemaker.inputs import TrainingInput

xgb_train = Estimator(
    image_uri="some_uri",
    instance_type=instance_type,
    instance_count=1,
    output_path=model_path,
    role=role,
    sagemaker_session=pipeline_session,
)

#training code 
train_args = xgb_train.fit(
    inputs={
        "train": TrainingInput(
            s3_data=step_process.properties.ProcessingOutputConfig.Outputs["train"].S3Output.S3Uri,
            content_type="text/csv",
        ),
        "validation": TrainingInput(
            s3_data=step_process.properties.ProcessingOutputConfig.Outputs[
                "validation"
            ].S3Output.S3Uri,
            content_type="text/csv",
        ),
    }
)

  • Can you share what you are planning to do once you access the tar file? You can write a script to download the S3 model in a processing step, but it will download it to the processing instance, which is also ephemeral.

已提问 1 年前249 查看次数
1 回答
0

You can try to do something like this or copy object as the download may happen on training instance

s3 = boto3.client('s3') s3.download_file('BUCKET_NAME', 'OBJECT_NAME', 'FILE_NAME')

profile pictureAWS
专家
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则