Skip to content

Create Sklearn model.tar.gz in one sagemaker, use the model in another sagemaker without using endpoint #1854

Closed

Description

@radhakrishnang

I am creating model.tar.gz for random forest classifier in sagemaker using sklearn based on sagemaker sklearn end 2 end example

my goal is to use the saved model in one sagemaker environment to deploy in another sagemaker environment without doing estimator or training again i just need to do batch transform

can you please point any documentation on loading the model and doing batch

Activity

  1. chuyang-deng commented on Sep 1, 2020

    @chuyang-deng
    Contributor

    Hi @radhakrishnang, if you have a pre-trained model, assuming that you have the S3 uri of the model artifact and your SageMaker role has access to the object, you can do the following to deploy the model to an endpoint:

    https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/sklearn/model.py#L53
    https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/model.py#L406

    model = SKLearnModel(model_data=<your pre-trained model location in S3>,
                                             role=<your SageMaker role>,
                                             entrypoint=<your inference script>,
                                             ... # other optional params)
    
    model.deploy(initial_instance_count=<instance count>,
                           instance_type=<chosen instance type>,
                           ... # other optional params)
    

    As for the batch transform, after your endpoint is in service, you can proceed batch transforming as normal.

  2. radhakrishnang commented on Sep 2, 2020

    @radhakrishnang
    Author

    Hi @radhakrishnang, if you have a pre-trained model, assuming that you have the S3 uri of the model artifact and your SageMaker role has access to the object, you can do the following to deploy the model to an endpoint:

    https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/sklearn/model.py#L53
    https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/model.py#L406

    model = SKLearnModel(model_data=<your pre-trained model location in S3>,
                                             role=<your SageMaker role>,
                                             entrypoint=<your inference script>,
                                             ... # other optional params)
    
    model.deploy(initial_instance_count=<instance count>,
                           instance_type=<chosen instance type>,
                           ... # other optional params)
    

    As for the batch transform, after your endpoint is in service, you can proceed batch transforming as normal.

    Ni hao @ChuyangDeng,

    I want to use model.tar.gz created from already trained model in sagemaker to be directly deployed in another sagemaker environment for batch transform without training again or having endpoint creation ... is it feasible?

    Xiexie

  3. locked and limited conversation to collaborators on May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions