原始的AlphaFold2需要docker环境,目前我们服务器还没有配置docker,就先用conda环境替代吧。
1.软件下载
git clone https://github.com/kalininalab/alphafold_non_docker.git
wget https://github.com/google-deepmind/alphafold/archive/refs/tags/v2.3.2.tar.gz
tar -zxvf v2.3.2.tar.gz
# 环境配置建议参考alphafold_non_docker里的README.md,特别注意CUDA版本相关的包
conda create -n alphafold2
conda activate alphafold2
conda install -y -c conda-forge openmm=8.0.0 pdbfixer python=3.10 -c conda-forge
conda install nvidia/label/cuda-12.4.0::cuda-toolkit
conda install cudnn=8.9.2.26=cuda12_0 -c nvidia
conda install -y -c bioconda hmmer hhsuite==3.3.0 kalign2 cudnn=8.9
pip install absl-py==1.0.0 biopython==1.79 chex==0.0.7 dm-haiku==0.0.13 dm-tree==0.1.6 immutabledict==2.0.0 ml-collections==0.1.0 numpy==1.22 pandas==1.3.4 protobuf==3.20.1 scipy==1.11.4 tensorflow-cpu==2.9.0
pip3 install --upgrade --no-cache-dir jax==0.4.23 jaxlib==0.4.23+cuda12.cudnn89 -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
# 下载依赖数据库(非常大)
bash alphafold_non_docker/download_db.sh -d database
安装的时候非常混乱,这里给出我的环境,基于CUDA12.4
, 可以直接通过conda
安装:conda env create -f alphafold2.yml
alphafold2.yml(CUDA12.4)name: alphafold2 channels: - bioconda - nvidia - nvidia/label/cuda-12.4.0 - conda-forge - defaults dependencies: - _libgcc_mutex=0.1=conda_forge - _openmp_mutex=4.5=2_gnu - bzip2=1.0.8=h4bc722e_7 - ca-certificates=2024.9.24=h06a4308_0 - cuda-cccl=12.4.99=0 - cuda-command-line-tools=12.4.0=0 - cuda-compiler=12.4.0=0 - cuda-cudart=12.4.99=0 - cuda-cudart-dev=12.4.99=0 - cuda-cudart-static=12.4.99=0 - cuda-cuobjdump=12.4.99=0 - cuda-cupti=12.4.99=0 - cuda-cupti-static=12.4.99=0 - cuda-cuxxfilt=12.4.99=0 - cuda-documentation=12.4.99=0 - cuda-driver-dev=12.4.99=0 - cuda-gdb=12.4.99=0 - cuda-libraries=12.4.0=0 - cuda-libraries-dev=12.4.0=0 - cuda-libraries-static=12.4.0=0 - cuda-nsight=12.4.99=0 - cuda-nsight-compute=12.4.0=0 - cuda-nvcc=12.4.99=0 - cuda-nvdisasm=12.4.99=0 - cuda-nvml-dev=12.4.99=0 - cuda-nvprof=12.4.99=0 - cuda-nvprune=12.4.99=0 - cuda-nvrtc=12.4.99=0 - cuda-nvrtc-dev=12.4.99=0 - cuda-nvrtc-static=12.4.99=0 - cuda-nvtx=12.4.99=0 - cuda-nvvp=12.4.99=0 - cuda-opencl=12.4.99=0 - cuda-opencl-dev=12.4.99=0 - cuda-profiler-api=12.4.99=0 - cuda-sanitizer-api=12.4.99=0 - cuda-toolkit=12.4.0=0 - cuda-tools=12.4.0=0 - cuda-version=12.6=3 - cuda-visual-tools=12.4.0=0 - cudnn=8.9.2.26=cuda12_0 - gds-tools=1.9.0.20=0 - hhsuite=3.3.0=py310pl5321hc31ed2c_13 - hmmer=3.4=hdbdd923_2 - kalign2=2.04=h031d066_7 - ld_impl_linux-64=2.43=h712a8e2_1 - libblas=3.9.0=24_linux64_openblas - libcblas=3.9.0=24_linux64_openblas - libcublas=12.4.2.65=0 - libcublas-dev=12.4.2.65=0 - libcublas-static=12.4.2.65=0 - libcufft=11.2.0.44=0 - libcufft-dev=11.2.0.44=0 - libcufft-static=11.2.0.44=0 - libcufile=1.9.0.20=0 - libcufile-dev=1.9.0.20=0 - libcufile-static=1.9.0.20=0 - libcurand=10.3.5.119=0 - libcurand-dev=10.3.5.119=0 - libcurand-static=10.3.5.119=0 - libcusolver=11.6.0.99=0 - libcusolver-dev=11.6.0.99=0 - libcusolver-static=11.6.0.99=0 - libcusparse=12.3.0.142=0 - libcusparse-dev=12.3.0.142=0 - libcusparse-static=12.3.0.142=0 - libffi=3.4.2=h7f98852_5 - libgcc=14.2.0=h77fa898_1 - libgcc-ng=14.2.0=h69a702a_1 - libgfortran=14.2.0=h69a702a_1 - libgfortran-ng=14.2.0=h69a702a_1 - libgfortran5=14.2.0=hd5240d6_1 - libgomp=14.2.0=h77fa898_1 - liblapack=3.9.0=24_linux64_openblas - libnpp=12.2.5.2=0 - libnpp-dev=12.2.5.2=0 - libnpp-static=12.2.5.2=0 - libnsl=2.0.1=hd590300_0 - libnvfatbin=12.4.99=0 - libnvfatbin-dev=12.4.99=0 - libnvjitlink=12.4.99=0 - libnvjitlink-dev=12.4.99=0 - libnvjpeg=12.3.1.89=0 - libnvjpeg-dev=12.3.1.89=0 - libnvjpeg-static=12.3.1.89=0 - libopenblas=0.3.27=pthreads_hac2b453_1 - libsqlite=3.46.1=hadc24fc_0 - libstdcxx=14.2.0=hc0a3c3a_1 - libstdcxx-ng=14.2.0=h4852527_1 - libuuid=2.38.1=h0b41bf4_0 - libxcrypt=4.4.36=hd590300_1 - libzlib=1.3.1=hb9d3cd8_2 - ncurses=6.5=he02047a_1 - nsight-compute=2024.1.0.13=0 - ocl-icd=2.3.2=hd590300_1 - ocl-icd-system=1.0.0=1 - openmm=8.0.0=py310h9995159_4 - openssl=3.3.2=hb9d3cd8_0 - pdbfixer=1.9=pyh1a96a4e_0 - perl=5.32.1=0_h5eee18b_perl5 - pip=24.2=pyh8b19718_1 - python=3.10.15=h4a871b0_2_cpython - python_abi=3.10=5_cp310 - readline=8.2=h8228510_1 - setuptools=75.1.0=pyhd8ed1ab_0 - tk=8.6.13=noxft_h4845f30_101 - tzdata=2024b=hc8b5060_0 - wheel=0.44.0=pyhd8ed1ab_0 - xz=5.2.6=h166bdaf_0 - pip: - absl-py==1.0.0 - astunparse==1.6.3 - biopython==1.79 - cachetools==5.5.0 - certifi==2024.8.30 - charset-normalizer==3.4.0 - chex==0.0.7 - contextlib2==21.6.0 - dm-haiku==0.0.13 - dm-tree==0.1.6 - flatbuffers==1.12 - gast==0.4.0 - google-auth==2.35.0 - google-auth-oauthlib==0.4.6 - google-pasta==0.2.0 - grpcio==1.67.0 - h5py==3.12.1 - idna==3.10 - immutabledict==2.0.0 - jax==0.4.23 - jaxlib==0.4.23+cuda12.cudnn89 - jmp==0.0.4 - keras==2.9.0 - keras-preprocessing==1.1.2 - libclang==18.1.1 - markdown==3.7 - markupsafe==3.0.1 - ml-collections==0.1.0 - ml-dtypes==0.5.0 - numpy==1.22.0 - oauthlib==3.2.2 - opt-einsum==3.4.0 - packaging==24.1 - pandas==1.3.4 - protobuf==3.20.1 - pyasn1==0.6.1 - pyasn1-modules==0.4.1 - python-dateutil==2.9.0.post0 - pytz==2024.2 - pyyaml==6.0.2 - requests==2.32.3 - requests-oauthlib==2.0.0 - rsa==4.9 - scipy==1.11.4 - six==1.16.0 - tabulate==0.9.0 - tensorboard==2.9.0 - tensorboard-data-server==0.6.1 - tensorboard-plugin-wit==1.8.1 - tensorflow-cpu==2.9.0 - tensorflow-estimator==2.9.0 - tensorflow-io-gcs-filesystem==0.37.1 - termcolor==2.5.0 - toolz==1.0.0 - typing-extensions==4.12.2 - urllib3==2.2.3 - werkzeug==3.0.4 - wrapt==1.16.0 prefix: /data/chaofan/miniconda3/envs/alphafold2
这个是我之前基于CUDA11.6
的环境:
alphafold2.yml(CUDA11.6)name: alphafold2 channels: - nvidia - conda-forge - bioconda - defaults dependencies: - _libgcc_mutex=0.1=main - _openmp_mutex=5.1=1_gnu - blas=1.0=mkl - ca-certificates=2023.7.22=hbcca054_0 - cuda-nvcc=11.6.124=hbba6d2d_0 - cudatoolkit=11.2.2=hbe64b41_10 - fftw=3.3.9=h27cfd23_1 - hhsuite=3.3.0=py38pl5321h8ded8fe_5 - hmmer=3.3.2=h87f3376_2 - intel-openmp=2021.4.0=h06a4308_3561 - kalign2=2.04=hec16e2b_3 - libedit=3.1.20221030=h5eee18b_0 - libffi=3.2.1=hf484d3e_1007 - libgcc-ng=11.2.0=h1234567_1 - libgomp=11.2.0=h1234567_1 - libnsl=2.0.0=h5eee18b_0 - libstdcxx-ng=11.2.0=h1234567_1 - mkl=2021.4.0=h06a4308_640 - mkl-service=2.4.0=py38h7f8727e_0 - mkl_fft=1.3.1=py38hd3c417c_0 - mkl_random=1.2.2=py38h51133e4_0 - ncurses=6.4=h6a678d5_0 - numpy-base=1.24.3=py38h31eccc5_0 - ocl-icd=2.3.1=h7f98852_0 - ocl-icd-system=1.0.0=1 - openmm=7.5.1=py38ha082873_1 - openssl=1.1.1l=h7f98852_0 - parallel=20230922=ha770c72_0 - pdbfixer=1.7=pyhd3deb0d_0 - perl=5.32.1=0_h5eee18b_perl5 - pip=23.2.1=py38h06a4308_0 - python=3.8.0=h0371630_2 - python_abi=3.8=2_cp38 - readline=7.0=h7b6447c_5 - setuptools=68.0.0=py38h06a4308_0 - six=1.16.0=pyhd3eb1b0_1 - sqlite=3.33.0=h62c20be_0 - tk=8.6.12=h1ccaba5_0 - wheel=0.41.2=py38h06a4308_0 - xz=5.4.2=h5eee18b_0 - zlib=1.2.13=h5eee18b_0 - pip: - absl-py==1.0.0 - alphapulldown==0.30.7 - anyio==4.0.0 - appdirs==1.4.4 - argon2-cffi==23.1.0 - argon2-cffi-bindings==21.2.0 - arrow==1.3.0 - asttokens==2.4.0 - astunparse==1.6.3 - async-lru==2.0.4 - attrs==23.1.0 - babel==2.13.0 - backcall==0.2.0 - beautifulsoup4==4.12.2 - biopython==1.78 - bleach==6.1.0 - cachetools==5.3.1 - certifi==2023.7.22 - cffi==1.16.0 - charset-normalizer==3.3.0 - chex==0.0.7 - comm==0.1.4 - contextlib2==21.6.0 - cycler==0.12.1 - debugpy==1.8.0 - decorator==5.1.1 - defusedxml==0.7.1 - dm-haiku==0.0.9 - dm-tree==0.1.6 - exceptiongroup==1.1.3 - executing==2.0.0 - fastjsonschema==2.18.1 - flatbuffers==1.12 - fqdn==1.5.1 - gast==0.4.0 - google-auth==2.23.2 - google-auth-oauthlib==0.4.6 - google-pasta==0.2.0 - grpcio==1.59.0 - h5py==3.1.0 - idna==3.4 - immutabledict==2.0.0 - importlib-metadata==6.8.0 - importlib-resources==5.8.0 - ipykernel==6.25.2 - ipython==8.12.3 - ipywidgets==8.1.1 - isoduration==20.11.0 - jax==0.3.25 - jaxlib==0.3.25+cuda11.cudnn805 - jedi==0.19.1 - jinja2==3.1.2 - jmp==0.0.4 - json5==0.9.14 - jsonpointer==2.4 - jsonschema==4.19.1 - jsonschema-specifications==2023.7.1 - jupyter-client==8.4.0 - jupyter-core==5.4.0 - jupyter-events==0.7.0 - jupyter-lsp==2.2.0 - jupyter-server==2.7.3 - jupyter-server-terminals==0.4.4 - jupyterlab==4.0.7 - jupyterlab-pygments==0.2.2 - jupyterlab-server==2.25.0 - jupyterlab-widgets==3.0.9 - keras==2.9.0 - keras-preprocessing==1.1.2 - kiwisolver==1.4.5 - libclang==16.0.6 - markdown==3.4.4 - markupsafe==2.1.3 - matplotlib==3.3.3 - matplotlib-inline==0.1.6 - mistune==2.0.5 - ml-collections==0.1.0 - ml-dtypes==0.2.0 - nbclient==0.8.0 - nbconvert==7.4.0 - nbformat==5.4.0 - nest-asyncio==1.5.8 - notebook-shim==0.2.3 - numpy==1.21.6 - oauthlib==3.2.2 - opt-einsum==3.3.0 - overrides==7.4.0 - packaging==23.2 - pandas==1.3.4 - pandocfilters==1.5.0 - parso==0.8.3 - pexpect==4.8.0 - pickleshare==0.7.5 - pillow==10.0.1 - pkgutil-resolve-name==1.3.10 - platformdirs==3.11.0 - prometheus-client==0.17.1 - prompt-toolkit==3.0.39 - protobuf==3.20.1 - psutil==5.9.5 - ptyprocess==0.7.0 - pure-eval==0.2.2 - py3dmol==2.0.1 - pyasn1==0.5.0 - pyasn1-modules==0.3.0 - pycparser==2.21 - pygments==2.16.1 - pyparsing==3.1.1 - python-dateutil==2.8.2 - python-json-logger==2.0.7 - pytz==2023.3.post1 - pyyaml==6.0.1 - pyzmq==25.1.1 - referencing==0.30.2 - requests==2.31.0 - requests-oauthlib==1.3.1 - rfc3339-validator==0.1.4 - rfc3986-validator==0.1.1 - rpds-py==0.10.6 - rsa==4.9 - scipy==1.7.0 - send2trash==1.8.2 - sniffio==1.3.0 - soupsieve==2.5 - stack-data==0.6.3 - tabulate==0.9.0 - tensorboard==2.9.0 - tensorboard-data-server==0.6.1 - tensorboard-plugin-wit==1.8.1 - tensorflow==2.9.0 - tensorflow-cpu==2.9.0 - tensorflow-estimator==2.9.0 - tensorflow-io-gcs-filesystem==0.34.0 - termcolor==2.3.0 - terminado==0.17.1 - tinycss2==1.2.1 - tomli==2.0.1 - toolz==0.12.0 - tornado==6.3.3 - tqdm==4.66.1 - traitlets==5.11.2 - types-python-dateutil==2.8.19.14 - typing-extensions==4.8.0 - uri-template==1.3.0 - urllib3==2.0.6 - wcwidth==0.2.8 - webcolors==1.13 - webencodings==0.5.1 - websocket-client==1.6.4 - werkzeug==3.0.0 - widgetsnbextension==4.0.9 - wrapt==1.15.0 - zipp==3.17.0 prefix: /data/chaofan/software/miniconda3/envs/alphafold2
2.测试
scp alphafold_non_docker/run_alphafold.sh alphafold-2.3.2/
# 修改下相关文件地址
vi alphafold-2.3.2/run_alphafold.sh
#
bash alphafold-2.3.2/run_alphafold.sh -c reduced_dbs -d ./database/ -o ./dummy_test/ -f t2.fa -t 2024-10-17 -m multimer -l 1 -n 40
t2.fa>Pip1 VTEVPNSMDWRKRGSVTGVKDQGVCGCCWAFSAAAAIEGAYQIANNELISLSEQQLLDCSTQNKGCEGGLMTVAYDFLLQNNGGGITTETNYPYEEAQNVCKTEQPAAVTINGYEVVPSDESSLLKAVVNQPISVGIAANDEFHMYGSGIYDGSCNSRLNHAVTVIGYGTSEEDGTKYWIVKNSWGSDWGEEGYMRIARDVGVDGGHCGIAKVASFPTA >EpiC2B QLNGYSKKEVTPEDTELLQKAQSNVSAYNSDVTSRICYLKVDSLETQVVSGENYKFHVSGCSVNSDKELGGCANQNCESSKYDIVIYSQSWTNTLKVTSITPAN
结果与我们之前在CUDA11.6
版本上的一致,也与原文章结果一致。
result{ "iptm+ptm": { "model_1_multimer_v3_pred_0": 0.913495827158252, "model_2_multimer_v3_pred_0": 0.9082750066457126, "model_3_multimer_v3_pred_0": 0.9185924126209433, "model_4_multimer_v3_pred_0": 0.9199507589621323, "model_5_multimer_v3_pred_0": 0.9214059557649581 }, "order": [ "model_5_multimer_v3_pred_0", "model_4_multimer_v3_pred_0", "model_3_multimer_v3_pred_0", "model_1_multimer_v3_pred_0", "model_2_multimer_v3_pred_0" ] }
3.安装过程中遇到的问题
1.
Warning: importing ‘simtk.openmm’ is deprecated. Import ‘openmm’ instead.
Traceback (most recent call last):
File “/data/chaofan/software/alphafold2/alphafold-2.3.2/run_alphafold.py”, line 40, in
from alphafold.relax import relax
File “/data/chaofan/software/alphafold2/alphafold-2.3.2/alphafold/relax/relax.py”, line 18, in
from alphafold.relax import amber_minimize
File “/data/chaofan/software/alphafold2/alphafold-2.3.2/alphafold/relax/amber_minimize.py”, line 33, in
from simtk.openmm.app.internal.pdbstructure import PdbStructure
ModuleNotFoundError: No module named ‘simtk.openmm.app.internal’
2.
Warning: importing ‘simtk.openmm’ is deprecated. Import ‘openmm’ instead.
FATAL Flags parsing error: Unknown command line flag ‘run_relax’
Pass –helpshort or –helpfull to see help on flags.
删掉
run_alphafold.sh
文件中的--run_relax=$run_relax
3.
AttributeError: module ‘jax’ has no attribute ‘xla’
pip install dm-haiku -U
还有一种安装方法,自行配置CUDA驱动,参考非root用户安装cuda与cudnn
,可以装个和alphafold_non_docker
一样的CUDA的版本,配置conda启动时自动替换一些环境变量,可能就没那么麻烦了,这里只提供一种可能的方式,我没有试过。