我的环境是win10
我正在使用qwen的Qwen/Qwen2.5-VL-7B-Instruct模型,模型跑成功后我希望加快模型的速度,所以考虑使用awq量化的模型版本和开启flash-attn自注意力模式
两种方法在安装都要安装triton,安装后运行时都遇到了Failed to find c compiler. Please specify via cc environment variable错误
从报错看着是缺少c编译器的环境,查询源码发现它可能是需要gcc或clang
# 源码
def _build(name, src, srcdir, library_dirs, include_dirs, libraries):
suffix = sysconfig.get_config_var('EXT_SUFFIX')
so = os.path.join(srcdir, '{name}{suffix}'.format(name=name, suffix=suffix))
# try to avoid setuptools if possible
cc = os.environ.get("CC")
if cc is None:
# TODO: support more things here.
cl = shutil.which("cl")
gcc = shutil.which("gcc")
clang = shutil.which("clang")
cc = cl if cl is not None else gcc if gcc is not None else clang
if cc is None:
raise RuntimeError("Failed to find C compiler. Please specify via CC environment variable.")
...
...
...
安装gcc或clang并配置环境变量后,还是会报错:很多类似undefined reference to `__imp_PyList_Type的错误
查询后说是python环境或gcc/clang的问题,解决未果
最后发现不是gcc和clang的问题,后来查询多篇帖子才知道是triton的问题
有两种triton,一种是能成功安装triton依赖但是不能正常使用的,另一种是能正常使用的,需要安装第二种
我的依赖版本:
Name: triton
Version: 3.0.0
Name: transformers
Version: 4.49.0
Name: autoawq
Version: 0.2.8