安装flash-attn失败。ERROR: Could not build wheels for flash-attn,

7,063 阅读1分钟

安装flash-attention2报错

按照官方给出的安装方法报错

完整的报错信息如下:

Building wheels for collected packages: flash-attn
  Building wheel for flash-attn (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [9 lines of output]
      fatal: not a git repository (or any of the parent directories): .git
      
      
      torch.__version__  = 2.0.1+cu118
      
      
      running bdist_wheel
      Guessing wheel URL:  https://github.com/Dao-AILab/flash-attention/releases/download/v2.3.2/flash_attn-2.3.2+cu118torch2.0cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
      error: Remote end closed connection without response
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for flash-attn
  Running setup.py clean for flash-attn
Failed to build flash-attn
ERROR: Could not build wheels for flash-attn, which is required to install pyproject.toml-based projects

这里的报错其实在第16行:没能成功从github拉下whl

原因:国内特殊的网络环境下,访问github不稳定

解决方法:修改hosts文件中githubip地址,使得它能顺利从github上下载文件。

这个报错很有迷惑性,最后一行说需要安装pyproject.toml-based projects很误导人,让人从这里去寻求解决方法,最终无功而返。而且报错很少会想到网络问题

其他

实际上修改host后也不一定能成功下载。还是直接从给出了wheel url下载好安装吧。