Automatic Environment Variable Configuration
This section describes the basic environment variables related to program build and execution that are configured by default using the set_env.sh script after the CANN software is installed, and the environment variables related to the installation packages that need to be manually configured during subsequent program build and execution.
After the CANN software is installed, the basic environment variables on which program build and execution depend are automatically configured by default. However, the environment variables automatically become invalid after the user process ends. You can also run the following environment variable scripts to configure the environment variables in one-click mode:
# The following is an example of configuring environment variables during installation as the root user: # Install the Toolkit package. source /usr/local/Ascend/cann/set_env.sh # Install the ATB acceleration library of the NNAL package. source /usr/local/Ascend/nnal/atb/set_env.sh # Install the SiP acceleration library of the NNAL package. source /usr/local/Ascend/nnal/asdsip/set_env.sh
# The following is an example of configuring environment variables during installation as a non-root user:
# Install the Toolkit package
source ${HOME}/Ascend/cann/set_env.sh
# Install the ATB acceleration library of the NNAL package.
source ${HOME}/Ascend/nnal/atb/set_env.sh
# Install the SiP acceleration library of the NNAL package.
source ${HOME}/Ascend/nnal/asdsip/set_env.sh
You can also configure permanent environment variables by modifying the ~/.bashrc file. The procedure is as follows:
- Run the vi ~/.bashrc command in any directory as the running user to open the .bashrc file and append the preceding lines to the file.
- Run the :wq! command to save the file and exit.
- Run the source ~/.bashrc command for the modification to take effect immediately.
The following table details the environment variables.
Package |
Environment Variable |
Description |
|---|---|---|
Development kit (Toolkit) |
PATH |
Path for searching for executable files |
LD_LIBRARY_PATH |
Dynamic library search path |
|
PYTHONPATH |
Python search path |
|
ASCEND_OPP_PATH |
Root directory of the operator package (OPP) |
|
ASCEND_AICPU_PATH |
Installation path of AI CPU |
|
TOOLCHAIN_HOME |
Installation path of the toolchain |
|
ASCEND_HOME_PATH |
Same as ASCEND_TOOLKIT_HOME, which indicates the path for storing files after Toolkit is installed. |
|
ASCEND_TOOLKIT_HOME |
Path for storing files after the Toolkit software package is installed. |
|
CMAKE_PREFIX_PATH |
Built-in environment variable of CMake, which specifies the path to CMake library configuration files for retrieval by commands such as find_package(). |
|
ATB in the neural network acceleration library (NNAL) |
ATB_HOME_PATH |
Path for storing files after the ATB software package is installed. |
LD_LIBRARY_PATH |
Search path list when the dynamic library is loaded in Linux. |
|
PATH |
Add the path of the bin directory of the ATB software package to the PATH environment variable. The default path is recommended. |
|
ATB_STREAM_SYNC_EVERY_KERNEL_ENABLE |
Used to locate the kernel where the error is reported. When the variable is set to 1, stream synchronization is performed when the execution of each kernel ends. |
|
ATB_STREAM_SYNC_EVERY_RUNNER_ENABLE |
Used to locate the runner where the error is reported. When the variable is set to 1, stream synchronization is performed during the execution of each runner. |
|
ATB_STREAM_SYNC_EVERY_OPERATION_ENABLE |
Used to locate the operation where the error is reported. When the variable is set to 1, synchronization is performed during the execution of each operation. |
|
ATB_OPSRUNNER_KERNEL_CACHE_LOCAL_COUNT |
Number of slots for the local kernel cache.
|
|
ATB_OPSRUNNER_KERNEL_CACHE_GLOBAL_COUNT |
Number of slots for the global kernel cache.
|
|
ATB_WORKSPACE_MEM_ALLOC_ALG_TYPE |
Workspace memory allocation algorithms. The ATB selects different algorithms to compute the workspace size and allocation based on the environment variable configuration. You can select different algorithms to test the workspace allocation. |
|
ATB_COMPARE_TILING_EVERY_KERNEL |
After each kernel runs, the system compares the tiling content on the NPU before and after the running to check whether tiling memory corruption occurs. |
|
ATB_SHARE_MEMORY_NAME_SUFFIX |
Name suffix of the shared memory. When the communication operator is used by multiple users, this variable needs to be set to distinguish the shared memory. |
|
ATB_MATMUL_SHUFFLE_K_ENABLE |
Whether to enable Shuffle-K to control the consistency of the accumulation order of the matrix multiplication result when different positions of the matrix are computed. This variable affects the internal accumulation order of the matmul operator. |
|
LCCL_DETERMINISTIC |
Whether to enable LCCL deterministic AllReduce (order-preserving). Note that this function takes effect when rankSize ≤ 8. Enabling this function has the following impacts:
|
|
LCCL_PARALLEL |
This function and deterministic computing cannot be enabled at the same time. LCCL_DETERMINISTIC must be set to 0 or false. After the multi-communicator parallelism is used, LCCL_PARALLEL must be set to false. Otherwise, the performance in basic scenarios deteriorates. The value cannot be changed during the running. This environment variable can be used only in the allReduce multi-thread concurrency scenario. Only the |
|
SiP in the neural network acceleration library (NNAL) |
ASDSIP_HOME_PATH |
Path for storing files after the SiP software package is installed. |
LD_LIBRARY_PATH |
Search path list when the dynamic library is loaded in Linux. |