Help Center/ ModelArts/ ModelArts User Guide (Standard)/ Model Training/ Creating a Production Training Job
Updated on 2024-10-29 GMT+08:00

Creating a Production Training Job

Model training continuously iterates and optimizes model weights. ModelArts training management allows you to create training jobs, view training status, and manage training versions. Through model training, you can test various combinations of model structures, data, and hyperparameters to obtain the optimal model structure and weight.

Create a production training job in either of the following ways:

Prerequisites

  • Data for training uploaded to an OBS directory.
  • At least one empty folder in OBS for storing training output.

    An OBS bucket not encrypted.

  • Account not in arrears (paid resources required for training jobs).
  • OBS directory and ModelArts in the same region.
  • Access authorization configured. For details, see Configuring Agency Authorization for ModelArts with One Click.
  • Training algorithm. For details, see Creating an Algorithm.

Procedure

To create a training job, follow these steps:

  1. Follow the steps in Accessing the Page for Creating a Training Job.
  2. Follow the steps in Configuring Basic Information.
  3. Select an algorithm type.

  4. Configure training parameters, including the input, output, hyperparameters, and environment variables. For details, see Configuring Training Parameters.
  5. Select a resource pool as needed. A dedicated resource pool is recommended for optimal performance. For details about the differences between dedicated and public resource pools, see Differences Between Dedicated Resource Pools and Public Resource Pools.

  6. Add tags if you want to manage training jobs by group. For details, see (Optional) Adding Tags.
  7. Perform follow-up procedure. For details, see Follow-Up Operations.

Accessing the Page for Creating a Training Job

  1. Log in to the ModelArts console.
  2. In the navigation pane on the left, choose Model Training > Training Jobs.
  3. Click Create Training Job.

Configuring Basic Information

On the Create Training Job page, configure parameters.

Table 1 Basic information

Parameter

Description

Name

Job name, which is mandatory.

The system automatically generates a name, which you can then rename according to the following rules.

  • The name contains 1 to 64 characters.
  • Letters, digits, hyphens (-), and underscores (_) are allowed.

Description

Job description, which helps you learn about the job information in the training job list.

Experiment

Experiment for classifying and managing the job.

  • If you select Create new, enter the experiment name and description.
  • If you select Use existing, select an experiment name.
  • If you select Not required, this job will not be managed in any experiment.

Runtime Type

Job type, which can be Production or Debug. Choose Production to create a production job. To create a debug job, see Creating a Debug Training Job.

Choosing an Algorithm Type (My Algorithm)

Set Algorithm Type to My algorithm and select an algorithm from the algorithm list. If no algorithm meets the requirements, you can create an algorithm. For details, see Creating an Algorithm.

Choosing an Algorithm Type (Custom Algorithm)

If an algorithm is available in algorithm management, choose My algorithm. If no algorithm is available, choose Custom algorithm. If you use a custom algorithm to create a training job, select a boot mode by referring to Table 2.
Table 2 Creating a training job using a custom algorithm

Parameter

Description

Algorithm Type

Select Custom algorithm. This parameter is mandatory.

Boot Mode

Select Preset image and select the preset image engine and engine version to be used by the training job.

If you select Customize for the engine version, select a custom image from Image.

Image

This parameter is displayed and mandatory only when the preset image version is set to Customize.

You can set the container image path in either of the following ways:
  • To select your image or an image shared by others, click Select on the right and select a container image for training. The required image must be uploaded to SWR beforehand.
  • To select a public image, enter the address of the public image in SWR. Enter the image path in the format of "Organization name/Image name:Version name". Do not contain the domain name in the path because the system will automatically add the domain name to the path.

Code Source

Select a training code source.

  • OBS: Select OBS if the training code is stored in an OBS bucket.
  • SFS: Select SFS if the training code is stored in an SFS file system.

Code Directory

Select the OBS directory where the training code file is stored. This parameter is mandatory.

  • Upload code to the OBS bucket beforehand. The total size of files in the directory cannot exceed 5 GB, the number of files cannot exceed 1000, and the folder depth cannot exceed 32.
  • The training code file is automatically downloaded to the ${MA_JOB_DIR}/demo-code directory of the training container when the training job is started. demo-code is the last-level OBS directory for storing the code. For example, if Code Directory is set to /test/code, the training code file is downloaded to the ${MA_JOB_DIR}/code directory of the training container.

Boot File

Select the Python boot script of the training job in the code directory. This parameter is mandatory.

ModelArts supports only the boot file written in Python. Therefore, the boot file must end with .py.

Local Code Directory

Specify the local directory of a training container. When a training starts, the system automatically downloads the code directory to this directory.

The default local code directory is /home/ma-user/modelarts/user-job-dir. This parameter is optional.

Work Directory

During training, the system automatically runs the cd command to execute the boot file in this directory.

Choosing a Boot Mode (Custom Image)

If you use a custom image to create a training job, select a boot mode by referring to Table 3.
Table 3 Creating a training job using a custom image

Parameter

Description

Algorithm Type

Select Custom algorithm. This parameter is mandatory.

Boot Mode

Select Custom image. This parameter is mandatory.

Image

Container image path. This parameter is mandatory.

You can set the container image path in either of the following ways:
  • To select your image or an image shared by others, click Select on the right and select a container image for training. The required image must be uploaded to SWR beforehand.
  • To select a public image, enter the address of the public image in SWR. Enter the image path in the format of "Organization name/Image name:Version name". Do not contain the domain name in the path because the system will automatically add the domain name to the path.

Code Directory

OBS directory where the training code file is stored. Configure this parameter only if your custom image does not contain training code.

  • Upload code to the OBS bucket beforehand. The total size of files in the directory cannot exceed 5 GB, the number of files cannot exceed 1000, and the folder depth cannot exceed 32.
  • The training code file is automatically downloaded to the ${MA_JOB_DIR}/demo-code directory of the training container when the training job is started. demo-code is the last-level OBS directory for storing the code. For example, if Code Directory is set to /test/code, the training code file is downloaded to the ${MA_JOB_DIR}/code directory of the training container.

User ID

User ID for running the container. The default value 1000 is recommended.

If the UID needs to be specified, its value must be within the specified range. The UID ranges of different resource pools are as follows:

  • Public resource pool: 1000 to 65535
  • Dedicated resource pool: 0 to 65535

Boot Command

Command for booting an image. This parameter is mandatory.

When a training job is running, the boot command is automatically executed after the code directory is downloaded.
  • If the training boot script is a .py file, train.py for example, the boot command is as follows.
    python ${MA_JOB_DIR}/demo-code/train.py
  • If the training boot script is a .sh file, main.sh for example, the boot command is as follows:
    bash ${MA_JOB_DIR}/demo-code/main.sh

You can use semicolons (;) and ampersands (&&) to combine multiple commands. demo-code in the command is the last-level OBS directory where the code is stored. Replace it with the actual one.

NOTE:

To ensure data security, do not enter sensitive information, such as plaintext passwords.

Local Code Directory

Specify the local directory of a training container. When a training starts, the system automatically downloads the code directory to this directory.

The default local code directory is /home/ma-user/modelarts/user-job-dir. This parameter is optional.

Work Directory

During training, the system automatically runs the cd command to execute the boot file in this directory.

Configuring Training Parameters

Data is obtained from an OBS bucket or dataset for model training. The training output can also be stored in an OBS bucket. When creating a training job, you can configure parameters such as input, output, hyperparameters, and environment variables by referring to Table 4.

The input, output, and hyperparameter parameters of a training job vary depending on the algorithm type selected during training job creation. If a parameter value is dimmed, the parameter has been configured in the algorithm code and cannot be modified.

Table 4 Configuring training parameters

Parameter

Sub-Parameter

Description

Input

Parameter name

The algorithm code reads the training input data based on the input parameter name.

The recommended value is data_url. The training input parameters must match the input parameters of the selected algorithm. For details, see Table 4.

Dataset

Click Dataset and select the target dataset and its version in the ModelArts dataset list.

When the training job is started, ModelArts automatically downloads the data in the input path to the training container.

NOTE:

ModelArts data management is being upgraded and is invisible to users who have not used data management. It is recommended that new users store their training data in OBS buckets.

Data path

Click Data path and select the storage path to the training input data from an OBS bucket.

When the training job is started, ModelArts automatically downloads the data in the input path to the training container.

Obtained from

The following uses training input data_path as an example.

  • If you select Hyperparameters, use this code to obtain the data:
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--data_path')
    args, unknown = parser.parse_known_args()
    data_path = args.data_path 
  • If you select Environment variables, use this code to obtain the data:
    import os
    data_path = os.getenv("data_path", "")

Output

Parameter name

The algorithm code reads the training output data based on the output parameter name.

The recommended value is train_url. The training output parameters must match the output parameters of the selected algorithm. For details, see Table 5.

Data path

Click Data path and select the storage path to the training output data from an OBS bucket. During training, the system automatically synchronizes files from the local code directory of the training container to the data path.

NOTE:

The data path can only be an OBS path. To prevent any issues with data storage, choose an empty directory as the data path.

Obtained from

The following uses the training output train_url as an example.

  • If you select Hyperparameters, use this code to obtain the data:
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument('--train_url')
    args, unknown = parser.parse_known_args()
    train_url = args.train_url 
  • If you select Environment variables, use this code to obtain the data:
    import os
    train_url = os.getenv("train_url", "")

Predownload

Indicates whether to pre-download the files in the output directory to a local directory.

  • If you set Predownload to No, the system does not download the files in the training output data path to a local directory of the training container when the training job is started.
  • If you set Predownload to Yes, the system automatically downloads the files in the training output data path to a local directory of the training container when the training job is started. The larger the file size, the longer the download time. To avoid excessive training time, remove any unneeded files from the local code directory of the training container as soon as possible. To use Resumable Training, select Yes.

Hyperparameter

N/A

Used for training tuning. This parameter is determined by the selected algorithm. If hyperparameters have been defined in the algorithm, all hyperparameters in the algorithm are displayed.

Hyperparameters can be modified and deleted. The status depends on the hyperparameter constraint settings in the algorithm. For details, see Configuring Hyperparameters.

NOTE:

To ensure data security, do not enter sensitive information, such as plaintext passwords.

Environment Variable

N/A

Add environment variables based on service requirements. For details about the environment variables preset in the training container, see Managing Environment Variables of a Training Container.

NOTE:

To ensure data security, do not enter sensitive information, such as plaintext passwords.

Auto Restart

N/A

Once this feature is enabled, you can set the number of restarts and whether to enable Unconditional auto restart.

After you enable auto restart, ModelArts will handle any exceptions caused by environmental issues during a training job. It will either automatically handle the exception or isolate the faulty node and then restart the job, which helps to increase the success rate of the training. To avoid losing training progress and make full use of compute power, ensure that your code logic supports resumable training before enabling this function. For details, see Resumable Training.

The value ranges from 1 to 128. The default value is 3. The value cannot be changed once the training job is created. Set this parameter based on your needs.

If Unconditional auto restart is selected, the training job will be restarted unconditionally once the system detects a training exception. To prevent invalid restarts, it supports a maximum of three consecutive unconditional restarts.

If auto restart is triggered during training, the system records the restart information. You can check the fault recovery details on the training job details page. For details, see Training Job Rescheduling.

Configuring a Public Resource Pool

To configure a public resource pool, refer to Table 5.
Table 5 Configuring a public resource pool for a training job

Parameter

Description

Resource Pool

Select Public resource pool.

Resource Type

Select the resource type required for training. This parameter is mandatory. If a resource type has been defined in the training code, select a proper resource type based on algorithm constraints. For example, if the resource type defined in the training code is CPU and you select other types, the training fails. If some resource types are invisible or unavailable for selection, they are not supported.

Specifications

Select the required resource specifications based on the resource type.

If Data path is selected for Input, you can click Check Input Size on the right to ensure the storage is larger than the input data size.

NOTICE:

The resource flavor GPU:n*tnt004 (n indicates a specific number) does not support multi-process training.

Compute Nodes

Select the number of compute nodes as required. The default value is 1.

  • If only one compute node is used, a single-node training job is created. ModelArts starts one training container on this node. The training container exclusively uses the compute resources of the selected flavor.
  • If more than one compute nodes are used, a distributed training job is created. For more information about distributed training configurations, see Overview.

Persistent Log Saving

If you select CPU or GPU flavors, Persistent Log Saving is available for you to set.

  • This function is disabled by default. ModelArts automatically stores the logs for 30 days. You can download all logs on the job details page to a local path.
  • After this feature is enabled, set Job Log Path. The system permanently stores training logs to the specified OBS path.

Job Log Path

When enabling Persistent Log Saving, select an empty OBS directory for Job Log Path to store log files generated by the training job.

Ensure that you have read and write permissions to the selected OBS directory.

Event Notification

Indicates whether to enable event notification.

  • This feature is disabled by default, which means SMN is disabled.
  • After this feature is enabled, you will be notified of specific events, such as job status changes or suspected suspensions, via an SMS or email. Notifications will be billed based on SMN pricing. In this case, you must configure the topic name and events.
    • Topic: topic of event notifications. Click Create Topic to create a topic on the SMN console.
    • Event: events you want to subscribe to. Examples: JobStarted, JobCompleted, JobFailed, JobTerminated, and JobHanged.
NOTE:
  • After you create a topic on the SMN console, add a subscription to the topic, and confirm the subscription. Then, you will be notified of events. For details, see Adding a Subscription.
  • SMN charges you for the number of notification messages. For details, see Billing.
  • Only training jobs using GPUs or NPUs support JobHanged events.

Auto Stop

When using paid resources, you can determine whether to enable auto stop.

  • This function is disabled by default, the training job keeps running until the training is completed.
  • If this function is enabled, configure the auto stop time. The value can be 1 hour, 2 hours, 4 hours, 6 hours, or Customize. The customized time must range from 1 hour to 720 hours. When you enable this feature, the training stops automatically when the time limit is reached. The time limit does not count down when the training is paused.

Configuring a Dedicated Resource Pool

To configure a dedicated resource pool, refer to Table 6.
Table 6 Configuring a dedicated resource pool for a training job

Parameter

Description

Resource Pool

Select a dedicated resource pool.

If you select a dedicated resource pool, you can view the status, node specifications, number of idle/fragmented nodes, number of available/total nodes, and number of cards of the resource pool. Hover over View in the Idle/Fragmented Nodes column to check fragment details and check whether the resource pool meets the training requirements.

Specifications

Select the required resource specifications based on the resource type.

If Data path is selected for Input, you can click Check Input Size on the right to ensure the storage is larger than the input data size.

NOTICE:

The resource flavor GPU:n*tnt004 (n indicates a specific number) does not support multi-process training.

Compute Nodes

Select the number of compute nodes as required. The default value is 1.

  • If only one compute node is used, a single-node training job is created. ModelArts starts one training container on this node. The training container exclusively uses the compute resources of the selected flavor.
  • If more than one compute nodes are used, a distributed training job is created. For more information about distributed training configurations, see Overview.

Job Priority

When using a dedicated resource pool, you can set the priority of the training job. The value ranges from 1 to 3. The default priority is 1, and the highest priority is 3.

  • By default, the job priority can be set to 1 or 2. After the permission to set the highest job priority is configured, the priority can be set to 1 to 3.
  • If a training job is in the Pending state for a long time, you can change the job priority to reduce the queuing duration. For details, see Priority of a Training Job.

SFS Turbo

When ModelArts and SFS Turbo are directly connected, multiple SFS Turbo file systems can be mounted to a training job to store training data. Click Add Mount Configuration and set the following parameters:

  • Name: Select an SFS Turbo file system.
  • Mount Path: Enter the SFS Turbo mounting path in the training container.
  • Directory: Specify the SFS Turbo storage location. If you have configured the folder control permission, select a storage location. If you have not configured the folder control permission, retain the default value / or customize a location.
  • Mounting Mode: Permission on the mounted SFS Turbo file system. This parameter is displayed as Read/Write or Read-only based on the permission of the SFS Turbo storage location. If you have not configured the folder control permission, this parameter is unavailable.
  • Mount Options: Configure SFS mount parameters to accelerate and optimize training. For details about the parameters, see Configuring SFS Turbo Mount Options. Alternatively, retain the default settings below:
    mountOptions:
    - vers=3 
    - timeo=600 
    - nolock 
    - hard
NOTE:
  • A file system can be mounted only once and to only one path. Each mount path must be unique. A maximum of 8 disks can be mounted to a training job.
  • The mounting path cannot be a / directory or a default mounting path, such as /cache and /home/ma-user/modelarts.
  • For details about how to set permissions for SFS Turbo folders, see Permissions Management.

Persistent Log Saving

If you select CPU or GPU flavors, Persistent Log Saving is available for you to set.

  • This feature is disabled by default. ModelArts automatically stores the logs for 30 days. You can download all logs on the job details page to a local path.
  • After this feature is enabled, set Job Log Path. The system permanently stores training logs to the specified OBS path.

Job Log Path

When enabling Persistent Log Saving, select an empty OBS directory for Job Log Path to store log files generated by the training job.

Ensure that you have read and write permissions to the selected OBS directory.

Event Notification

Indicates whether to enable event notification.

  • This feature is disabled by default, which means SMN is disabled.
  • After this feature is enabled, you will be notified of specific events, such as job status changes or suspected suspensions, via an SMS or email. Notifications will be billed based on SMN pricing. In this case, you must configure the topic name and events.
    • Topic: topic of event notifications. Click Create Topic to create a topic on the SMN console.
    • Event: events you want to subscribe to. Examples: JobStarted, JobCompleted, JobFailed, JobTerminated, and JobHanged.
NOTE:
  • After you create a topic on the SMN console, add a subscription to the topic, and confirm the subscription. Then, you will be notified of events. For details, see Adding a Subscription.
  • SMN charges you for the number of notification messages. For details, see Billing.
  • Only training jobs using GPUs or NPUs support JobHanged events.

Auto Stop

When using paid resources, you can determine whether to enable auto stop.

  • This feature is disabled by default, the training job keeps running until the training is completed.
  • If this feature is enabled, configure the auto stop time. The value can be 1 hour, 2 hours, 4 hours, 6 hours, or Customize. The customized time must range from 1 hour to 720 hours. When you enable this feature, the training stops automatically when the time limit is reached. The time limit does not count down when the training is paused.

(Optional) Adding Tags

If you want to manage training jobs by group using tags, select Configure Now for Advanced Configuration to set tags for training jobs. For details about how to use tags, see Using TMS Tags to Manage Resources by Group.

Follow-Up Operations

After parameter setting for creating a training job, click Submit. On the Confirm dialog box, click OK.

A training job runs for a period of time. You can go to the training job list to view the basic information about the training job.

  • In the training job list, Status of a newly created training job is Pending.
  • When the status of a training job changes to Completed, the training job is finished, and the generated model is stored in the corresponding output path.
  • If the status is Failed or Abnormal, click the job name to go to the job details page and view logs for troubleshooting.

You are billed for the resources you choose when your training job runs.