145 lines
4.5 KiB
Markdown
145 lines
4.5 KiB
Markdown
---
|
|
title: DiffDock CUDA 12.8 环境安装记录
|
|
date: 2026-05-16
|
|
tags: [DiffDock, CUDA, Python, 分子对接]
|
|
collections: [软件安装]
|
|
summary: 记录 DiffDock CUDA 12.8 环境的源码获取、依赖安装、PyG 扩展编译和推理测试流程。
|
|
draft: false
|
|
featured: false
|
|
---
|
|
|
|
# DiffDock CUDA 12.8 环境安装记录
|
|
|
|
本文记录一次 DiffDock CUDA 12.8 版本的安装过程。实际执行时按自己的环境修改源码仓库、工作目录和模型缓存路径即可。
|
|
|
|
## 准备源码
|
|
|
|
先准备工作目录,并从私有仓库拉取 CUDA 12.8 适配版本。
|
|
|
|
```bash
|
|
WORKDIR="/path/to/software/unpack"
|
|
DIFFDOCK_REPO="ssh://git@private-git-host:port/group/DiffDock_cu128.git"
|
|
|
|
cd "${WORKDIR}"
|
|
git clone "${DIFFDOCK_REPO}"
|
|
cd DiffDock_cu128
|
|
```
|
|
|
|
## 创建 Conda 环境
|
|
|
|
项目仓库中提供了 `environment.yml`,优先使用它创建环境。
|
|
|
|
```bash
|
|
mamba env create -f environment.yml
|
|
mamba activate diffdock
|
|
```
|
|
|
|
如果后续出现 `networkx` 版本不兼容,可按需固定版本。
|
|
|
|
```bash
|
|
python -m pip install networkx==2.8.4
|
|
```
|
|
|
|
## 安装 PyTorch 与 PyG 组件
|
|
|
|
原始安装记录使用了 CUDA 13.0 的 PyTorch/PyG wheel 源来安装部分组件。按当前环境保留如下命令,必要时根据实际 CUDA、PyTorch 版本替换 `cu130`、`torch==2.7.1+cu130` 和 PyG wheel 页面。
|
|
|
|
```bash
|
|
python -m pip install \
|
|
--extra-index-url https://download.pytorch.org/whl/cu130 \
|
|
--find-links https://data.pyg.org/whl/torch-2.7.0+cu130.html \
|
|
torch==2.7.1+cu130 \
|
|
pyg-lib \
|
|
torch-cluster \
|
|
torch-geometric==2.7.0 \
|
|
torch-scatter \
|
|
torch-sparse \
|
|
e3nn==0.5.1 \
|
|
fair-esm==2.0.0 \
|
|
networkx==2.8.4 \
|
|
pandas==1.5.1 \
|
|
pybind11==2.11.1 \
|
|
rdkit==2022.03.3 \
|
|
scikit-learn==1.1.0 \
|
|
"gradio==3.50.*" \
|
|
requests
|
|
```
|
|
|
|
如果只需要补装 `torch-cluster`,可单独执行:
|
|
|
|
```bash
|
|
python -m pip install \
|
|
--extra-index-url https://download.pytorch.org/whl/cu130 \
|
|
--find-links https://data.pyg.org/whl/torch-2.7.0+cu130.html \
|
|
torch-cluster
|
|
```
|
|
|
|
## 固定基础科学计算依赖
|
|
|
|
安装 PyG 扩展前,先固定 `numpy`、`scipy` 和 `biopython` 版本。
|
|
|
|
```bash
|
|
python -m pip install --force-reinstall numpy==1.26.4 scipy==1.12.0 biopython==1.76
|
|
```
|
|
|
|
## 本地编译 PyG 扩展
|
|
|
|
如果预编译 wheel 与运行环境不匹配,可以强制从源码重新编译安装相关扩展。
|
|
|
|
```bash
|
|
python -m pip install --force-reinstall --no-build-isolation --no-binary torch-scatter torch-scatter
|
|
python -m pip install --force-reinstall --no-build-isolation --no-binary torch-sparse torch-sparse
|
|
python -m pip install --force-reinstall --no-build-isolation --no-binary torch-cluster torch-cluster
|
|
python -m pip install --force-reinstall --no-build-isolation --no-binary torch-spline-conv torch-spline-conv
|
|
```
|
|
|
|
编译时如果缺少合适的 C++ 编译器,可安装 `gxx=12`。
|
|
|
|
```bash
|
|
mamba install gxx=12
|
|
```
|
|
|
|
## 安装 OpenFold 相关依赖
|
|
|
|
`dllogger` 和 `openfold` 来自私有 Git 仓库,按实际仓库地址安装即可。
|
|
|
|
```bash
|
|
python -m pip install "dllogger @ git+ssh://git@private-git-host:port/group/dllogger.git@master"
|
|
python -m pip install --no-build-isolation "openfold @ git+ssh://git@private-git-host:port/group/openfold.git@v2.2.0"
|
|
```
|
|
|
|
## 模型缓存
|
|
|
|
推理测试会用到 ESM2 模型文件。可将模型放在当前用户的 Torch Hub 缓存目录,或显式配置到项目支持的模型路径。
|
|
|
|
```text
|
|
~/.cache/torch/hub/checkpoints/esm2_t33_650M_UR50D-contact-regression.pt
|
|
~/.cache/torch/hub/checkpoints/esm2_t33_650M_UR50D.pt
|
|
```
|
|
|
|
## 推理测试
|
|
|
|
安装完成后,可以使用项目自带的示例 CSV 运行一次推理。下面使用相对路径,避免暴露本机环境中的绝对目录。
|
|
|
|
```bash
|
|
python inference.py \
|
|
--config default_inference_args.yaml \
|
|
--protein_ligand_csv data/protein_ligand_example.csv \
|
|
--out_dir results/user_predictions_small
|
|
```
|
|
|
|
如果需要显式指定环境中的 Python,可用占位符路径替换:
|
|
|
|
```bash
|
|
/path/to/miniforge/envs/diffdock/bin/python /path/to/DiffDock_cu128/inference.py \
|
|
--config /path/to/DiffDock_cu128/default_inference_args.yaml \
|
|
--protein_ligand_csv /path/to/DiffDock_cu128/data/protein_ligand_example.csv \
|
|
--out_dir /path/to/DiffDock_cu128/results/user_predictions_small
|
|
```
|
|
|
|
## 检查要点
|
|
|
|
- `torch`、`torch-cluster`、`torch-scatter`、`torch-sparse` 的 CUDA 与 PyTorch ABI 需要一致。
|
|
- 从源码编译 PyG 扩展时,优先确认 `gxx`、CUDA Toolkit、PyTorch 版本是否匹配。
|
|
- 私有仓库地址、内网 IP、用户名、NAS 目录和 Home 目录不应写入公开文章。
|