Method: Aws::SageMaker::Client#create_model

Defined in:
lib/aws-sdk-sagemaker/client.rb

#create_model(params = {}) ⇒ Types::CreateModelOutput

Creates a model in SageMaker. In the request, you name the model and describe a primary container. For the primary container, you specify the Docker image that contains inference code, artifacts (from prior training), and a custom environment map that the inference code uses when you deploy the model for predictions.

Use this API to create a model if you want to use SageMaker hosting services or run a batch transform job.

To host your model, you create an endpoint configuration with the ‘CreateEndpointConfig` API, and then create an endpoint with the `CreateEndpoint` API. SageMaker then deploys all of the containers that you defined for the model in the hosting environment.

To run a batch transform using your model, you start a job with the ‘CreateTransformJob` API. SageMaker uses your model and your dataset to get inferences which are then saved to a specified S3 location.

In the request, you also provide an IAM role that SageMaker can assume to access model artifacts and docker image for deployment on ML compute hosting instances or for batch transform jobs. In addition, you also use the IAM role to manage permissions the inference code needs. For example, if the inference code access any other Amazon Web Services resources, you grant necessary permissions via this role.

Examples:

Request syntax with placeholder values


resp = client.create_model({
  model_name: "ModelName", # required
  primary_container: {
    container_hostname: "ContainerHostname",
    image: "ContainerImage",
    image_config: {
      repository_access_mode: "Platform", # required, accepts Platform, Vpc
      repository_auth_config: {
        repository_credentials_provider_arn: "RepositoryCredentialsProviderArn", # required
      },
    },
    mode: "SingleModel", # accepts SingleModel, MultiModel
    model_data_url: "Url",
    model_data_source: {
      s3_data_source: {
        s3_uri: "S3ModelUri", # required
        s3_data_type: "S3Prefix", # required, accepts S3Prefix, S3Object
        compression_type: "None", # required, accepts None, Gzip
        model_access_config: {
          accept_eula: false, # required
        },
      },
    },
    environment: {
      "EnvironmentKey" => "EnvironmentValue",
    },
    model_package_name: "VersionedArnOrName",
    inference_specification_name: "InferenceSpecificationName",
    multi_model_config: {
      model_cache_setting: "Enabled", # accepts Enabled, Disabled
    },
  },
  containers: [
    {
      container_hostname: "ContainerHostname",
      image: "ContainerImage",
      image_config: {
        repository_access_mode: "Platform", # required, accepts Platform, Vpc
        repository_auth_config: {
          repository_credentials_provider_arn: "RepositoryCredentialsProviderArn", # required
        },
      },
      mode: "SingleModel", # accepts SingleModel, MultiModel
      model_data_url: "Url",
      model_data_source: {
        s3_data_source: {
          s3_uri: "S3ModelUri", # required
          s3_data_type: "S3Prefix", # required, accepts S3Prefix, S3Object
          compression_type: "None", # required, accepts None, Gzip
          model_access_config: {
            accept_eula: false, # required
          },
        },
      },
      environment: {
        "EnvironmentKey" => "EnvironmentValue",
      },
      model_package_name: "VersionedArnOrName",
      inference_specification_name: "InferenceSpecificationName",
      multi_model_config: {
        model_cache_setting: "Enabled", # accepts Enabled, Disabled
      },
    },
  ],
  inference_execution_config: {
    mode: "Serial", # required, accepts Serial, Direct
  },
  execution_role_arn: "RoleArn",
  tags: [
    {
      key: "TagKey", # required
      value: "TagValue", # required
    },
  ],
  vpc_config: {
    security_group_ids: ["SecurityGroupId"], # required
    subnets: ["SubnetId"], # required
  },
  enable_network_isolation: false,
})

Response structure


resp.model_arn #=> String

Options Hash (params):

See Also:



5482
5483
5484
5485
# File 'lib/aws-sdk-sagemaker/client.rb', line 5482

def create_model(params = {}, options = {})
  req = build_request(:create_model, params)
  req.send_request(options)
end