create_training_job
async
¶
create_training_job(
*,
config_overrides: Optional[AsyncSageMakerClientConfig] = 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/async_sage_maker.py
8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 | |