Help Center/ ModelArts/ ModelArts User Guide (Standard)/ Model Training/ Creating a Debug Training Job/ Using PyCharm Toolkit to Create and Debug a Training Job
Updated on 2024-10-29 GMT+08:00

Using PyCharm Toolkit to Create and Debug a Training Job

AI developers use PyCharm to develop algorithms or models. ModelArts provides the PyCharm Toolkit plug-in to help AI developers quickly submit locally developed code to the ModelArts training environment. With PyCharm Toolkit, developers can quickly remotely access notebook instances, upload code, submit training jobs, and obtain training logs for local display so that they can better focus on local code development.

This section describes how to use PyCharm Toolkit to create and debug a training job.

Prerequisites

  • Step 1 Download and Install PyCharm Toolkit
  • A training code project exists in the local PyCharm.
  • You have created a bucket and folders in OBS for storing datasets and trained models. For example, create a bucket named test-modelarts2 and folders dataset-mnist and mnist-output. Data used by the training job has been uploaded to OBS. OBS and ModelArts are in the same region.

Configuring Training Job Parameters

  1. In PyCharm, open the training code project and training boot file, and choose ModelArts > Training Job > New... on the menu bar.
    Figure 1 Configuring job parameters
  2. In the displayed dialog box, configure the training job parameters. For details, see Table 1.
    Table 1 Training job parameters

    Parameter

    Description

    Job Name

    Name of the training job.

    The system automatically generates a name. You can rename it based on the following naming rules:

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

    Job Description

    Brief description of the training job.

    Algorithm Source

    Source of the training algorithm. The options are Frequently-used and Custom.

    Frequently-used refers to the frequently-used AI engines supported by ModelArts Training Management.

    If the AI engine you use is not in the supported list, you are advised to create a training job using a custom image.

    AI Engine

    Select the AI engine and the version used in code. The supported AI engines are the same as the frequently-used frameworks supported by training jobs on the ModelArts management console.

    Boot File Path

    Training boot file. The selected boot file must be a file in the current PyCharm training project. This parameter is displayed if Algorithm source is set to Frequently-used.

    Code Directory

    Training code directory. The system automatically sets this parameter to the directory where the training boot file is located. You can change the parameter value to a directory that is in the current project and contains the boot file.

    If the algorithm source is a custom image and the training code has been built in the image, this parameter can be left blank.

    Image Path(optional)

    URL of the SWR image

    Boot Command

    Command for starting the training job, for example, bash /home/work/run_train.sh python {Python boot file and parameters}. This parameter is displayed if Algorithm source is set to Custom.

    If the command does not contain the --data_url or --train_url parameter, the tool automatically adds the two parameters to the end of the command when submitting the training job. The two parameters correspond to the OBS path for storing training data and the OBS path for storing training output, respectively.

    Data OBS Path

    OBS path for storing training data, for example, /test-modelarts2/mnist/dataset-mnist/, in which test-modelarts2 indicates a bucket name.

    Training OBS Path

    OBS path. A directory is automatically created in the path for storing a trained model and training logs.

    Running Parameters

    Running parameters. Add running parameters to your code based on your needs. Separate multiple running parameters with semicolons (;), for example, key1=value1;key2=value2. This parameter can be left blank.

    Specifications

    Type of resources used for training. Currently, public resource pools and dedicated resource pools are supported.

    Dedicated resource pool specifications are identified by Dedicated Resource Pool. Dedicated resource pool specifications are displayed only for users who have purchased dedicated resource pools.

    Compute Nodes

    Number of compute nodes. If this parameter is set to 1, the system runs in standalone mode. If this parameter is set to a value greater than 1, the distributed computing mode is used at the background.

    Available/Total Nodes

    When Specifications is set to a dedicated resource pool, the number of available nodes and the total number of nodes are displayed. The value of Compute Nodes cannot exceed the number of available nodes.

    Figure 2 Configuring training job parameter (public resource pool)
    Figure 3 Configuring training job parameters (dedicated resource pool)
    Figure 4 Configuring training job parameters (custom image)
  3. Click Apply and Run. Then, local code is automatically uploaded to the cloud and training is started. The training job status is displayed in the Training Log area in real time. If information similar to Current training job status: Successful is displayed in the training logs, the training job has been successfully executed.
    • After you click Apply and Run, the system automatically executes the training job. To stop the training job, choose ModelArts > Training Job > Stop on the menu bar.
    • If you click Apply, the job is not started directly, and the training job settings are saved instead. To start the job, click Apply and Run.
    Figure 5 Training log example

Stopping a Job

When a training job is running, choose ModelArts > Training Job > Stop on the PyCharm menu bar to stop the training job.

Figure 6 Stopping a job

Viewing Training Logs

You can view training logs in OBS or PyCharm Toolkit.

  • Viewing training logs in OBS

    When you submit a training job, the system automatically creates a folder with the same name as the training job in the configured OBS path to store the model, logs, and code outputted during training.

    For example, when the train-job-01 job is submitted, a folder named train-job-01 is created in the test-modelarts2 bucket. In this folder, three sub-folders (output, log, and code) are created to store the outputted model, logs, and training code, respectively. Sub-folders will be created in the output folder based on your training job version. The following is an example of the folder structure:
    test-modelarts2
        |---train-job-01
             |---output 
             |---log
             |---code
  • Viewing training logs in PyCharm Toolkit

    In PyCharm Toolkit, click ModelArts Training Log in the lower right corner of the page to view the training logs.

    Figure 7 Viewing training logs