Environment Setup
Environment Setup
- Install the development kit. For details, see CANN Software Installation Guide.
- Configure environment variables.After the CANN package is installed, log in to the environment as the CANN operating user and run the source $INSTALL_DIR/set_env.sh command to set environment variables. Replace ${INSTALL_DIR} with the CANN component directory. For example, if the installation is performed by the root user, the default file storage path is /usr/local/Ascend/cann.
The preceding environment variables take effect only in the current window. You can write the preceding commands to the ~/.bashrc file to make the environment variables take effect permanently. The operations are as follows:
- Run the vi ~/.bashrc command in any directory as the installation user to open the .bashrc file and append the preceding environment variables to the file.
- Run the :wq! command to save the file and exit.
- Run the source ~/.bashrc command for the environment variable to take effect.
Restrictions
- The analysis and migration tool supports the analysis and migration of training scripts of PyTorch 1.11.0, 2.1.0, 2.2.0, 2.3.1, 2.4.0, 2.5.1, and 2.6.0.
In automatic migration mode, PyTorch 1.11.0 does not support
Atlas A3 training products /Atlas A3 inference products . - The original scripts can be successfully executed in the GPU environment and based on Python 3.7 or later.
- The execution logic after script migration must be the same as that before migration.
- If the source code calls third-party libraries, adaptation issues may occur during the migration. Before migrating the source code, you need to install the third-party library versions adapted to Ascend based on the called third-party libraries. For details about the adapted third-party libraries and their usage guides, see Ascend Extension for PyTorch Supported Suites and Third-Party Libraries.
- The FusedAdam optimizer used in Apex does not support automatic migration and PyTorch GPU2Ascend tool-based migration. If the source code contains this optimizer, modify it as required.
- The current analysis tool does not support affinity API analysis for native functions self.dropout(), nn.functional.softmax(), torch.add, bboexs_diou(), bboexs_giou(), LabelSmoothingCrossEntropy(), and ColorJitter. If the original training script contains the preceding native functions, refer to "PyTorchx.x.x" > "Ascend Extension for PyTorch Custom APIs" > "torch_npu.contrib" in the Ascend Extension for PyTorch Custom API Reference to analyze and replace them.
- If the user training script contains the amp_C module that is not supported by the Ascend NPU platform, manually delete the code related to import amp_C before training.
- The platform of the migrated script is different from that of the original script. Therefore, during the debugging and running of the migrated script, an exception may be thrown due to such causes as operator differences and the process is terminated. This type of exception needs to be further debugged and resolved based on the specific exception information.
Security Precautions
- When using the tool in the Linux environment, you are advised to use a common user account instead of a high-permission user account (such as root) to ensure security and minimize permissions.
- When using the tool in the Linux environment, ensure that the execution user's umask is greater than or equal to 0027. Otherwise, the permissions on the data files and directories generated by the tool may be too high.
- When using the tool in the Linux environment, ensure that the minimum permission principle is used. For example, the files input to the tool must not be writable by other users. In some function scenarios with stricter security requirements, ensure that the input files are not writable by group users.
- This tool depends on CANN. To ensure security, use the CANN package installed by the same low-permission user by default. After the source command is executed, do not modify the environment variables involved in set_env.sh.
- This tool is a development and debugging tool. You are advised not to use it in the production environment.