class_docstr: Handle end-to-end training and deployment of custom MXNet code.
class_docstr_tok: ["Handle","end-to-end","training","and","deployment","of","custom","MXNet","code","."]
docstr: This ``Estimator`` executes an MXNet script in a managed MXNet execution environment.
  
  The managed MXNet environment is an Amazon-built Docker container that executes
  functions defined in the supplied ``entry_point`` Python script.
  
  Training is started by calling
  :meth:`~sagemaker.amazon.estimator.Framework.fit` on this Estimator.
  After training is complete, calling
  :meth:`~sagemaker.amazon.estimator.Framework.deploy` creates a hosted
  SageMaker endpoint and returns an
  :class:`~sagemaker.amazon.mxnet.model.MXNetPredictor` instance that can
  be used to perform inference against the hosted model.
  
  Technical documentation on preparing MXNet scripts for SageMaker
  training and using the MXNet Estimator is available on the project
  home-page: https://github.com/aws/sagemaker-python-sdk
  
  Args:
      entry_point (str or PipelineVariable): Path (absolute or relative) to the
          Python source file which should be executed as the entry point to training.
          If ``source_dir`` is specified, then ``entry_point``
          must point to a file located at the root of ``source_dir``.
      framework_version (str): MXNet version you want to use for executing
          your model training code. Defaults to `None`. Required unless
          ``image_uri`` is provided. List of supported versions.
          https://aws.amazon.com/releasenotes/available-deep-learning-containers-images/.
      py_version (str): Python version you want to use for executing your
          model training code. One of 'py2' or 'py3'. Defaults to ``None``. Required
          unless ``image_uri`` is provided.
      source_dir (str or PipelineVariable): Path (absolute, relative or an S3 URI) to
          a directory with any other training source code dependencies aside from the entry
          point file (default: None). If ``source_dir`` is an S3 URI, it must
          point to a tar.gz file. Structure within this directory are preserved
          when training on Amazon SageMaker.
      hyperparameters (dict[str, str] or dict[str, PipelineVariable]): Hyperparameters
          that will be used for training (default: None). The hyperparameters are made
          accessible as a dict[str, str] to the training code on
          SageMaker. For convenience, this accepts other types for keys
          and values, but ``str()`` will be called to convert them before
          training.
      image_uri (str or PipelineVariable): If specified, the estimator will use this image
          for training and hosting, instead of selecting the appropriate SageMaker official
          image based on framework_version and py_version. It can be an ECR url or dockerhub
          image and tag.
  
          Examples:
              * ``123412341234.dkr.ecr.us-west-2.amazonaws.com/my-custom-image:1.0``
              * ``custom-image:latest``
  
          If ``framework_version`` or ``py_version`` are ``None``, then
          ``image_uri`` is required. If also ``None``, then a ``ValueError``
          will be raised.
      distribution (dict): A dictionary with information on how to run distributed
          training (default: None). Currently we support distributed training with
          parameter server and MPI [Horovod].
          To enable parameter server use the following setup:
  
          .. code:: python
  
              {
                  'parameter_server':
                  {
                      'enabled': True
                  }
              }
  
          To enable MPI:
  
          .. code:: python
  
              {
                  'mpi':
                  {
                      'enabled': True
                  }
              }
  
          Option parameters within ``mpi`` are ``processes_per_host``
          and ``custom_mpi_options``.
  
          .. code:: python
  
              {
                  'mpi':
                  {
                      'enabled': True,
                      'processes_per_host': 2,
                      'custom_mpi_options': '-verbose --NCCL_DEBUG=INFO'
                  }
              }
  
      **kwargs: Additional kwargs passed to the
          :class:`~sagemaker.estimator.Framework` constructor.
  
  .. tip::
  
      You can find additional parameters for initializing this class at
      :class:`~sagemaker.estimator.Framework` and
      :class:`~sagemaker.estimator.EstimatorBase`.
docstr_tok: ["This","``","Estimator","``","executes","an","MXNet","script","in","a","managed","MXNet","execution","environment",".","The","managed","MXNet","environment","is","an","Amazon-built","Docker","container","that","executes","functions","defined","in","the","supplied","``","entry_point","``","Python","script",".","Training","is","started","by","calling",":","meth",":","`","~sagemaker.amazon.estimator.Framework.fit","`","on","this","Estimator",".","After","training","is","complete",",","calling",":","meth",":","`","~sagemaker.amazon.estimator.Framework.deploy","`","creates","a","hosted","SageMaker","endpoint","and","returns","an",":","class",":","`","~sagemaker.amazon.mxnet.model.MXNetPredictor","`","instance","that","can","be","used","to","perform","inference","against","the","hosted","model",".","Technical","documentation","on","preparing","MXNet","scripts","for","SageMaker","training","and","using","the","MXNet","Estimator","is","available","on","the","project","home-page",":","https",":","\/\/github.com\/aws\/sagemaker-python-sdk","Args",":","entry_point","(","str","or","PipelineVariable",")",":","Path","(","absolute","or","relative",")","to","the","Python","source","file","which","should","be","executed","as","the","entry","point","to","training",".","If","``","source_dir","``","is","specified",",","then","``","entry_point","``","must","point","to","a","file","located","at","the","root","of","``","source_dir","``",".","framework_version","(","str",")",":","MXNet","version","you","want","to","use","for","executing","your","model","training","code",".","Defaults","to","`","None","`",".","Required","unless","``","image_uri","``","is","provided",".","List","of","supported","versions",".","https",":","\/\/aws.amazon.com\/releasenotes\/available-deep-learning-containers-images\/",".","py_version","(","str",")",":","Python","version","you","want","to","use","for","executing","your","model","training","code",".","One","of","'py2","'","or","'py3","'",".","Defaults","to","``","None","``",".","Required","unless","``","image_uri","``","is","provided",".","source_dir","(","str","or","PipelineVariable",")",":","Path","(","absolute",",","relative","or","an","S3","URI",")","to","a","directory","with","any","other","training","source","code","dependencies","aside","from","the","entry","point","file","(","default",":","None",")",".","If","``","source_dir","``","is","an","S3","URI",",","it","must","point","to","a","tar.gz","file",".","Structure","within","this","directory","are","preserved","when","training","on","Amazon","SageMaker",".","hyperparameters","(","dict","[","str",",","str","]","or","dict","[","str",",","PipelineVariable","]",")",":","Hyperparameters","that","will","be","used","for","training","(","default",":","None",")",".","The","hyperparameters","are","made","accessible","as","a","dict","[","str",",","str","]","to","the","training","code","on","SageMaker",".","For","convenience",",","this","accepts","other","types","for","keys","and","values",",","but","``","str","(",")","``","will","be","called","to","convert","them","before","training",".","image_uri","(","str","or","PipelineVariable",")",":","If","specified",",","the","estimator","will","use","this","image","for","training","and","hosting",",","instead","of","selecting","the","appropriate","SageMaker","official","image","based","on","framework_version","and","py_version",".","It","can","be","an","ECR","url","or","dockerhub","image","and","tag",".","Examples",":","*","``","123412341234.dkr.ecr.us-west-2.amazonaws.com\/my-custom-image:1.0","``","*","``","custom-image",":","latest","``","If","``","framework_version","``","or","``","py_version","``","are","``","None","``",",","then","``","image_uri","``","is","required",".","If","also","``","None","``",",","then","a","``","ValueError","``","will","be","raised",".","distribution","(","dict",")",":","A","dictionary","with","information","on","how","to","run","distributed","training","(","default",":","None",")",".","Currently","we","support","distributed","training","with","parameter","server","and","MPI","[","Horovod","]",".","To","enable","parameter","server","use","the","following","setup",":","..","code",":",":","python","{","'parameter_server","'",":","{","'enabled","'",":","True","}","}","To","enable","MPI",":","..","code",":",":","python","{","'mpi","'",":","{","'enabled","'",":","True","}","}","Option","parameters","within","``","mpi","``","are","``","processes_per_host","``","and","``","custom_mpi_options","``",".","..","code",":",":","python","{","'mpi","'",":","{","'enabled","'",":","True",",","'processes_per_host","'",":","2",",","'custom_mpi_options","'",":","'-verbose","--","NCCL_DEBUG=INFO'","}","}","*","*","kwargs",":","Additional","kwargs","passed","to","the",":","class",":","`","~sagemaker.estimator.Framework","`","constructor",".","..","tip",":",":","You","can","find","additional","parameters","for","initializing","this","class","at",":","class",":","`","~sagemaker.estimator.Framework","`","and",":","class",":","`","~sagemaker.estimator.EstimatorBase","`","."]
code: def __init__(
      self,
      entry_point: Union[str, PipelineVariable],
      framework_version: Optional[str] = None,
      py_version: Optional[str] = None,
      source_dir: Optional[Union[str, PipelineVariable]] = None,
      hyperparameters: Optional[
          Dict[str, Union[str, PipelineVariable]]
      ] = None,
      image_uri: Optional[Union[str, PipelineVariable]] = None,
      distribution: Optional[Dict[str, str]] = None,
      **kwargs,
  ):
      """This ``Estimator`` executes an MXNet script in a managed MXNet execution environment.
  
      The managed MXNet environment is an Amazon-built Docker container that executes
      functions defined in the supplied ``entry_point`` Python script.
  
      Training is started by calling
      :meth:`~sagemaker.amazon.estimator.Framework.fit` on this Estimator.
      After training is complete, calling
      :meth:`~sagemaker.amazon.estimator.Framework.deploy` creates a hosted
      SageMaker endpoint and returns an
      :class:`~sagemaker.amazon.mxnet.model.MXNetPredictor` instance that can
      be used to perform inference against the hosted model.
  
      Technical documentation on preparing MXNet scripts for SageMaker
      training and using the MXNet Estimator is available on the project
      home-page: https://github.com/aws/sagemaker-python-sdk
  
      Args:
          entry_point (str or PipelineVariable): Path (absolute or relative) to the
              Python source file which should be executed as the entry point to training.
              If ``source_dir`` is specified, then ``entry_point``
              must point to a file located at the root of ``source_dir``.
          framework_version (str): MXNet version you want to use for executing
              your model training code. Defaults to `None`. Required unless
              ``image_uri`` is provided. List of supported versions.
              https://aws.amazon.com/releasenotes/available-deep-learning-containers-images/.
          py_version (str): Python version you want to use for executing your
              model training code. One of 'py2' or 'py3'. Defaults to ``None``. Required
              unless ``image_uri`` is provided.
          source_dir (str or PipelineVariable): Path (absolute, relative or an S3 URI) to
              a directory with any other training source code dependencies aside from the entry
              point file (default: None). If ``source_dir`` is an S3 URI, it must
              point to a tar.gz file. Structure within this directory are preserved
              when training on Amazon SageMaker.
          hyperparameters (dict[str, str] or dict[str, PipelineVariable]): Hyperparameters
              that will be used for training (default: None). The hyperparameters are made
              accessible as a dict[str, str] to the training code on
              SageMaker. For convenience, this accepts other types for keys
              and values, but ``str()`` will be called to convert them before
              training.
          image_uri (str or PipelineVariable): If specified, the estimator will use this image
              for training and hosting, instead of selecting the appropriate SageMaker official
              image based on framework_version and py_version. It can be an ECR url or dockerhub
              image and tag.
  
              Examples:
                  * ``123412341234.dkr.ecr.us-west-2.amazonaws.com/my-custom-image:1.0``
                  * ``custom-image:latest``
  
              If ``framework_version`` or ``py_version`` are ``None``, then
              ``image_uri`` is required. If also ``None``, then a ``ValueError``
              will be raised.
          distribution (dict): A dictionary with information on how to run distributed
              training (default: None). Currently we support distributed training with
              parameter server and MPI [Horovod].
              To enable parameter server use the following setup:
  
              .. code:: python
  
                  {
                      'parameter_server':
                      {
                          'enabled': True
                      }
                  }
  
              To enable MPI:
  
              .. code:: python
  
                  {
                      'mpi':
                      {
                          'enabled': True
                      }
                  }
  
              Option parameters within ``mpi`` are ``processes_per_host``
              and ``custom_mpi_options``.
  
              .. code:: python
  
                  {
                      'mpi':
                      {
                          'enabled': True,
                          'processes_per_host': 2,
                          'custom_mpi_options': '-verbose --NCCL_DEBUG=INFO'
                      }
                  }
  
          **kwargs: Additional kwargs passed to the
              :class:`~sagemaker.estimator.Framework` constructor.
  
      .. tip::
  
          You can find additional parameters for initializing this class at
          :class:`~sagemaker.estimator.Framework` and
          :class:`~sagemaker.estimator.EstimatorBase`.
      """
      distribution = renamed_kwargs(
          "distributions", "distribution", distribution, kwargs
      )
      instance_type = renamed_kwargs(
          "train_instance_type",
          "instance_type",
          kwargs.get("instance_type"),
          kwargs,
      )
      validate_version_or_image_args(
          framework_version, py_version, image_uri
      )
      if py_version == "py2":
          logger.warning(
              python_deprecation_warning(
                  self._framework_name, defaults.LATEST_PY2_VERSION
              )
          )
      self.framework_version = framework_version
      self.py_version = py_version
  
      if "enable_sagemaker_metrics" not in kwargs:
          # enable sagemaker metrics for MXNet v1.6 or greater:
          if self.framework_version and Version(
              self.framework_version
          ) >= Version("1.6"):
              kwargs["enable_sagemaker_metrics"] = True
  
      super(MXNet, self).__init__(
          entry_point,
          source_dir,
          hyperparameters,
          image_uri=image_uri,
          **kwargs,
      )
  
      if distribution is not None:
          warn_if_parameter_server_with_multi_gpu(
              training_instance_type=instance_type,
              distribution=distribution,
          )
  
      self._configure_distribution(distribution)
  
file_path: sagemaker-python-sdk/src/sagemaker/mxnet/estimator.py
imports: from __future__ import absolute_import
  import logging
  from typing import Union, Optional, Dict
  from packaging.version import Version
  from sagemaker.deprecations import renamed_kwargs
  from sagemaker.estimator import Framework
  from sagemaker.fw_utils import framework_name_from_image, framework_version_from_tag, python_deprecation_warning, validate_version_or_image_args, warn_if_parameter_server_with_multi_gpu
  from sagemaker.mxnet import defaults
  from sagemaker.mxnet.model import MXNetModel
  from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
  from sagemaker.workflow.entities import PipelineVariable
label_desc: Use image node_id 1 to create a new MXNet object from inherited base classes: Framework with example: obj = MXNet(entry_point, framework_version, py_version, source_dir, hyperparameters, image_uri, distribution)