PyTorchModel: PyTorchModel class

PyTorchModelR Documentation

PyTorchModel class

Description

An PyTorch SageMaker “Model“ that can be deployed to a SageMaker “Endpoint“.

Super classes

sagemaker.mlcore::ModelBase -> sagemaker.mlcore::Model -> sagemaker.mlcore::FrameworkModel -> PyTorchModel

Public fields

.LOWEST_MMS_VERSION

Lowest Multi Model Server PyTorch version that can be executed

Methods

Public methods

Inherited methods

Method new()

Initialize a PyTorchModel.

Usage
PyTorchModel$new(
  model_data,
  role,
  entry_point,
  framework_version = NULL,
  py_version = NULL,
  image_uri = NULL,
  predictor_cls = PyTorchPredictor,
  model_server_workers = NULL,
  ...
)
Arguments
model_data

(str): The S3 location of a SageMaker model data “.tar.gz“ file.

role

(str): An AWS IAM role (either name or full ARN). The Amazon SageMaker training jobs and APIs that create Amazon SageMaker endpoints use this role to access training data and model artifacts. After the endpoint is created, the inference code might use the IAM role, if it needs to access an AWS resource.

entry_point

(str): Path (absolute or relative) to the Python source file which should be executed as the entry point to model hosting. If “source_dir“ is specified, then “entry_point“ must point to a file located at the root of “source_dir“.

framework_version

(str): PyTorch version you want to use for executing your model training code. Defaults to None. Required unless “image_uri“ is provided.

py_version

(str): Python version you want to use for executing your model training code. Defaults to “None“. Required unless “image_uri“ is provided.

image_uri

(str): A Docker image URI (default: None). If not specified, a default image for PyTorch will be used. If “framework_version“ or “py_version“ are “None“, then “image_uri“ is required. If also “None“, then a “ValueError“ will be raised.

predictor_cls

(callable[str, sagemaker.session.Session]): A function to call to create a predictor with an endpoint name and SageMaker “Session“. If specified, “deploy()“ returns the result of invoking this function on the created endpoint name.

model_server_workers

(int): Optional. The number of worker processes used by the inference server. If None, server will use one worker per vCPU.

...

: Keyword arguments passed to the superclass :class:'~sagemaker.model.FrameworkModel' and, subsequently, its superclass :class:'~sagemaker.model.Model'.


Method register()

Creates a model package for creating SageMaker models or listing on Marketplace.

Usage
PyTorchModel$register(
  content_types,
  response_types,
  inference_instances,
  transform_instances,
  model_package_name = NULL,
  model_package_group_name = NULL,
  image_uri = NULL,
  model_metrics = NULL,
  metadata_properties = NULL,
  marketplace_cert = FALSE,
  approval_status = NULL,
  description = NULL,
  drift_check_baselines = NULL
)
Arguments
content_types

(list): The supported MIME types for the input data.

response_types

(list): The supported MIME types for the output data.

inference_instances

(list): A list of the instance types that are used to generate inferences in real-time.

transform_instances

(list): A list of the instance types on which a transformation job can be run or on which an endpoint can be deployed.

model_package_name

(str): Model Package name, exclusive to 'model_package_group_name', using 'model_package_name' makes the Model Package un-versioned (default: None).

model_package_group_name

(str): Model Package Group name, exclusive to 'model_package_name', using 'model_package_group_name' makes the Model Package versioned (default: None).

image_uri

(str): Inference image uri for the container. Model class' self.image will be used if it is None (default: None).

model_metrics

(ModelMetrics): ModelMetrics object (default: None).

metadata_properties

(MetadataProperties): MetadataProperties object (default: None).

marketplace_cert

(bool): A boolean value indicating if the Model Package is certified for AWS Marketplace (default: False).

approval_status

(str): Model Approval Status, values can be "Approved", "Rejected", or "PendingManualApproval" (default: "PendingManualApproval").

description

(str): Model Package description (default: None).

drift_check_baselines

(DriftCheckBaselines): DriftCheckBaselines object (default: None).

Returns

A 'sagemaker.model.ModelPackage' instance.


Method prepare_container_def()

Return a container definition with framework configuration set in model environment variables.

Usage
PyTorchModel$prepare_container_def(
  instance_type = NULL,
  accelerator_type = NULL
)
Arguments
instance_type

(str): The EC2 instance type to deploy this Model to. For example, 'ml.p2.xlarge'.

accelerator_type

(str): The Elastic Inference accelerator type to deploy to the instance for loading and making inferences to the model.

Returns

dict[str, str]: A container definition object usable with the CreateModel API.


Method serving_image_uri()

Create a URI for the serving image.

Usage
PyTorchModel$serving_image_uri(
  region_name,
  instance_type,
  accelerator_type = NULL
)
Arguments
region_name

(str): AWS region where the image is uploaded.

instance_type

(str): SageMaker instance type. Used to determine device type (cpu/gpu/family-specific optimized).

accelerator_type

(str): The Elastic Inference accelerator type to deploy to the instance for loading and making inferences to the model.

Returns

str: The appropriate image URI based on the given parameters


Method clone()

The objects of this class are cloneable with this method.

Usage
PyTorchModel$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.


DyfanJones/sagemaker-r-mlframework documentation built on March 18, 2022, 7:41 a.m.