首先是我服务器的初始版本:
python==3.7.4
cuda==12.3
torch(没安装,其实安装过,装openfold总是报错,我就uninstall了,你要是也一直报错,就卸载)
开始安装
这里我需要装的python==3.10,torch==2.2,
第一步:创建一个虚拟环境:
conda create -n openfold python=3.10 -y
conda activate openfold
第二步:升级下pip(可选)
pip install -U pip setuptools wheel
第三步:安装 PyTorch(CUDA12)
CUDA12.3 推荐:
pip install torch torchvision torchaudio \
--index-url https://download.pytorch.org/whl/cu121
安装完成后,验证下是否可用:
python -c "import torch;print(torch.cuda.is_available())"
第四步:安装 OpenFold 依赖
安装基础库:
pip install numpy scipy pandas biopython einops ml-collections
pip install dm-tree modelcif
pip install deepspeed
pip install pytorch-lightning
pip install hydra-core omegaconf
pip install tqdm
pip install requests
pip install ninja
pip install openmm
pip install pdbfixer
第五步:下载 OpenFold
git clone https://github.com/aqlaboratory/openfold.git
cd openfold
第六步:编译 OpenFold CUDA kernel
python setup.py install
但这里就看你会不会报错:
如果报 C++14错误
#error "You're trying to build PyTorch with a too old version of GCC. We need GCC 9 or later."
把setuo.py的-std=c++14改成-std=c++17。
但要求gcc>9,我的cuda的gcc=8.8,所以我就要升级。
网络上是给的命令,我conda安装任何包都会报错:
conda install -c conda-forge gcc=11 gxx=11 -y
(openfold) [qio@vol08 openfold]$ conda install -c conda-forge gcc=11 gxx=11 -y
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): \
所以我改用mamba安装gcc:
首先安装mamba:
conda install -y --channel=https://conda.anaconda.org/conda-forge --channel=https://conda.anaconda.org/pytorch --channel=https://conda.anaconda.org/pyg mamba && conda clean -ya
再用mamba安装gcc11:
mamba install -c conda-forge gcc=11 gxx=11 -y
设置下编译器:
export CC=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-gcc
export CXX=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-g++
第七步:重新编译 OpenFold
先清理:
cd openfold
rm -rf build
rm -rf openfold.egg-info
rm -rf ~/.cache/torch_extensions
第八步:
python setup.py install
最后尝试下安装是否成功:
import openfold
import torch
print(torch.cuda.is_available())