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 安装包

相关推荐
学测绘的小杨6 小时前
CompassFusion:一个从 GNSS 到 GNSS/INS 组合导航的独立工程包
python
武子康10 小时前
调查研究-191 SenseVoice 不只是 ASR:把语音从“转文字“升级成“理解状态“
人工智能·深度学习·openai
zzzzzz31013 小时前
当产品经理说这个很简单:我用Python自动化处理奇葩需求的实战指南
python·pycharm·产品经理
雪隐13 小时前
个人电脑玩AI-06让5060 Ti给你打工——不光能画画,Qwen3-TTS还能学人说话,连我老板都信了!
人工智能·后端·python
兵慌码乱1 天前
面向桌面端的资产管理系统分层架构设计与核心模块实现
python·系统架构·sqlite·pyqt5·数据库设计·桌面应用开发·mvc架构
hboot1 天前
AI工程师第三课 - 机器学习基础
python·scikit-learn·kaggle
顾林海1 天前
Agent入门阶段-编程基础-Python:流程控制
python·agent·ai编程
呱呱复呱呱1 天前
Django CBV 源码解读:一个请求是怎么找到你的 get() 方法的
python·django
曲幽2 天前
刚部署的 LibreTranslate 频频翻车?我掏出了 20 年前的 StarDict 词典,用 FastAPI 搭了个本地词典翻译 API
python·fastapi·web·translate·goldendict·libretranslate·stardict·pystardict
荣码2 天前
用Streamlit给AI应用套个界面,10行代码出Web页面
java·python