复现StableDiffusion的时候在配置环境遇到xformer的这个报错:
Installing collected packages: xformers
Running setup.py develop for xformers
error: subprocess-exited-with-error
× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [26 lines of output]
running develop
running egg_info
writing xformers.egg-info\PKG-INFO
writing dependency_links to xformers.egg-info\dependency_links.txt
writing requirements to xformers.egg-info\requires.txt
writing top-level names to xformers.egg-info\top_level.txt
reading manifest file 'xformers.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'third_party\flash-attention\version.txt'
warning: manifest_maker: MANIFEST.in, line 13: path 'third_party/flash-attention/csrc/cutlass/docs/' cannot end with '/'
warning: manifest_maker: MANIFEST.in, line 14: path 'third_party/flash-attention/csrc/cutlass/test/' cannot end with '/'
warning: manifest_maker: MANIFEST.in, line 15: path 'third_party/flash-attention/csrc/cutlass/tools/' cannot end with '/'
warning: manifest_maker: MANIFEST.in, line 16: path 'third_party/flash-attention/csrc/cutlass/media/' cannot end with '/'
warning: manifest_maker: MANIFEST.in, line 17: path 'third_party/flash-attention/csrc/cutlass/python/' cannot end with '/'
adding license file 'LICENSE'
writing manifest file 'xformers.egg-info\SOURCES.txt'
running build_ext
···
warnings.warn(f'Error checking compiler version for {compiler}: {error}')
building 'xformers._C' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
解决方法:
安装Microsoft Visual C++ 14.0 or greater
网址如下:
https://visualstudio.microsoft.com/zh-hans/visual-cpp-build-tools/
下载生成工具,之后双击打开 vs_BuildTools.exe
通过win+r,输入winver查看系统版本
我的是这样:
在下载工具勾选
右方勾选兼容的版本即可
解决效果:
Installing collected packages: xformers
Running setup.py develop for xformers
Successfully installed xformers-0.0.25+de5e5b9.d20240215