Installation Guide

Installation Description

This document describes how to install the PTO-AS component and deploy the PTOAS tool using the CANN PTO-AS run installation package.

PTOAS is installed together with the PTO-AS component. When you install the PTO-AS component, the installer deploys the PTOAS launcher, runtime dependencies, and the PTOAS wheel, and installs the PTOAS wheel into the shared python/site-packages directory under the CANN version root directory. You do not need to run pip install separately in the current Python environment.

Prerequisites

Before installation, ensure that Python 3.8 or later is installed in the current environment, and obtain the PTO-AS run installation package that matches the current system architecture.

Performing Installation

Go to the directory where the PTO-AS installation package is located and run the installation command.

The following example uses the installation package of version 9.2.0 for the x86_64 architecture:

bash cann-pto-as_9.2.0_linux-x86_64.run --full --install-path=xxx

Where:

  • cann-pto-as_9.2.0_linux-x86_64.run is the name of the PTO-AS installation package. In actual use, use the name of the installation package you obtained.
  • --full indicates that the full mode is used for installation.
  • --install-path=xxx specifies the installation root directory. Replace xxx with the actual installation path.

The installation script supports three installation modes: run, full, and devel. You can specify only one of them for a single installation.

Description

This document uses the full mode as an example and does not elaborate on the differences among the run, full, and devel installation modes.

Configuring the Environment Variables

Using --setenv During Installation

You can use --setenv during installation to configure the environment variables required for running:

bash cann-pto-as_9.2.0_linux-x86_64.run --full --install-path=xxx --setenv

After installation with --setenv, newly opened login/interactive shells automatically load the environment required for running PTO-AS. Currently open shells and non-interactive scenarios such as scripts and CI are not affected, and you still need to manually load the environment as described below.

Not Using --setenv During Installation

If --setenv is not used during installation, you need to manually load the environment variables before using PTO-AS:

source <version_root>/set_env.sh

<version_root> indicates the CANN version root directory.

Default Installation Path

If --install-path is not specified during installation, the default installation root directory is as follows:

  • Regular user: ${HOME}/Ascend
  • root user: /usr/local/Ascend

Other Installation Options

The PTO-AS run installation package also supports the following common options:

  • --install-for-all: installs for all users.
  • --quiet: performs a silent installation, skipping interactive confirmation.
  • --pre-check: performs a pre-installation check.

For example, to perform a pre-installation check:

bash cann-pto-as_9.2.0_linux-x86_64.run --pre-check

Viewing PTOAS Runtime Files

When you install the PTO-AS component, the installer automatically installs the PTOAS wheel and deploys the PTOAS-related runtime files.

In the following, <version_root> indicates the CANN version root directory. In the default layout, <version_root> is <install_path>/cann, and <install_path> is the installation root directory specified by --install-path. You can also directly specify the version directory during installation, and its actual location is subject to the installation result and the environment script.

<version_root>/
├── bin/
│   └── ptoas -> ../tools/ptoas/bin/ptoas
├── python/site-packages/
│   ├── ptoas/
│   ├── ptodsl/
│   └── ...
└── tools/ptoas/
    ├── bin/ptoas
    └── wheels/

tools/ptoas/bin/ptoas is the launcher, and tools/ptoas/wheels stores the wheels deployed with the installation package. The Python packages and their runtime dependencies are deployed in the shared python/site-packages directory instead of a PTOAS-specific Python subdirectory. The installer automatically installs the wheels, so you do not need to install them separately into your current Python environment.

Checking Installation Results

After loading the environment script, verify that the commands and Python packages are available:

command -v ptoas
ptoas --version
python3 -c 'import ptoas; import ptodsl'

The Python import check should use an interpreter compatible with the installed wheel. Continue to use vec_add.pto to verify the actual compilation. In the directory where the example resides, run the following:

ptoas vec_add.pto --pto-arch=a3 --pto-backend=emitc \
  --enable-insert-sync -o vec_add_kernel.cpp

The preceding checks verify the environment, package import, and PTOAS code generation respectively. For the device running process, see Building and Running Examples.

Uninstalling PTO-AS

Use the corresponding run installation package to perform uninstallation:

bash cann-pto-as_9.2.0_linux-x86_64.run --uninstall --install-path=xxx

Here, xxx must be consistent with the installation root directory specified during installation.