Installing CANN (Online Installation Using pip)

Prerequisites

Before the installation, ensure that the Python environment and pip3 are available. Currently, CANN supports Python 3.7.x to 3.13.x. If the Python version does not meet the requirements, run the following commands to install it:

Debian, Ubuntu, veLinux:
1
sudo apt-get install -y python3 python3-pip
openEuler, CentOS, Kylin, BCLinux, UOS V20, AntOS, AliOS, CTyunOS, CULinux, Tlinux, MTOS, vesselOS:
1
sudo yum install -y python3 python3-pip

If the installation fails, the version does not meet the requirements, or the dynamic library libpython3.x.so is not included, perform the operations in Compiling and Installing Python.

Configuring the Ascend Repository

Configure the Ascend repository. Otherwise, the installation will fail.

pip config set global.extra-index-url https://ascend.devcloud.huaweicloud.com/cann/pypi/simple
pip config set global.trusted-host ascend.devcloud.huaweicloud.com

Installing the Toolkit Development Kit

The CANN Toolkit development kit installed using pip is mainly used to run training and inference services on the framework side. For Toolkit packages in development and debugging scenarios (such as development and compilation of operators, applications, and models), select other installation modes.

  • Ensure that the available space of the installation directory is greater than 10 GB. If this requirement is not met, clear the space or change the installation directory.
  • Both Toolkit and ops must be installed in CANN 8.5.0.
  1. Run the installation command.
    1
    pip install ascend-cann-toolkit==8.5.0
    

    The software package is installed in the <Python path>/site-packages/ascend directory. You can run the pip show ascend-cann-toolkit command to query the specific path of the software package.

  2. Set the environment variable. The following uses installation path ${HOME}/lib/python3.12/site-packages/ascend as an example.
    1
    source ${HOME}/lib/python3.12/site-packages/ascend/cann-8.5.0/set_env.sh
    

    The preceding environment variables take effect only in the current window. You can add the preceding commands to the environment variable configuration file (for example, the .bashrc file) as required.

Installing the ops Operator Package

Before installing the ops operator package, install Toolkit of the matching version in the same path. Currently, the ops operator packages of multiple chips cannot be installed in the same path. You can install Toolkit and ops of different chips in different paths to meet the development and deployment requirements in a multi-chip environment.

Table 1 Installing the ops Operator Package

Product Type

Installation Command

Atlas A3 series

1
pip install ascend-cann-a3-ops==8.5.0

Atlas A2 series

1
pip install ascend-cann-910b-ops==8.5.0

Atlas training series

1
pip install ascend-cann-910-ops==8.5.0

Atlas inference series

1
pip install ascend-cann-310p-ops==8.5.0

Atlas 200I/500 A2 inference series

1
pip install ascend-cann-310b-ops==8.5.0