Procedure

The main steps for MindStudio to perform model training are as follows: Creating a Training Project (model training for the first time)/Importing a Training Project (a training project already exists) > Setting Run Configuration > Performing Training.

Creating a Training Project

You can use the MindSpore, TensorFlow, and PyTorch training frameworks as templates to create training projects.

  1. Navigate to the Create Ascend Training Project dialog box, as shown in Figure 1.
    • On the MindStudio welcome page, click New Project to access the project creation page.
    • On the MindStudio project page, choose File > New > Project... from the menu bar to access the project creation page.
      Figure 1 Project creation page
  2. Create a training project.
    1. In the navigation tree on the left, choose Ascend Training, as shown in Figure 1.
      1. Select a CANN Version on the right pane.
      2. Select a framework project under Templates or select a built-in sample under Samples. Here, a framework project under Templates is selected.

        If you select a project under Templates, you need to import or write a training script. If it is an NPU training script, you can directly perform model training. If it is a GPU training script, convert it into an NPU training script using the Analysis and Migration and then perform model training. If you select an NPU training project sample under Samples, you can directly perform model training.

    2. Click Next and configure other information about the training project. Table 1 describes the parameters.
      Table 1 Project parameters

      Parameter

      Description

      Project name

      Project name (user-defined).

      The name must start and end with a digit or letter. Only letters, digits, hyphens (-), and underscores (_) are allowed.

      Project location

      Default path for saving a project (user-defined). (For users who use MindStudio for the first time, the default value is $HOME/MindstudioProjects)

      More settings

      Module name: module name, same as the Project name.

      Content root: path in the root directory.

      Module file location: module file path.

      Click the check box on the right of Project format. A drop-down list is displayed.
      • .idea (directory-based) (default option): During project creation, an .idea project directory is created to save the project information.
      • .ipr (file-based): project configuration file used to save the project configuration information.
    3. Click Finish. The training project is created.
      If there is already an active project in the window, a confirmation message is displayed.
      • Click This Window to open the created project in the current window.
      • Click New Window to open the created project in a new window.
  3. View the directory structure and main files of the training project (subject to the actual creation result).
    ├── .idea
    ├── data                                  // Dataset directory, which needs to be created by yourself.
    ├── .project                                 // Project information file, including the project type, project description, target device type, and CANN version
    ├── train.py                                // Training script file, which is an empty file. You can create a training script here.
    ├── MyTraining.iml                         

Importing a Training Project

If a training project exists, you do not need to create one. Instead, directly import it through MindStudio. The procedure is as follows:

  1. Use MindStudio to import the training project.
    • On the MindStudio welcome page, click Open, select the project to be imported, and click OK.
    • On the MindStudio project page, choose File > Open... from the top menu bar or click on the menu bar to select an existing project and open it.
      • If a project has code risks, the trust window is displayed when you open the project.
        • If the project source code is trusted and secure, click Trust Project. (You can select Trust projects in <workspace_directory> to trust all projects in the directory.)
        • If the project is not trusted and you only want to view the source code, click Preview in Safe Mode to preview the project in safe mode.
        • To cancel opening the project, click Don't Open.
      • If you import an NPU training project, you can directly perform model training. If you import a GPU training project, convert it into an NPU training script using the Analysis and Migration and then perform model training.
  2. If there is already an active project in the window, a confirmation message is displayed.
    • Click This Window to open the created project in the current window.
    • Click New Window to open the created project in a new window.
  3. After a project is imported, the project directory is displayed in a tree structure (subject to the actual result).

Setting Run Configuration

  1. Choose Run > Edit Configurations... on the project page or click Edit Configurations... on the menu shown in Figure 2 to access the run configuration page.
    Figure 2 Shortcut menu of the run configuration page
  2. Configure training parameters.
    • If Run Mode is set to Remote Run, the configuration page shown in Figure 3 is displayed.
      Figure 3 Run configuration page
    • If Run Mode is set to Local Run, the configuration page shown in Figure 4 is displayed.
      Figure 4 Run configuration page

    Set run configurations of the training project on the right, as described in Table 2.

    Table 2 Parameters

    Parameter

    Description

    Remarks

    Name

    Project name (user-defined).

    For example: MyTraining

    The name contains a maximum of 64 characters, starting with a letter and ending with a letter or digit. Only letters, digits, hyphens (-), and underscores (_) are allowed.

    Run Mode

    Run mode, either Remote Run (default) or Local Run.

    -

    Executable

    Entry point file of the training project.

    For example:

    /data/home/xxx/MindstudioProjects/MyTraining/train.py

    -

    Deployment

    Run configuration settings. Mandatory. This parameter is available only when Remote Run is selected.

    You can use the Deployment function to synchronize the files and folders in a specified project to a specified directory on a remote device. For details, see Deployment.

    Command Arguments

    Command-line arguments for training. This parameter is optional.

    -

    Environment Variables

    Environment variables of the training project. This parameter is optional.

    -

  3. Click OK, and training project information is created.

Performing Training

  1. Choose Run > Run 'MyTraining' on the project page or click the button shown in Figure 5 to perform training. The process is as follows: Connect to the remote training machine > Package the training project and release it to the remote training machine > Start the training project.
    Figure 5 Performing training using a shortcut
  2. After performing the training, the real-time runtime information is displayed in the Run window at the bottom of the project page, as shown in the following figure.
    Figure 6 Real-time runtime information
  3. If the training succeeds, a corresponding message is displayed. Otherwise, the network_analysis_timestamp.report of the training project is generated in out/reports in the root directory of the project. The report content is as follows:
    Figure 7 Network analysis report

    The network support report is the .report file generated in out/reports under the project root directory after a training project using MindSpore as the training framework fails. For training projects using TensorFlow and PyTorch as training frameworks, the .report files are returned to user-defined output paths after training failures.