Environment Setup
Before development, set up the environment, including software package installation and environment variable configuration. This section details the setup procedure.
Installing the Driver, Firmware, and CANN Package
Set up the hardware environment with AI processor by referring to CANN Software Installation. Ensure that the CANN Toolkit and ops operator package have been installed. (For 8.5.0 and later versions, when building a graph into an offline model, you must install the ops operator package that matches the target AI processor. Otherwise, the build will fail.) After the installation is complete:
- ${INSTALL_DIR}/opp/built-in/op_graph/inc provides the CANN operator prototype definitions, which are used for building a graph from operator prototypes.
- ${INSTALL_DIR}/include/graph provides an API for building graphs.
- ${INSTALL_DIR}/include/ge provides an API for running graphs.
- ${INSTALL_DIR}/<arch>-linux/devlib provides related dependency libraries. <arch> indicates the OS architecture.
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.
Setting Environment Variables
- Required environment variables
After the CANN package is installed, log in to the environment as the CANN operating user and execute the following environment variables:
source /usr/local/Ascend/cann/set_env.sh/usr/local/Ascend/ is the default installation path for the root user. Replace it with the actual one.
- Optional environment variables
If you want the files generated during program compilation and running to be flushed to a unified directory, you can set the environment variables ASCEND_CACHE_PATH and ASCEND_WORK_PATH to storage paths of shared files and process-exclusive files, respectively.
export ASCEND_CACHE_PATH=/repo/task001/cache export ASCEND_WORK_PATH=/repo/task001/172.16.1.12_01_03
- The environment variables set using export take effect only in the current window. You can add the relevant commands to the environment variable configuration file (for example, the .bashrc file) as required.
- Before setting optional environment variables, run the env command to check whether ASCEND_CACHE_PATH and ASCEND_WORK_PATH exist. It is recommended that all functions use the same planned path.