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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南