Installation Packages
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.
Automatic Environment Variable Configuration
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/ascend-toolkit/set_env.sh # Install the nnrt package. source /usr/local/Ascend/nnrt/set_env.sh # Install the nnae package. source /usr/local/Ascend/nnae/set_env.sh # Install the nnal package. source /usr/local/Ascend/nnal/atb/set_env.sh # Install the tfplugin package. source /usr/local/Ascend/tfplugin/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/ascend-toolkit/set_env.sh
# Install the nnrt package.
source ${HOME}/Ascend/nnrt/set_env.sh
# Install the nnae package.
source ${HOME}/Ascend/nnae/set_env.sh
# Install the nnal package.
source ${HOME}/Ascend/nnal/atb/set_env.sh
# Install the tfplugin package.
source ${HOME}/Ascend/tfplugin/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 |
Example |
|---|---|---|---|
Development kit (Toolkit) |
LD_LIBRARY_PATH |
Dynamic library search path |
export LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64:/usr/local/Ascend/driver/lib64/common:/usr/local/Ascend/driver/lib64/driver:$LD_LIBRARY_PATH
export ASCEND_TOOLKIT_HOME=/home/HwHiAiUser/Ascend/ascend-toolkit/latest
export LD_LIBRARY_PATH=${ASCEND_TOOLKIT_HOME}/lib64:${ASCEND_TOOLKIT_HOME}/lib64/plugin/opskernel:${ASCEND_TOOLKIT_HOME}/lib64/plugin/nnengine:$LD_LIBRARY_PATH
export PYTHONPATH=${ASCEND_TOOLKIT_HOME}/python/site-packages:${ASCEND_TOOLKIT_HOME}/opp/built-in/op_impl/ai_core/tbe:$PYTHONPATH
export PATH=${ASCEND_TOOLKIT_HOME}/bin:${ASCEND_TOOLKIT_HOME}/compiler/ccec_compiler/bin:$PATH
export ASCEND_AICPU_PATH=${ASCEND_TOOLKIT_HOME}
export ASCEND_OPP_PATH=${ASCEND_TOOLKIT_HOME}/opp
export TOOLCHAIN_HOME=${ASCEND_TOOLKIT_HOME}/toolkit
export ASCEND_HOME_PATH=${ASCEND_TOOLKIT_HOME}
|
ASCEND_TOOLKIT_HOME |
Path for storing files after the CANN-toolkit software package is installed |
||
PYTHONPATH |
Python search path |
||
PATH |
Path for searching for executable files |
||
ASCEND_AICPU_PATH |
Installation path of AI CPU |
||
ASCEND_OPP_PATH |
Root directory of the operator package (OPP) |
||
TOOLCHAIN_HOME |
Installation path of the toolchain |
||
ASCEND_HOME_PATH |
Same as ASCEND_TOOLKIT_HOME, indicates the file storage path after the CANN-toolkit software is installed. |
||
Offline inference engine package (nnrt) |
ASCEND_NNRT_HOME |
Path for storing files after the nnrt software package is installed |
export LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64:/usr/local/Ascend/driver/lib64/common:/usr/local/Ascend/driver/lib64/driver:$LD_LIBRARY_PATH
export ASCEND_NNRT_HOME=/home/HwHiAiUser/Ascend/nnrt/latest
export LD_LIBRARY_PATH=${ASCEND_NNRT_HOME}/lib64:$LD_LIBRARY_PATH
export PYTHONPATH=${ASCEND_NNRT_HOME}/python/site-packages:$PYTHONPATH
export ASCEND_AICPU_PATH=${ASCEND_NNRT_HOME}
export ASCEND_OPP_PATH=${ASCEND_NNRT_HOME}/opp
|
LD_LIBRARY_PATH |
Dynamic library search path |
||
PYTHONPATH |
Python search path |
||
ASCEND_AICPU_PATH |
Installation path of AI CPU |
||
ASCEND_OPP_PATH |
Root directory of the operator package (OPP) |
||
Deep learning engine package (nnae) |
ASCEND_NNAE_HOME |
Path for storing files after the nnae software package is installed |
export LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64:/usr/local/Ascend/driver/lib64/common:/usr/local/Ascend/driver/lib64/driver:$LD_LIBRARY_PATH
export ASCEND_NNAE_HOME=/home/HwHiAiUser/Ascend/nnae/latest
export LD_LIBRARY_PATH=${ASCEND_NNAE_HOME}/lib64:${ASCEND_NNAE_HOME}/lib64/plugin/opskernel:${ASCEND_NNAE_HOME}/lib64/plugin/nnengine:$LD_LIBRARY_PATH
export PYTHONPATH=${ASCEND_NNAE_HOME}/python/site-packages:${ASCEND_NNAE_HOME}/opp/built-in/op_impl/ai_core/tbe:$PYTHONPATH
export PATH=${ASCEND_NNAE_HOME}/bin:${ASCEND_NNAE_HOME}/compiler/ccec_compiler/bin:$PATH
export ASCEND_AICPU_PATH=${ASCEND_NNAE_HOME}
export ASCEND_OPP_PATH=${ASCEND_NNAE_HOME}/opp
export ASCEND_HOME_PATH=${ASCEND_NNAE_HOME}
|
LD_LIBRARY_PATH |
Dynamic library search path |
||
PYTHONPATH |
Python search path |
||
PATH |
Path for searching for executable files |
||
ASCEND_AICPU_PATH |
Installation path of AI CPU |
||
ASCEND_OPP_PATH |
Root directory of the operator package (OPP) |
||
ASCEND_HOME_PATH |
Same as ASCEND_NNAE_HOME, indicates the file storage path after the nnae software is installed. |
||
Acceleration library (nnal) |
ATB_HOME_PATH |
Path for storing files after the package is installed |
export ATB_HOME_PATH="${atb_path}/latest/atb/cxx_abi_${cxx_abi}"
export LD_LIBRARY_PATH=$ATB_HOME_PATH/lib:$ATB_HOME_PATH/examples:$ATB_HOME_PATH/tests/atbopstest:$LD_LIBRARY_PATH
export PATH=$ATB_HOME_PATH/bin:$PATH
# Environment variables of the acceleration library
export ATB_STREAM_SYNC_EVERY_KERNEL_ENABLE=0
export ATB_STREAM_SYNC_EVERY_RUNNER_ENABLE=0
export ATB_STREAM_SYNC_EVERY_OPERATION_ENABLE=0
export ATB_OPSRUNNER_SETUP_CACHE_ENABLE=1
export ATB_OPSRUNNER_KERNEL_CACHE_TYPE=3
export ATB_OPSRUNNER_KERNEL_CACHE_LOCAL_COUNT=1
export ATB_OPSRUNNER_KERNEL_CACHE_GLOABL_COUNT=5
export ATB_OPSRUNNER_KERNEL_CACHE_TILING_SIZE=10240
export ATB_WORKSPACE_MEM_ALLOC_ALG_TYPE=1
export ATB_WORKSPACE_MEM_ALLOC_GLOBAL=0
export ATB_COMPARE_TILING_EVERY_KERNEL=0
export ATB_HOST_TILING_BUFFER_BLOCK_NUM=128
export ATB_DEVICE_TILING_BUFFER_BLOCK_NUM=32
export ATB_SHARE_MEMORY_NAME_SUFFIX=""
export ATB_LAUNCH_KERNEL_WITH_TILING=1
export ATB_MATMUL_SHUFFLE_K_ENABLE=1
export ATB_RUNNER_POOL_SIZE=64
# Environment variables of the OPP
export ASDOPS_HOME_PATH=$ATB_HOME_PATH
export ASDOPS_MATMUL_PP_FLAG=1
export ASDOPS_LOG_LEVEL=ERROR
export ASDOPS_LOG_TO_STDOUT=0
export ASDOPS_LOG_TO_FILE=1
export ASDOPS_LOG_TO_FILE_FLUSH=0
export ASDOPS_LOG_TO_BOOST_TYPE=atb
export ASDOPS_LOG_PATH=~
export ASDOPS_TILING_PARSE_CACHE_DISABLE=0
export LCCL_DETERMINISTIC=0
|
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_SETUP_CACHE_ENABLE |
Whether to enable the SetupCache function of the ATB. When detecting that the input and output tensors of the operation do not change, this function skips most of the processes of the setup to improve the performance on the scheduling side. This function is enabled by default for performance acceleration. |
||
ATB_OPSRUNNER_KERNEL_CACHE_TYPE |
Whether to enable the kernelCache function of the ATB. When detecting that the input and parameters of the operation do not change, this function reuses the computed tiling data and internal structs to improve the performance on the scheduling side. |
||
ATB_OPSRUNNER_KERNEL_CACHE_LOCAL_COUNT |
Number of slots for the local kernel cache.
|
||
ATB_OPSRUNNER_KERNEL_CACHE_GLOABL_COUNT |
Number of slots for the global kernel cache.
|
||
ATB_OPSRUNNER_KERNEL_CACHE_TILING_SIZE |
Sets the size of each buffer used to store tiling in the kernel cache (unit: byte). You are advised not to change the value unless the operator tiling size exceeds the buffer size. |
||
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_WORKSPACE_MEM_ALLOC_GLOBAL |
Whether to use the global intermediate tensor memory allocation algorithm. After this algorithm is enabled, the size of the intermediate tensor memory is computed and allocated. |
||
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_HOST_TILING_BUFFER_BLOCK_NUM |
Number of HostTilingBuffer blocks in the context. The number is related to the maximum number of parallel operators. Generally, the default value is used and should not be changed unless necessary. |
||
ATB_DEVICE_TILING_BUFFER_BLOCK_NUM |
Number of DeviceTilingBuffer blocks in the context. The number is related to the maximum number of parallel operators. Generally, the default value is used should not be changed unless necessary. |
||
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_LAUNCH_KERNEL_WITH_TILING |
Whether to enable the function of delivering tiling copies with operators. After this environment variable is enabled, the tiling copy mode is modified to improve the performance of Atlas inference products. |
||
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. |
||
ATB_RUNNER_POOL_SIZE |
Number of runners that can be stored in the runner pool of the acceleration library. You are advised not to change the value. If the input tensor and parameter configurations of the operator do not remain unchanged, increasing the capacity of the runner pool can improve the performance but increases the host memory usage. |
||
ASDOPS_HOME_PATH |
Used to configure the OPP path to facilitate the use of the ATB function. |
||
ASDOPS_MATMUL_PP_FLAG |
Whether to enable PPMATMUL for the OPP. |
||
ASDOPS_LOG_LEVEL |
OPP log level. |
||
ASDOPS_LOG_TO_STDOUT |
Whether to output OPP logs to the console. |
||
ASDOPS_LOG_TO_FILE |
Whether to output OPP logs to a file. |
||
ASDOPS_LOG_TO_FILE_FLUSH |
Whether to update the flushed log file. |
||
ASDOPS_LOG_TO_BOOST_TYPE |
Name of the acceleration library log directory. |
||
ASDOPS_LOG_PATH |
Path for storing OPP logs. |
||
ASDOPS_TILING_PARSE_CACHE_DISABLE |
Whether to enable tilingParse cache optimization for the OPP. After the optimization is enabled, the performance of non-first tokens is improved. |
||
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:
|
||
TensorFlow framework plugin package (tfplugin) |
ASCEND_PLUGIN_HOME |
Path for storing files after the framework package is installed |
export ASCEND_PLUGIN_HOME=/usr/local/Ascend/tfplugin/latest
export PYTHONPATH=${ASCEND_PLUGIN_HOME}/python/site-packages:$PYTHONPATH
|
PYTHONPATH |
Python search path |
Manual Environment Variable Configuration
During program build and execution, you may need to configure environment variables related to software package installation. The following describes the CANN environment variables that need to be manually configured in different scenarios.
Package |
Environment Variable |
Description |
Example |
|---|---|---|---|
Custom operator installation package |
ASCEND_CUSTOM_OPP_PATH |
Installation path of the user custom operator package. Multiple paths need to be separated by colons (:). The path at the beginning has the highest priority. |
export ASCEND_CUSTOM_OPP_PATH=/home/HwHiAiUser/Ascend/ascend-toolkit/latest/opp/vendor_name2:/home/HwHiAiUser/Ascend/ascend-toolkit/latest/opp/vendor_name1 |