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
Sourceascend/agent-skills
Added on
NPX Install
npx skill4agent add ascend/agent-skills triton-operator-env-configTags
Translated version includes tags in frontmatterSKILL.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 Version | CANN Version | Release Date |
|---|---|---|
| 3.2.0 | 8.5.0 (Recommended) | 2026/01/16 |
| 3.2.0rc4 | 8.3.RC2 | 2025/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
- Execute to check if the driver is loaded successfully
npu-smi info - Execute to check if the CANN environment is loaded and the npuir compiler is obtained, a path should be output
which bisheng - 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
- Priority:
- 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
- Check the current Python path:
which python3 - If failed, try executing:
export PATH="/usr/bin:$PATH" - Perform step 1 check again. If unsuccessful, remind the user to install Python, preferring the miniconda method below
- If Python3 exists, check the Python version: , which must comply with the requirements in the official quick_start.md documentation
python3 --version
3. Python Environment Installation (On-Demand)
- If the user needs to install a Python environment, first execute to check if a conda environment exists. If yes, jump to step 5; if no, execute step 2 to install
conda init bash - Execute to confirm the current system architecture If the system architecture is aarch64, execute:
uname -mIf the system architecture is x86_64, execute:wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.shwget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh - Execute the installation script: or
bash Miniconda3-latest-Linux-x86_64.sh, activate the miniconda environment after installation as promptedbash Miniconda3-latest-Linux-aarch64.sh - Check if miniconda is installed successfully:
conda init bash - Create a Python environment:
conda create -n triton python=<official required version> - Activate the Python environment:
conda activate triton
4. torch Configuration
Ensure all previous steps are successful
- Execute:
pip list | grep "torch" - Check the torch / torch_npu versions, which must comply with the requirements in the official documentation
- If versions do not meet requirements, install according to the documentation:
- First install torch:
pip install torch==<official required version> - If encountering the error , try:
ERROR: No matching distribution found for torch==2.7.1+cpubashpip 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>
- First install torch:
- Check if the torch environment is configured successfully:
python3 -c "import torch; print(torch.__version__)" - Run a simple torch code to check if the NPU device is loaded successfully: , which should output results similar to:
python3 -c "import torch; a = torch.randn(2, 3); print(a)"tensor([[2.86, 1.0406, 1.5811], [0.8329, 1.0024, 1.3639]])
5. triton-ascend Configuration
- Execute:
pip list | grep "triton" - 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
- If native triton is installed, uninstall it first:
- Install the latest triton-ascend package:
pip install triton-ascend - 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.pyPerform validation:
bash
python3 <skill-dir>/scripts/01-vector-add.pyAfter 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.0Troubleshooting
| Symptom | Action |
|---|---|
| torch installation failed: No matching distribution found for torch==2.7.1+cpu | Try installing from the official PyTorch source: |
| Both native triton and triton-ascend are installed | Uninstall native triton first: |
| C++ compiler not found | Install the compiler: |
| Missing dependencies when compiling from source | Install system libraries: |
| Still failed after retrying according to the above table | Keep 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 and
npu-smi info)?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 (runs successfully)?
01-vector-add.py
Notes
- If there are still problems after following the above process, you can check the official online documentation for new matching requirements: https://triton-ascend.readthedocs.io/zh-cn/latest/quick_start.html