MindSpore Training

Environment Setup

Set up the operating environment. For details, see the Installation Guide of MindSpore.
  • The MindSpore model training scripts provided at ModelZoo in the Ascend Community are based on the hardware backends equipped with Ascend AI Processors. Make sure to set up the MindSpore operating environment on the Ascend 910 hardware. After the MindSpore operating environment is set up, configure the software environment variables corresponding to Ascend 910 AI Processors.
  • If the run mode is Remote Run, MindSpore is installed in a remote environment while MindStudio is installed in a local environment.

Environment Variable Configuration

  1. Run the vi ~/.bashrc command in any directory as the running user to open the .bashrc file, and append the following content to the file (the default installation path of a non-root user is used as an example):
    # Ascend-CANN-Toolkit environment variable. Change it to the actual path.
    source ~/Ascend/ascend-toolkit/set_env.sh
  2. Refer to Configuring Environment Variables to configure MindSpore environment variables.
  3. Run the :wq! command to save the file and exit.
  4. Run the source ~/.bashrc command for the modification to take effect immediately.

Procedure

The following describes the overall procedure for creating a training project with the ResNet-50 for MindSpore template sample. For details about the project information and related pop-up windows, see Procedure.

  1. Click Ascend Training on the left of the page to create an Ascend training project, as shown in Figure 1.
    Figure 1 Project creation page
  2. On the training project selection page shown in Figure 1, select the ResNet-50 for MindSpore template under CANN Version and Samples.
  3. Click Next and configure other information about the training project. For details about the parameters, see Creating a Training Project.
  4. Click Finish. The training project is created.

    If this is your first-time creation, the tool will automatically download the sample project template. Ensure that your device is connected to the network; or subsequent operations cannot be performed.

  5. View the ResNet-50 for MindSpore template project window as shown in Figure 2.
    Figure 2 Template project window

    If error message "Unzip failed. There is problem occurred when unzipping file." is displayed when you create a sample training project on Window, refer to What Do I Do If I Get Error "Unzip failed. There is problem occurred when unzipping file." When Creating a Sample Training Project on Windows? to rectify the fault.

  6. Download the CIFAR-10 dataset, for example, cifar-10-binary.tar.gz. Copy it to the data/ directory (created by yourself) in the local environment or decompress it in the remote operating environment.

    If you copy the dataset to the remote operating environment, ensure that the dataset import path defined in the training script is the same as the path of the uploaded dataset.

  7. Set the run configurations and run the project.
    1. Choose Run > Edit Configurations... on the training project page or click Edit Configurations... on the menu shown in Figure 3 to access the run configuration page.
      Figure 3 Shortcut to the run configuration page
    2. Set training parameters, as shown in Figure 4.
      Figure 4 Run configuration page

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

      Table 1 Run configurations of the training project

      Parameter

      Description

      Remarks

      Name

      Project name (user-defined).

      For example: MyTraining1.

      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.

      For example, Local Run.

      -

      Deployment

      Run configurations.

      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.

      In this example, Run Mode is set to Local Run. Therefore, this parameter is not displayed.

      Executable

      Entry point file of the training project.

      scripts/run_standalone_train.sh

      Command Arguments

      Command-line arguments for training.

      resnet50 cifar10 ../data/cifar-10-batches-bin

      Environment Variables

      Environment variables of the training project.

      Set this parameter as required.

    3. Click OK, and the training project information is created.
    4. Choose Run > Run 'MyTraining1' on the project page or click the button shown in Figure 5 to perform training.
      Figure 5 Performing training using a shortcut
      Figure 6 shows the training process.
      Figure 5 Training process display
  8. After the training is complete, the generated model file .ckpt is stored in the /scripts/train directory of the project file.

    For details about other operations, see the Training tab in the ResNet-50 model page at ModelZoo in the Ascend Community.