Environment Setup
Before developing Ascend C operators, you need to install the Drive, Firmware, and CANN package to set up the environment.
For details about how to install the Driver and Firmware, see section "NPU Driver and Firmware Installation" in CANN Software Installation Guide. This section does not provide installation examples.
This section describes how to install the CANN package as the root user in the training, inference, development, and debugging scenarios where the OS architecture is X86_64. The installation procedures in other scenarios are similar. For details, see CANN Software Installation Guide.
- Install third-party dependencies.
- Ubuntu (The operations are the same for Debian, UOS20, and Linux.)
apt-get install -y gcc g++ make cmake zlib1g zlib1g-dev openssl libsqlite3-dev libssl-dev libffi-dev unzip pciutils net-tools libblas-dev gfortran libblas3
- openEuler (The operations are the same for EulerOS, CentOS, and BC-Linux.)
yum install -y gcc gcc-c++ make cmake unzip zlib-devel libffi-devel openssl-devel pciutils net-tools sqlite-devel lapack-devel gcc-gfortran
- Ubuntu (The operations are the same for Debian, UOS20, and Linux.)
- Install Python.
Run the following commands to check whether a required Python development environment (Python 3.7.5–3.7.11, Python 3.8.0–3.8.11, Python 3.9.0–3.9.7, and Python 3.10.0–3.10.12) is installed:
python3 --version pip3 --version
If the returned information indicates that the Python version requirement is met, directly go to the next step. If the Python version requirement is not met, install Python based on the OS. For details, see "Installing the Development Environment > Installing Dependencies" in CANN Software Installation Guide.
If you need to install PyTorch 2.1.0 or PyTorch 2.2.0 as your AI framework, your Python version must be 3.8.0 to 3.8.11, 3.9.0 to 3.9.7, or 3.10.0 to 3.10.12. Python 3.7.5 to 3.7.11 support PyTorch 1.11.0 only.
- Install related dependencies.
pip3 install attrs numpy decorator sympy cffi pyyaml pathlib2 psutil protobuf scipy requests absl-py wheel typing_extensions
- Install the CANN Toolkit.
- Upload the CANN Toolkit to any directory in the installation environment and run the following command to grant the execute permission on the package:
chmod +x Ascend-cann-toolkit_8.0.R2_linux-x86_64.run - Run the following command to check the consistency and integrity of the package:
./Ascend-cann-toolkit_8.0.R2_linux-x86_64.run --check - Run the following command to install the CANN Toolkit:
./Ascend-cann-toolkit_8.0.R2_linux-x86_64.run --installYou need to sign the Huawei Enterprise End User License Agreement (EULA) before starting the installation process. You can enter y or Y to confirm the agreement based on the command output, or enter any other character to reject the agreement. After you accept the agreement, the installation starts. After the installation is complete, if the following information is displayed, the software is successfully installed:
[INFO] Ascend-cann-toolkit install success
- Configure the CANN environment variables.
source /usr/local/Ascend/ascend-toolkit/set_env.sh
- Upload the CANN Toolkit to any directory in the installation environment and run the following command to grant the execute permission on the package:
- For the development of Ascend C operators, the Driver and Firmware are not required things. For a non-Ascend device, you can use the CPU simulation environment to develop and test operators, and then use the Ascend device to perform accelerated computing. For details about how to install a non-Ascend device, see "Appendix B: Common Operations > Installing CANN on a Non-Ascend Device" in CANN Software Installation Guide.
- When installing third-party dependencies, ensure that the GCC and G++ versions meet the requirements listed in CANN Software Installation Guide.
- To use an Ascend C operator project (kernel launch project or custom operator project), you must install CMake 3.16 or later. The following uses CMake 3.16.0 (Linux, x86_64 architecture) as an example.
mkdir -p cmake-3.16 && wget -qO- "https://cmake.org/files/v3.16/cmake-3.16.0-linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C cmake-3.16 export PATH=`pwd`/cmake-3.16/bin:$PATH