首先,保证你有nvidia独显
其次,你需要安装一个cuda,最好安装12.4及以前的版本,链接在这https://developer.nvidia.com/cuda-toolkit-archive
然后,请到xformer的github仓库中查看下载方式(不同版本cuda命令不同),链接在这https://github.com/facebookresearch/xformers
我遇到的问题:使用命令pip install xformers[cuda](ChatGPT提供的命令)安装会出现编译错误
解决方法:使用xformer的github提供的命令(注意cuda版本匹配):
pip3 install -U xformers --index-url https://download.pytorch.org/whl/cu124
之后成功安装。