sagemaker.core.image_uris#

Functions for generating ECR image URIs for pre-built SageMaker Docker images.

Functions

config_for_framework(framework)

Loads the JSON config for the given framework.

get_base_python_image_uri(region[, py_version])

Retrieves the image URI for base python image.

get_training_image_uri(region, framework[, ...])

Retrieves the image URI for training.

list_frameworks()

Lists the frameworks that have a bundled image URI config.

list_py_versions(framework, version[, ...])

Lists the available Python versions for a framework version.

list_versions(framework[, image_scope])

Lists the available versions for a framework.

retrieve(framework, region[, version, ...])

Retrieves the ECR URI for the Docker image matching the given arguments.

sagemaker.core.image_uris.config_for_framework(framework)[source]#

Loads the JSON config for the given framework.

sagemaker.core.image_uris.get_base_python_image_uri(region, py_version='310') → str[source]#

Retrieves the image URI for base python image.

Parameters:
  • region (str) – The AWS region to use for image URI.

  • py_version (str) – The python version to use for the image. Can be 310 or 38

  • 310 (Default to)

Returns:

The image URI string.

Return type:

str

sagemaker.core.image_uris.get_training_image_uri(region, framework, framework_version=None, py_version=None, image_uri=None, distribution=None, compiler_config=None, tensorflow_version=None, pytorch_version=None, instance_type=None) → str[source]#

Retrieves the image URI for training.

Parameters:
  • region (str) – The AWS region to use for image URI.

  • framework (str) – The framework for which to retrieve an image URI.

  • framework_version (str) – The framework version for which to retrieve an image URI (default: None).

  • py_version (str) – The python version to use for the image (default: None).

  • image_uri (str) – If an image URI is supplied, it is returned (default: None).

  • distribution (dict) – A dictionary with information on how to run distributed training (default: None).

  • compiler_config (TrainingCompilerConfig) – A configuration class for the SageMaker Training Compiler (default: None).

  • tensorflow_version (str) – The version of TensorFlow to use. (default: None)

  • pytorch_version (str) – The version of PyTorch to use. (default: None)

  • instance_type (str) – The instance type to use. (default: None)

Returns:

The image URI string.

Return type:

str

sagemaker.core.image_uris.list_frameworks() → List[str][source]#

Lists the frameworks that have a bundled image URI config.

Returns:

Sorted framework names accepted by retrieve() and list_versions(). Non-framework config files are excluded.

Return type:

list[str]

sagemaker.core.image_uris.list_py_versions(framework: str, version: str, image_scope: str | None = None) → List[str][source]#

Lists the available Python versions for a framework version.

A version alias (e.g. "2.0") is resolved to its concrete target before lookup, matching retrieve().

Parameters:
  • framework (str) – The framework name (see list_frameworks()).

  • version (str) – The framework version or alias (see list_versions()).

  • image_scope (str) – Optional image scope (e.g. "training" or "inference"). Only applies to scope-nested configs; when omitted, Python versions are unioned across all scopes that define the given version. (default: None).

Returns:

Sorted, de-duplicated Python versions (e.g. ["py310"]). Empty if the version defines no Python versions – either because the image has none (e.g. algorithm images) or because the framework nests Python versions under a base-framework version (e.g. huggingface), which this helper does not descend into.

Return type:

list[str]

Raises:

ValueError – If the framework, image_scope, or version is unknown.

sagemaker.core.image_uris.list_versions(framework: str, image_scope: str | None = None) → List[str][source]#

Lists the available versions for a framework.

Both concrete versions and version aliases (e.g. "2.0" -> "2.0.1") are returned, since retrieve() accepts either as its version argument.

Parameters:
  • framework (str) – The framework name (see list_frameworks()).

  • image_scope (str) – Optional image scope (e.g. "training" or "inference"). For scope-nested configs, versions are unioned across all scopes when omitted; for single-map configs it is validated (when the config declares a scope list) but does not change the returned versions. (default: None).

Returns:

Sorted, de-duplicated available versions and aliases.

Return type:

list[str]

Raises:

ValueError – If the framework is unknown, or image_scope is invalid.

sagemaker.core.image_uris.retrieve(framework, region, version=None, py_version=None, instance_type=None, accelerator_type=None, image_scope=None, container_version=None, distribution=None, base_framework_version=None, training_compiler_config=None, model_id=None, model_version=None, hub_arn=None, tolerate_vulnerable_model=False, tolerate_deprecated_model=False, sdk_version=None, inference_tool=None, serverless_inference_config=None, sagemaker_session=<sagemaker.core.jumpstart.constants._LazyJumpStartSagemakerSession object>, config_name=None, model_type: ~sagemaker.core.jumpstart.enums.JumpStartModelType = JumpStartModelType.OPEN_WEIGHTS) → str[source]#

Retrieves the ECR URI for the Docker image matching the given arguments.

Ideally this function should not be called directly, rather it should be called from the fit() function inside framework estimator.

Parameters:
  • framework (str) – The name of the framework or algorithm.

  • region (str) – The AWS region.

  • version (str) – The framework or algorithm version. This is required if there is more than one supported version for the given framework or algorithm.

  • py_version (str) – The Python version. This is required if there is more than one supported Python version for the given framework version.

  • instance_type (str) – The SageMaker instance type. For supported types, see https://aws.amazon.com/sagemaker/pricing. This is required if there are different images for different processor types.

  • accelerator_type (str) – Elastic Inference accelerator type. For more, see https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html.

  • image_scope (str) – The image type, i.e. what it is used for. Valid values: “training”, “inference”, “inference_graviton”, “eia”. If accelerator_type is set, image_scope is ignored.

  • container_version (str) – the version of docker image. Ideally the value of parameter should be created inside the framework. For custom use, see the list of supported container versions: aws/deep-learning-containers (default: None).

  • distribution (dict) – A dictionary with information on how to run distributed training

  • base_framework_version (str) – The base version number of PyTorch or Tensorflow. (default: None).

  • training_compiler_config (TrainingCompilerConfig) – A configuration class for the SageMaker Training Compiler (default: None).

  • model_id (str) – The JumpStart model ID for which to retrieve the image URI (default: None).

  • model_version (str) – The version of the JumpStart model for which to retrieve the image URI (default: None).

  • hub_arn (str) – The arn of the SageMaker Hub for which to retrieve model details from. (Default: None).

  • tolerate_vulnerable_model (bool) – True if vulnerable versions of model specifications should be tolerated without an exception raised. If False, raises an exception if the script used by this version of the model has dependencies with known security vulnerabilities. (Default: False).

  • tolerate_deprecated_model (bool) – True if deprecated versions of model specifications should be tolerated without an exception raised. If False, raises an exception if the version of the model is deprecated. (Default: False).

  • sdk_version (str) – the version of python-sdk that will be used in the image retrieval. (default: None).

  • inference_tool (str) – the tool that will be used to aid in the inference. Valid values: “neuron, neuronx, None” (default: None).

  • serverless_inference_config (sagemaker.serverless.ServerlessInferenceConfig) – Specifies configuration related to serverless endpoint. Instance type is not provided in serverless inference. So this is used to determine processor type.

  • sagemaker_session (sagemaker.session.Session) – A SageMaker Session object, used for SageMaker interactions. If not specified, one is created using the default AWS configuration chain. (Default: sagemaker.jumpstart.constants.DEFAULT_JUMPSTART_SAGEMAKER_SESSION).

  • config_name (Optional[str]) – Name of the JumpStart Model config to apply. (Default: None).

  • model_type (JumpStartModelType) – The type of the model, can be open weights model or proprietary model. (Default: JumpStartModelType.OPEN_WEIGHTS).

Returns:

The ECR URI for the corresponding SageMaker Docker image.

Return type:

str

Raises:
  • NotImplementedError – If the scope is not supported.

  • ValueError – If the combination of arguments specified is not supported or any PipelineVariable object is passed in.

  • VulnerableJumpStartModelError – If any of the dependencies required by the script have known security vulnerabilities.

  • DeprecatedJumpStartModelError – If the version of the model is deprecated.