triton-operator-env-config

Original🇨🇳 Chinese
Translated
1 scriptsChecked / no sensitive code detected

Verify and build the required environment for Triton operator development on the Ascend platform, including configurations of dependencies such as CANN, Python/torch/torch_npu/triton-ascend and PATH environment variables. This is used when users need to configure the Triton operator development environment, check the installation of CANN/torch/triton-ascend, or verify whether the environment is available.

12installs
Added on

NPX Install

npx skill4agent add ascend/agent-skills triton-operator-env-config

SKILL.md Content (Chinese)

View Translation Comparison →

Triton Operator Development Environment Configuration

Core Principles

Environment checks must be performed in order, as each step depends on the success of the previous one.

Prerequisite: Obtain the Latest Matching Requirements (MANDATORY)

Matching versions may be updated, so you must obtain the latest official documentation first.
MANDATORY - READ ENTIRE PAGE: Visit and fully read the official online documentation at https://triton-ascend.readthedocs.io/zh-cn/latest/quick_start.html and https://triton-ascend.readthedocs.io/zh-cn/latest/installation_guide.html to get the latest:
  • Python version requirements
  • torch / torch_npu version requirements
  • triton-ascend version requirements
  • CANN version requirements
  • Version correspondence of each component
Follow the version requirements in the documentation to update the version numbers in subsequent steps.
Currently known version correspondence (as of 2026-03-26):
Triton-Ascend VersionCANN VersionRelease Date
3.2.08.5.0 (Recommended)2026/01/16
3.2.0rc48.3.RC22025/11/20
torch_npu Version: 2.7.1

Environment Check and Configuration Process

1. CANN Environment Configuration (Step 1)

CANN environment check must be done first
  1. Execute
    npu-smi info
    to check if the driver is loaded successfully
  2. Execute
    which bisheng
    to check if the CANN environment is loaded and the npuir compiler is obtained, a path should be output
  3. If there is no output, try loading the CANN environment:
    • Priority:
      source /usr/local/Ascend/cann/set_env.sh
    • Alternative:
      source /usr/local/Ascend/ascend-toolkit/set_env.sh
  4. Perform step 1 and step 2 checks again. If unsuccessful, remind the user to check and resolve the CANN environment configuration, and suggest downloading and installing CANN from https://www.hiascend.com/cann/download

2. Python Version Check

If encountering Python issues, use miniconda to create an environment as the first solution
  1. Check the current Python path:
    which python3
  2. If failed, try executing:
    export PATH="/usr/bin:$PATH"
  3. Perform step 1 check again. If unsuccessful, remind the user to install Python, preferring the miniconda method below
  4. If Python3 exists, check the Python version:
    python3 --version
    , which must comply with the requirements in the official quick_start.md documentation

3. Python Environment Installation (On-Demand)

  1. If the user needs to install a Python environment, first execute
    conda init bash
    to check if a conda environment exists. If yes, jump to step 5; if no, execute step 2 to install
  2. Execute
    uname -m
    to confirm the current system architecture If the system architecture is aarch64, execute:
    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh
    If the system architecture is x86_64, execute:
    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
  3. Execute the installation script:
    bash Miniconda3-latest-Linux-x86_64.sh
    or
    bash Miniconda3-latest-Linux-aarch64.sh
    , activate the miniconda environment after installation as prompted
  4. Check if miniconda is installed successfully:
    conda init bash
  5. Create a Python environment:
    conda create -n triton python=<official required version>
  6. Activate the Python environment:
    conda activate triton

4. torch Configuration

Ensure all previous steps are successful
  1. Execute:
    pip list | grep "torch"
  2. Check the torch / torch_npu versions, which must comply with the requirements in the official documentation
  3. If versions do not meet requirements, install according to the documentation:
    • First install torch:
      pip install torch==<official required version>
    • If encountering the error
      ERROR: No matching distribution found for torch==2.7.1+cpu
      , try:
      bash
      pip install torch==2.7.1+cpu --index-url https://download.pytorch.org/whl/cpu
    • Then install torch_npu:
      pip install torch_npu==<official required version>
  4. Check if the torch environment is configured successfully:
    python3 -c "import torch; print(torch.__version__)"
  5. Run a simple torch code to check if the NPU device is loaded successfully:
    python3 -c "import torch; a = torch.randn(2, 3); print(a)"
    , which should output results similar to:
    tensor([[2.86, 1.0406, 1.5811], [0.8329, 1.0024, 1.3639]])

5. triton-ascend Configuration

  1. Execute:
    pip list | grep "triton"
  2. Community Triton and Triton-Ascend cannot coexist:
    • If native triton is installed, uninstall it first:
      pip uninstall triton
    • If triton-ascend is also installed, uninstall it first, then reinstall
  3. Install the latest triton-ascend package:
    pip install triton-ascend
  4. For installing the nightly version, refer to: https://triton-ascend.readthedocs.io/zh-cn/latest/installation_guide.html#nightly-build

Environment Validation (MANDATORY)

Used to confirm that the current terminal environment can execute Triton operators normally.
MANDATORY - READ ENTIRE FILE: Before performing the validation, you must fully read
scripts/01-vector-add.py
.
Perform validation:
bash
python3 <skill-dir>/scripts/01-vector-add.py
After executing this operator sample, if results similar to the following appear, it indicates that the calculation meets expectations; a difference of 0.0 means the validation is passed:
tensor([0.8329, 1.0024, 1.3639,  ..., 1.0796, 1.0406, 1.5811], device='npu:0')
tensor([0.8329, 1.0024, 1.3639,  ..., 1.0796, 1.0406, 1.5811], device='npu:0')
The maximum difference between torch and triton is 0.0

Troubleshooting

SymptomAction
torch installation failed: No matching distribution found for torch==2.7.1+cpuTry installing from the official PyTorch source:
pip install torch==2.7.1+cpu --index-url https://download.pytorch.org/whl/cpu
Both native triton and triton-ascend are installedUninstall native triton first:
pip uninstall triton
, then reinstall triton-ascend
C++ compiler not foundInstall the compiler:
apt-get install g++
Missing dependencies when compiling from sourceInstall system libraries:
sudo apt install zlib1g-dev clang-15 lld-15
(clang >= 15, lld >= 15 is recommended)
Still failed after retrying according to the above tableKeep complete terminal error messages and the sequence of executed commands for local or subsequent troubleshooting

Anti-Pattern List (NEVER)

  • ❌ Skip reading the official online documentation to obtain the latest matching requirements
  • ❌ Skip CANN environment check and directly configure Python
  • ❌ Use Python / torch versions that do not meet official requirements
  • ❌ Install both native triton and triton-ascend at the same time
  • ❌ Start development without environment validation
  • ❌ Execute steps in different terminal sessions (must be in the same terminal)

Checklist

  • Have you read the official online documentation to obtain the latest matching requirements?
  • Is the CANN environment loaded successfully (output from
    npu-smi info
    and
    which bisheng
    )?
  • Does the Python version meet official requirements?
  • Do the torch / torch_npu versions meet official requirements?
  • Has triton-ascend been installed (native triton has been uninstalled)?
  • Has the environment validation passed (
    01-vector-add.py
    runs successfully)?

Notes