Image#

class pai.image.ImageInfo(image_name: str, image_uri: str, framework_name: str, image_scope: str, framework_version: Optional[str] = None, accelerator_type: Optional[str] = None, python_version: Optional[str] = None)#

基类:object

This class represents information for an image provided by PAI.

参数:
  • image_name (str) -- The name of the image.

  • image_uri (str) -- The URI of the image.

  • framework_name (str) -- The name of the framework installed in the image.

  • framework_version (str, optional) -- The version of the framework (Default None).

  • image_scope (str) -- The scope of the image, could be 'training', 'inference' or 'develop'.

  • accelerator_type (str, optional) -- The type of accelerator. Defaults to None.

  • python_version (str, optional) -- The version of Python. Defaults to None.

class pai.image.ImageScope#

基类:object

Class containing constants that indicate the purpose of an image.

TRAINING = 'training'#

Indicates the image is used for submitting a training job.

INFERENCE = 'inference'#

Indicates the image is used for creating a prediction service.

DEVELOP = 'develop'#

Indicates the image is used for running in DSW.

classmethod to_image_label(scope: str)#
pai.image.retrieve(framework_name: str, framework_version: str, accelerator_type: str = 'CPU', image_scope: Optional[str] = 'training', session: Optional[Session] = None) ImageInfo#

Get a container image URI that satisfies the specified requirements.

Examples:

# get a TensorFlow image with specific version for training.
retrieve(framework_name="TensorFlow", framework_version="2.3")

# get the latest PyTorch image that supports GPU for inference.
retrieve(
    framework_name="PyTorch",
    framework_version="latest",
    accelerator_type="GPU",
    scope=ImageScope.INFERENCE,
)
参数:
  • framework_name (str) -- The name of the framework. Possible values include TensorFlow, XGBoost, PyTorch, OneFlow, and others.

  • framework_version (str) -- The version of the framework to use. Get the latest version supported in PAI by set the parameters as 'latest'.

  • image_scope (str, optional) -- The scope of the image to use. Possible values include 'training', 'inference', and 'develop'.

  • accelerator_type (str, optional) -- The name of the accelerator to use. Possible values including 'CPU', and 'GPU', (Default CPU).

  • session (pai.session.Session, optional) -- A session object to interact with the PAI Service. If not provided, a default session will be used.

返回:

A object contains information of the image that satisfy the

requirements.

返回类型:

ImageInfo

抛出:

RuntimeError -- A RuntimeErrors is raised if the specific image is not found.

pai.image.list_images(framework_name: str, session: Optional[Session] = None, image_scope: Optional[str] = 'training') List[ImageInfo]#

List available images provided by PAI.

参数:
  • framework_name (str) -- The name of the framework. Possible values include TensorFlow, XGBoost, PyTorch, OneFlow, and others.

  • image_scope (str, optional) -- The scope of the image to use. Possible values include 'training', 'inference', and 'develop'.

  • session (pai.session.Session) -- A session object used to interact with the PAI Service. If not provided, a default session is used.

返回:

A list of image URIs.

返回类型:

List[ImageInfo]