xFormers 安装

系统信息

  • 系统镜像:docker pull nvidia/cuda:12.4.1-cudnn-devel-rockylinux8
  • python 版本:3.11
  • pytorch 版本:2.5.1+cu124

直接安装

pip install xformers==0.0.28.post3 --index-url https://download.pytorch.org/whl/cu124
XFORMERS_MORE_DETAILS=1 python -m xformers.info

源码编译安装

# 下载源码
git clone https://github.com/facebookresearch/xformers.git
cd ./xformers
git checkout v0.0.28.post3
git submodule update --init --recursive

# 安装依赖
yum install -y gcc-toolset-11
pip install ninja
source /opt/rh/gcc-toolset-11/enable

# 编译安装
# 如果编译过程中出现 OOM,请调小 MAX_JOBS 后重试
MAX_JOBS=16 \
  TORCH_CUDA_ARCH_LIST="7.0 7.5 8.0 8.6 9.0" \
  pip wheel \
  -v \
  --no-build-isolation \
  --no-deps \
  .
pip install ./xformers-*-cp311-cp311-linux_x86_64.whl
XFORMERS_MORE_DETAILS=1 python -m xformers.info
Comment