From 0f97bbc8a94aa87588ec4e66f754c8245c8d8c71 Mon Sep 17 00:00:00 2001 From: ffmh Date: Mon, 15 Jun 2026 17:31:12 +0800 Subject: [PATCH] [master] add env config for libtorch_triton_ascend in README MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: ffmh # message auto-generated for no-merge-commit merge: !38296 merge fix_triton_doc into master [master] add env config for libtorch_triton_ascend in README Created-by: ffmh Commit-by: ffmh Merged-by: ascend-robot Description: # 【合入来源】 - [ ] 需求 - [x] 问题单 - [ ] issue/工单 - [ ] 重构优化 - [ ] 资料更新 # 【修改方案】 1. 在 examples/libtorch_triton_ascend/README.md 中新增环境变量配置说明,指导用户配置 libtorch_triton_ascend 运行所需的环境变量 # 【资料变更】 不涉及 # 【接口变更】 不涉及 # 【功能验证】 文档变更,已验证 README.md 中环境变量配置示例的正确性 # 【CheckList】 - [x] 代码注释完备,正确记录错误日志 - [x] 代码实现进行了返回值、空指针等校验 - [x] PR标题正确使用类型标签 docs - [x] PR持续集成流水线(CI)执行通过,代码检查无异常 See merge request: Ascend/pytorch!38296 --- examples/libtorch_triton_ascend/README.md | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/examples/libtorch_triton_ascend/README.md b/examples/libtorch_triton_ascend/README.md index 85c412eeda..156c81e471 100644 --- a/examples/libtorch_triton_ascend/README.md +++ b/examples/libtorch_triton_ascend/README.md @@ -1,5 +1,21 @@ # libtorch_triton_ascend +## 环境约束 + +1)**torch_npu 和 CANN 环境** + +本样例依赖 torch_npu 运行环境,推荐 torch_npu 26.1.0 及配套 CANN 9.1.0 版本。 + +2)**triton-ascend >= 3.2.2** + +在 https://github.com/triton-lang/triton-ascend/releases 获取最新whl包。或拉取[源码](https://github.com/triton-lang/triton-ascend/tree/release/3.2.2-dev)编译,依赖pr https://github.com/triton-lang/triton-ascend/pull/246 + +3)**pybind11** + +```bash +pip install pybind11 +``` + ## 跑demo demo.cpp 包含三个示例: @@ -54,3 +70,19 @@ C++: match: YES ```bash export LOG_TORCH_TRITON_RUNTIME=1 ``` + +## FAQ + +1)**编译报错 unsupported relocation,python环境中没有 libpython\*.so** + +本样例会链接 `libpython*.so`,要求 Python 安装目录下存在该共享库(即 CPython 编译时须启用 `--enable-shared`)。 + +检查方法: + +```bash +ls $(python3 -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")/libpython*.so +``` + +如找不到当前 Python 版本的 `libpython*.so`,或仅有 `libpython*.a` 静态链接库,则可能会产生编译报错。 + +修复方法:使用 `apt install -y python3-dev` 安装python-dev包,或使用Conda创建python环境