python应用运行报错,部分输出信息如下:WARNING[XFORMERS]: xFormers can’t load C++/CUDA extensions. xFormers was built for:
PyTorch 2.2.2+cu118 with CUDA 1108 (you have 2.2.2+cu121)
Python 3.10.11 (you have 3.10.11)
Please reinstall xformers (see https://github.com/facebookresearch/xformers#installing-xformers)
Memory-efficient attention, SwiGLU, sparse and more won’t be available.
Set XFORMERS_MORE_DETAILS=1 for more details
pip list查看安装的依赖信息,可以看到torch 版本是2.2.2+cu121,xformers版本是0.0.25.post1+cu118,可以看到cuda版本不一样,可以把xformers卸载重装,先
pip uninstall xformers
查看requirements.txt内容xformers要求是0.0.25.post1版本,可以运行如下命令重新安装cuda121版本的xformers:
pip install -U xformers==0.0.25.post1 --index-url https://download.pytorch.org/whl/cu121
成功安装,重新运行没有再报xFormers错误。
xformers/CUDA/pytorch版本关系对照参考文章:《最新xformers/CUDA/pytorch版本关系对照表》