win10下cuda12.1 +troch2.4.1+vs2022环境下编译安装flash-attn

步骤一 下载项目

先下载 https://github.com/Dao-AILab/flash-attention,然后在conda环境中进入项目目录

步骤二 安装依赖项

执行以下命令,安装cutlass库,该库为编译flash-attn的必须依赖

复制代码
conda update --force conda 
conda install conda-forge::cutlass

conda下查找: https://anaconda.org/conda-forge/

步骤三 设置include目录

在flash-attention项目下,setup.py,第300行,添加 "c:/Users/Administrator/miniconda3/Library/include",这里为自己conda环境下的include目录,该命令下有conda安装的库文件,如cutlass。

具体修改效果如下

步骤四 突破vs2022与cuda版本限制

在cuda v12.1\include\crt\host_config.h下,表明不支持vs2022,强制进行编译会输出以下报错

txt 复制代码
error -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022 (inclusive) are supported! The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; however, using an unsupported host compiler may cause compilation failure or incorrect run time execution. Use at your own risk

参考:https://blog.csdn.net/lishiyu93/article/details/114599859,修改_MSC_VER的版本范围 原先是1940,被博主修改成了2940

在C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\include\yvals_core.h中,表明只支持cuda12.4以上的版本,将原来的代码参考 https://blog.csdn.net/weixin_55361556/article/details/141465456 ,修改为 #if __CUDACC_VER_MAJOR__ < 10 || (__CUDACC_VER_MAJOR__ == 10 && __CUDACC_VER_MINOR__ < 1)

步骤五 进行编译

执行 python setup.py build,进行编译

步骤六 生成whl文件

执行python .\setup.py bdist_wheel生成whl文件,命令行输出如下

生成的whl文件在dist目录下

博主编译好的whl文件下载地址: https://download.csdn.net/download/a486259/89839302

步骤七 安装包

执行 pip install .\flash_attn-2.6.3-cp38-cp38-win_amd64.whl 安装包

相关推荐
隔壁大炮4 分钟前
07. PyTorch框架简介
人工智能·pytorch·python
TTBIGDATA6 分钟前
【Atlas】Atlas 搜索时报 `__AtlasUserProfile` 不存在导致事务回滚
开发语言·python·ambari·kerberos·ranger·atlas·bigtop
apcipot_rain8 分钟前
python与人工智能代码基础
人工智能·python·机器学习
Coding茶水间11 分钟前
基于深度学习的鸡数量统计系统演示与介绍(YOLOv12/v11/v8/v5模型+Pyqt5界面+训练代码+数据集)
开发语言·人工智能·深度学习·yolo·目标检测·机器学习
海天一色y18 分钟前
用Python和Pygame从零打造植物大战僵尸:完整技术解析
开发语言·python·pygame
嫂子的姐夫18 分钟前
029-rs5:欧治
爬虫·python·逆向
ppppppatrick20 分钟前
【深度学习基础篇04】从回归到分类:图像分类与卷积神经网络入门
人工智能·深度学习·分类
带娃的IT创业者23 分钟前
STDP+Transformer:当局部可塑性遇见全局语义
人工智能·深度学习·神经网络·transformer·ai智能体·硅基生命·意识编程实现
两万五千个小时25 分钟前
构建mini Claude Code:03 - TodoWrite:让模型按计划执行
人工智能·python
得一录28 分钟前
AI Agent的主流设计模式之工具调用模式
深度学习·aigc