Before You Start

Restrictions

Before using tools, understand the following restrictions:

  • Permission restrictions
    • Adhere to the principle of least privilege. Specifically, eliminate world-writable permissions such as 666 and 777.
    • Before using profiling tools, ensure that the execution user's umask is 0027 or more restrictive. Otherwise, the generated profile data directories and files will have excessive permissions.
    • To ensure security and adhere to the principle of least privilege, you are advised to run this tool as a standard user rather than a high-privilege user (such as root).
    • This tool is a development and debugging tool and should not be used in the production environment.
    • This tool depends on CANN and the corresponding driver software package. Before using this tool, install CANN and the required driver software package, and run the source command to execute the set_env.sh environment variable file of CANN. To ensure security, do not modify the environment variables in set_env.sh after running the source command.
    • Ensure that the profile data is stored in the current user directory that does not contain soft links. Otherwise, security problems may occur.
  • Execution restrictions
    • Simultaneously initiating multiple profiling tasks on the same device is not supported. Additionally, two or more profiling tools cannot be started at the same time.
    • Avoid using the data profiling feature alongside the dump function. The dump operation could affect the system performance. If the data profiling and dump functions are both enabled, the profile data metrics will be inaccurate. Therefore, disable data dump before starting data profiling.
  • Data flush restrictions
    • The recommended duration for data profiling is within 5 minutes. Reserve memory and disk space that is at least 20 times the size of the raw profile data. The size of raw data refers to the total amount of data saved in the data directory after profiling.
    • For data profiling and flushing in a single task when all profiling items are enabled, ensure that the disk read/write speed meets the requirements.
      • If your inference job runs on a single device, ensure that the disk read/write speed is 50 MB/s or higher.
      • If your training job runs on a single device, ensure that the disk read/write speed is 60 MB/s or higher.
      • If your job runs on multiple devices, the disk read/write speed must be greater than or equal to that of a single device multiplied by the number of devices.
    • Profile data cannot be flushed to a disk if the disk is full during profiling. Therefore, it is necessary to leave enough space on the disk. You can configure --storage-limit to prevent the disk space from being used up by the profile data.
    • During profile data parsing, if the configured disk or user directory space is full, the parsing fails or the file cannot be flushed to the disk. In this case, you need to clear the disk or user directory space.
  • Compatibility and scenario restrictions
    • Python 3.7.5 or later is required.
    • The application project development must comply with Application Development Guide (C&C++). To obtain complete profile data, call aclInit() to perform initialization and call aclFinalize() to perform deinitialization.

      If the application has called aclInit() but not aclFinalize(), the profiling process will be terminated abnormally, resulting in incomplete profile data. The data profiled within the last second may be lost due to delayed flushing, but the lost data is no more than 2 MB, and this does not affect the analysis of the flushed profile data.

    • If you use the msprof CLI for data profiling of an application project developed with pyACL APIs, the Python script cannot access files with relative paths. Otherwise, errors will be reported during profiling.
    • Ascend virtual instance: For details about the supported profiling options, see Data Profiling Switches Supported in the Ascend virtual instance Scenario.

Environment Setup

  1. Install CANN packages based on the actual scenario. For details about , see CANN Software Installation Guide..

    In the Ascend EP scenario, the msprof tool is saved in ${INSTALL_DIR}/tools/profiler/bin. Replace ${INSTALL_DIR} with the actual CANN component directory. If the Ascend-CANN-Toolkit package is installed as the root user, the CANN component directory is /usr/local/Ascend/ascend-toolkit/latest.

    In the Ascend RC scenario, the msprof tool is saved in /var.

    If only the Ascend-cann-nnae deep learning engine or Ascend-cann-nnrt offline inference engine is installed in the operating environment, call AscendCL APIs to perform profiling (see Using acl (Adapted for C & C++) APIs for Data Profiling). Upload the profiled result to the development environment where the Ascend-cann-toolkit is installed, and parse and export the result by referring to Parsing and Exporting Profile Data.

  2. Set public environment variables.

    After the CANN software is installed, when you build and run your application as the CANN running user, log in to the environment as the CANN running user and run the source ${install_path}/set_env.sh command to set environment variables. {install_path} indicates the CANN installation path, for example, /usr/local/Ascend/ascend-toolkit.

  3. Set Python environment variables.
    If multiple Python 3 series versions exist, specify your Python installation path according to your service needs. The following takes Python 3.7.5 as an example.
    export PATH=/usr/local/python3.7.5/bin:$PATH
    # Set the library path for Python 3.7.5.
    export LD_LIBRARY_PATH=/usr/local/python3.7.5/lib:$LD_LIBRARY_PATH

The preceding environment variables take effect only in the current window. You can write the preceding commands to the ~/.bashrc file to make them take effect permanently. The operations are as follows:

  1. Run the vi ~/.bashrc command in any directory as the installation user and append the preceding commands to the file.
  2. Run the :wq! command to save the file and exit.
  3. Run the source ~/.bashrc command to make the environment variables take effect.