ModuleNotFoundError: No module named ‘triton‘
最近使用Kolmogorov-Arnold Transformation测试程序,代码中有一段引用
from kat_rational import KAT_Group
其中需要
import triton
由于我用的windows系统进行测试,出现了如下问题
Traceback (most recent call last):File "C:/Users/64883/Desktop/Cy/DoubleKATBlock.py", line 4, in <module>from kat_rational import KAT_GroupFile "C:\Users\64883\Desktop\Cy\kat_rational\__init__.py", line 2, in <module>from .kat_1dgroup_triton import RationalTriton1DGroup, KAT_GroupFile "C:\Users\64883\Desktop\Cy\kat_rational\kat_1dgroup_triton.py", line 4, in <module>from .rational_triton import RationalTriton1DGroupFile "C:\Users\64883\Desktop\Cy\kat_rational\rational_triton.py", line 2, in <module>import triton
ModuleNotFoundError: No module named 'triton'
凭着直觉,直接输入了
pip install triton
但是没有成功,出现了如下问题
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
ERROR: Could not find a version that satisfies the requirement triton (from versions: none)
ERROR: No matching distribution found for triton
查了一下资料,发现triton 是 Meta(Facebook)开发的用于高性能深度学习内核编写的库,而目前只有在支持的环境(通常是 Linux + NVIDIA GPU)上才能正确编译和运行。因此在 Windows 上安装和使用 triton 可能会失败或无法使用。
因此,我们只需要将代码上传到Linux系统即可。
额外问题
ImportError: cannot import name 'cached_property' from 'functools' (/home/sys120-1/miniconda3/envs/pyt_3.7/lib/python3.7/functools.py)
解决方法:Python 版本是 3.7,而 functools.cached_property 是从 Python 3.8 才引入的标准库功能。在 Python 3.7 中该属性不存在,导致 triton 加载失败。
AttributeError: module 'triton.language' has no attribute 'fma'
解决方法:说明当前安装的 triton 版本过旧,不支持 tl.fma,升级 Triton 到最新版
pip install --upgrade triton