InferenceConfig class

Definition

InferenceConfig(entry_script, runtime=None, conda_file=None, extra_docker_file_steps=None, source_directory=None, enable_gpu=None, description=None, base_image=None, base_image_registry=None, cuda_version=None, environment=None)
Inheritance
builtins.object
InferenceConfig

Parameters

entry_script
str

The path to a local file that contains the code to run for the image.

runtime
str

The runtime to use for the image. Current supported runtimes are 'spark-py' and 'python'.

conda_file
str

The path to a local file containing a conda environment definition to use for the image.

extra_docker_file_steps
str

The path to a local file containing additional Docker steps to run when setting up the image.

source_directory
str

The path to the folder that contains all files to create the image.

enable_gpu
bool

Indicates whether to enable GPU support in the image. The GPU image must be used on Microsoft Azure Services such as Azure Container Instances, Azure Machine Learning Compute, Azure Virtual Machines, and Azure Kubernetes Service.

description
str

A description to give this image.

base_image
str

A custom image to be used as base image. If no base image is given then the base image will be used based off of given runtime parameter.

base_image_registry
ContainerRegistry

The image registry that contains the base image.

cuda_version
str

The version of CUDA to install for images that need GPU support. The GPU image must be used on Microsoft Azure Services such as Azure Container Instances, Azure Machine Learning Compute, Azure Virtual Machines, and Azure Kubernetes Service. Supported versions are 9.0, 9.1, and 10.0. If enable_gpu is set, this defaults to '9.1'.

environment
Environment

An environment object to use for the deployment. The environment doesn't have to be registered.

Provide either this parameter, or the other parameters, but not both. The individual parameters will NOT serve as an override for the environment object. Exceptions include entry_script, source_directory, and description.

Remarks

The following sample shows how to create an InferenceConfig object and use it to deploy a model.


   from azureml.core import Webservice
   from azureml.core.model import InferenceConfig
   from azureml.exceptions import WebserviceException

   service_name = 'my-custom-env-service'

   # Remove any existing service under the same name.
   try:
       Webservice(ws, service_name).delete()
   except WebserviceException:
       pass

   inference_config = InferenceConfig(entry_script='score.py',
                                      source_directory='.',
                                      environment=environment)

   service = Model.deploy(ws, service_name, [model], inference_config)
   service.wait_for_deployment(show_output=True)

Full sample is available from https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/deployment/deploy-to-cloud/model-register-and-deploy.ipynb

Methods

build_create_payload(workspace, name, model_ids)

Build the creation payload for the Container image.

build_profile_payload(profile_name, input_data)

Build the profiling payload for the Model package.

validate_configuration()

Check that the specified configuration values are valid.

Raises a WebserviceException if validation fails.

build_create_payload(workspace, name, model_ids)

Build the creation payload for the Container image.

build_create_payload(workspace, name, model_ids)

Parameters

workspace
Workspace

The workspace object to create the image in.

name
str

The name of the image.

model_ids
list[str]

A list of model IDs to package into the image.

Returns

The container image creation payload.

Return type

Exceptions

build_profile_payload(profile_name, input_data)

Build the profiling payload for the Model package.

build_profile_payload(profile_name, input_data)

Parameters

profile_name
str

The name of the profile.

input_data
str

The input data for profiling.

Returns

The Model profile payload.

Return type

Exceptions

validate_configuration()

Check that the specified configuration values are valid.

Raises a WebserviceException if validation fails.

validate_configuration()

Exceptions