create_training_job
¶
create_training_job(
*,
config_overrides: Optional[SageMakerClientConfig] = None,
training_job_name: Optional[TrainingJobName] = None,
hyper_parameters: Optional[HyperParameters] = None,
algorithm_specification: Optional[AlgorithmSpecification] = None,
role_arn: Optional[RoleArn] = None,
input_data_config: Optional[InputDataConfig] = None,
output_data_config: Optional[OutputDataConfig] = None,
resource_config: Optional[ResourceConfig] = None,
vpc_config: Optional[VpcConfig] = None,
stopping_condition: Optional[StoppingCondition] = None,
tags: Optional[TagList] = None,
enable_network_isolation: Optional[Boolean] = None,
enable_inter_container_traffic_encryption: Optional[Boolean] = None,
enable_managed_spot_training: Optional[Boolean] = None,
checkpoint_config: Optional[CheckpointConfig] = None,
debug_hook_config: Optional[DebugHookConfig] = None,
debug_rule_configurations: Optional[DebugRuleConfigurations] = None,
tensor_board_output_config: Optional[TensorBoardOutputConfig] = None,
experiment_config: Optional[ExperimentConfig] = None,
profiler_config: Optional[ProfilerConfig] = None,
profiler_rule_configurations: Optional[ProfilerRuleConfigurations] = None,
environment: Optional[TrainingEnvironmentMap] = None,
retry_strategy: Optional[RetryStrategy] = None,
remote_debug_config: Optional[RemoteDebugConfig] = None,
infra_check_config: Optional[InfraCheckConfig] = None,
session_chaining_config: Optional[SessionChainingConfig] = None,
serverless_job_config: Optional[ServerlessJobConfig] = None,
mlflow_config: Optional[MlflowConfig] = None,
model_package_config: Optional[ModelPackageConfig] = None,
) -> CreateTrainingJobResponse
Starts a model training job. After training completes, SageMaker saves the resulting model artifacts to an Amazon S3 location that you specify.
If you choose to host your model using SageMaker hosting services, you can use the resulting model artifacts as part of the model. You can also use the artifacts in a machine learning service other than SageMaker, provided that you know how to use them for inference.
In the request body, you provide the following:
-
AlgorithmSpecification- Identifies the training algorithm to use. -
HyperParameters- Specify these algorithm-specific parameters to enable the estimation of model parameters during training. Hyperparameters can be tuned to optimize this learning process. For a list of hyperparameters for each training algorithm provided by SageMaker, see Algorithms.Do not include any security-sensitive information including account access IDs, secrets, or tokens in any hyperparameter fields. As part of the shared responsibility model, you are responsible for any potential exposure, unauthorized access, or compromise of your sensitive data if caused by security-sensitive information included in the request hyperparameter variable or plain text fields.
-
InputDataConfig- Describes the input required by the training job and the Amazon S3, EFS, or FSx location where it is stored. -
OutputDataConfig- Identifies the Amazon S3 bucket where you want SageMaker to save the results of model training. -
ResourceConfig- Identifies the resources, ML compute instances, and ML storage volumes to deploy for model training. In distributed training, you specify more than one instance. -
EnableManagedSpotTraining- Optimize the cost of training machine learning models by up to 80% by using Amazon EC2 Spot instances. For more information, see Managed Spot Training. -
RoleArn- The Amazon Resource Name (ARN) that SageMaker assumes to perform tasks on your behalf during model training. You must grant this role the necessary permissions so that SageMaker can successfully complete model training. -
StoppingCondition- To help cap training costs, useMaxRuntimeInSecondsto set a time limit for training. UseMaxWaitTimeInSecondsto specify how long a managed spot training job has to complete. -
Environment- The environment variables to set in the Docker container.Do not include any security-sensitive information including account access IDs, secrets, or tokens in any environment fields. As part of the shared responsibility model, you are responsible for any potential exposure, unauthorized access, or compromise of your sensitive data if caused by security-sensitive information included in the request environment variable or plain text fields.
-
RetryStrategy- The number of times to retry the job when the job fails due to anInternalServerError.
For more information about SageMaker, see How It Works.
Parameters:
-
training_job_name(Optional[TrainingJobName], default:None) –The name of the training job. The name must be unique within an Amazon Web Services Region in an Amazon Web Services account.
-
hyper_parameters(Optional[HyperParameters], default:None) –Algorithm-specific parameters that influence the quality of the model. You set hyperparameters before you start the learning process. For a list of hyperparameters for each training algorithm provided by SageMaker, see Algorithms.
You can specify a maximum of 100 hyperparameters. Each hyperparameter is a key-value pair. Each key and value is limited to 256 characters, as specified by the
Length Constraint.Do not include any security-sensitive information including account access IDs, secrets, or tokens in any hyperparameter fields. As part of the shared responsibility model, you are responsible for any potential exposure, unauthorized access, or compromise of your sensitive data if caused by any security-sensitive information included in the request hyperparameter variable or plain text fields.
-
algorithm_specification(Optional[AlgorithmSpecification], default:None) –The registry path of the Docker image that contains the training algorithm and algorithm-specific metadata, including the input mode. For more information about algorithms provided by SageMaker, see Algorithms. For information about providing your own algorithms, see Using Your Own Algorithms with Amazon SageMaker.
-
role_arn(Optional[RoleArn], default:None) –The Amazon Resource Name (ARN) of an IAM role that SageMaker can assume to perform tasks on your behalf.
During model training, SageMaker needs your permission to read input data from an S3 bucket, download a Docker image that contains training code, write model artifacts to an S3 bucket, write logs to Amazon CloudWatch Logs, and publish metrics to Amazon CloudWatch. You grant permissions for all of these tasks to an IAM role. For more information, see SageMaker Roles.
To be able to pass this role to SageMaker, the caller of this API must have the
iam:PassRolepermission. -
input_data_config(Optional[InputDataConfig], default:None) –An array of
Channelobjects. Each channel is a named input source.InputDataConfigdescribes the input data and its location.Algorithms can accept input data from one or more channels. For example, an algorithm might have two channels of input data,
training_dataandvalidation_data. The configuration for each channel provides the S3, EFS, or FSx location where the input data is stored. It also provides information about the stored data: the MIME type, compression method, and whether the data is wrapped in RecordIO format.Depending on the input mode that the algorithm supports, SageMaker either copies input data files from an S3 bucket to a local directory in the Docker container, or makes it available as input streams. For example, if you specify an EFS location, input data files are available as input streams. They do not need to be downloaded.
Your input must be in the same Amazon Web Services region as your training job.
-
output_data_config(Optional[OutputDataConfig], default:None) –Specifies the path to the S3 location where you want to store model artifacts. SageMaker creates subfolders for the artifacts.
-
resource_config(Optional[ResourceConfig], default:None) –The resources, including the ML compute instances and ML storage volumes, to use for model training.
ML storage volumes store model artifacts and incremental states. Training algorithms might also use ML storage volumes for scratch space. If you want SageMaker to use the ML storage volume to store the training data, choose
Fileas theTrainingInputModein the algorithm specification. For distributed training algorithms, specify an instance count greater than 1. -
vpc_config(Optional[VpcConfig], default:None) –A VpcConfig object that specifies the VPC that you want your training job to connect to. Control access to and from your training container by configuring the VPC. For more information, see Protect Training Jobs by Using an Amazon Virtual Private Cloud.
-
stopping_condition(Optional[StoppingCondition], default:None) –Specifies a limit to how long a model training job can run. It also specifies how long a managed Spot training job has to complete. When the job reaches the time limit, SageMaker ends the training job. Use this API to cap model training costs.
To stop a job, SageMaker sends the algorithm the
SIGTERMsignal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts, so the results of training are not lost. -
tags(Optional[TagList], default:None) –An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different ways, for example, by purpose, owner, or environment. For more information, see Tagging Amazon Web Services Resources.
Do not include any security-sensitive information including account access IDs, secrets, or tokens in any tags. As part of the shared responsibility model, you are responsible for any potential exposure, unauthorized access, or compromise of your sensitive data if caused by any security-sensitive information included in the request tag variable or plain text fields.
-
enable_network_isolation(Optional[Boolean], default:None) –Isolates the training container. No inbound or outbound network calls can be made, except for calls between peers within a training cluster for distributed training. If you enable network isolation for training jobs that are configured to use a VPC, SageMaker downloads and uploads customer data and model artifacts through the specified VPC, but the training container does not have network access.
-
enable_inter_container_traffic_encryption(Optional[Boolean], default:None) –To encrypt all communications between ML compute instances in distributed training, choose
True. Encryption provides greater security for distributed training, but training might take longer. How long it takes depends on the amount of communication between compute instances, especially if you use a deep learning algorithm in distributed training. For more information, see Protect Communications Between ML Compute Instances in a Distributed Training Job. -
enable_managed_spot_training(Optional[Boolean], default:None) –To train models using managed spot training, choose
True. Managed spot training provides a fully managed and scalable infrastructure for training machine learning models. this option is useful when training jobs can be interrupted and when there is flexibility when the training job is run.The complete and intermediate results of jobs are stored in an Amazon S3 bucket, and can be used as a starting point to train models incrementally. Amazon SageMaker provides metrics and logs in CloudWatch. They can be used to see when managed spot training jobs are running, interrupted, resumed, or completed.
-
checkpoint_config(Optional[CheckpointConfig], default:None) –Contains information about the output location for managed spot training checkpoint data.
-
debug_rule_configurations(Optional[DebugRuleConfigurations], default:None) –Configuration information for Amazon SageMaker Debugger rules for debugging output tensors.
-
profiler_rule_configurations(Optional[ProfilerRuleConfigurations], default:None) –Configuration information for Amazon SageMaker Debugger rules for profiling system and framework metrics.
-
environment(Optional[TrainingEnvironmentMap], default:None) –The environment variables to set in the Docker container.
Do not include any security-sensitive information including account access IDs, secrets, or tokens in any environment fields. As part of the shared responsibility model, you are responsible for any potential exposure, unauthorized access, or compromise of your sensitive data if caused by security-sensitive information included in the request environment variable or plain text fields.
-
retry_strategy(Optional[RetryStrategy], default:None) –The number of times to retry the job when the job fails due to an
InternalServerError. -
remote_debug_config(Optional[RemoteDebugConfig], default:None) –Configuration for remote debugging. To learn more about the remote debugging functionality of SageMaker, see Access a training container through Amazon Web Services Systems Manager (SSM) for remote debugging.
-
infra_check_config(Optional[InfraCheckConfig], default:None) –Contains information about the infrastructure health check configuration for the training job.
-
session_chaining_config(Optional[SessionChainingConfig], default:None) –Contains information about attribute-based access control (ABAC) for the training job.
-
serverless_job_config(Optional[ServerlessJobConfig], default:None) –The configuration for serverless training jobs.
-
mlflow_config(Optional[MlflowConfig], default:None) –The MLflow configuration using SageMaker managed MLflow.
-
model_package_config(Optional[ModelPackageConfig], default:None) –The configuration for the model package.
Raises:
-
ResourceInUse–Resource being accessed is in use.
-
ResourceLimitExceeded–You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created.
-
ResourceNotFound–Resource being access is not found.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_sagemaker/_services/sage_maker.py
7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 | |