第一步:配置显卡驱动
1.安装英伟达显卡的驱动版本(手动配置)
1.1确认你的显卡支持和兼容的CUDA版本
nvidia-smi
注:neuralplexer2要求CUDA>=10.2
1.2CUDA安装
官网链接:
CUDA Toolkit Archive | NVIDIA Developer
并不一定要安装最高的适配版本,因为后续要和PyTorch适配,我这里安装的就是12.1。
#官网指导的安装代码
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.2.1/local_installers/cuda-repo-ubuntu2004-12-2-local_12.2.1-535.86.10-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2004-12-2-local_12.2.1-535.86.10-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2004-12-2-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda
安装过程中安装指示进行即可,安装过程和环境变量的配置可以参考:
[CUDA][cudnn][小白向]ubuntu环境下指定版本安装教程_cuda安装deb local和network-CSDN博客
1.3cudnn安装
官网链接:
cuDNN Archive | NVIDIA Developer
软件的下载和环境配置也可以参考上文的链接,需要注意我的这个路径/usr/local/cuda/就不对,应该是/usr/local/cuda-12.1/,大家需要自行检查一下,按照实际情况修改。
#将以下代码保存为GPU_test.py
import torch
import time
# 创建大张量
size = 10000
x_cpu = torch.randn(size, size)
y_cpu = torch.randn(size, size)
# 在 CPU 上进行矩阵乘法
start_time_cpu = time.time()
z_cpu = torch.mm(x_cpu, y_cpu)
end_time_cpu = time.time()
print("CPU Matrix multiplication took {:.2f} seconds".format(end_time_cpu - start_time_cpu))
# 将张量转移到 GPU
x_gpu = torch.randn(size, size, device='cuda:0')
y_gpu = torch.randn(size, size, device='cuda:0')
# 在 GPU 上进行矩阵乘法
start_time_gpu = time.time()
z_gpu = torch.mm(x_gpu, y_gpu)
end_time_gpu = time.time()
print("GPU Matrix multiplication took {:.2f} seconds".format(end_time_gpu - start_time_gpu))
python GPU_test.py #运行
显示以下结果表示驱动配置成功,可以看到GPU矩阵运算比CPU快很多
2.安装NeuralPLexer2
github链接:
按照作者提示下载模型数据和libmambda(这个可以加速conda,建议安装)
#下载模型数据
wget https://doi.org/10.5281/zenodo.10373581
#我下载很慢,换镜像也没用,最后我是在手机上下载下来传到服务器上的。。。
#conda 22.11 update: The libmamba solver’s experimental flag has been removed. To use the new solver, update conda in your base environment:
conda update -n base conda
#To install and set the new solver, run the following commands:
conda install -n base conda-libmamba-solver
conda config --set solver libmamba
#克隆安装包
git clone https://github.com/zrqiao/NeuralPLexer.git
#配置环境
make environment
#安装包下载
make install
注:
1.安装速度慢可以更改镜像设置或者直接指定镜像:
pip install package-name -i https://pypi.tuna.tsinghua.edu.cn/simple
2.pip clone安装过程中出现报错,直接去github上手动安装即可
3.我在安装安装 openfold时候出现了以下报错
需要配置中使用 cudatoolkit-dev而不是 cudatoolkit,并将 mkl 降级为 mkl=2024.0.0,即可安装成功
#conda install cudatoolkit-dev #我并没有进行该操作
conda install mkl=2024.0.0
也可以直接跳过手动安装的步骤直接使用conda安装 cudatoolkit-dev,只是对应的配置需要调整。
3.运行NeuralPLexer2
3.1.1已知蛋白下载pdb:UniProt
3.1.2未知蛋白预测蛋白结构获得pdb
我目前的问题是,该软件直接输入fasta蛋白序列文件的功能我不能使用,只能利用alphafold3预测完蛋白结构后得到cif文件,再用Chimera转换成pdb文件,有点麻烦,该问题有待解决。
alphafold3官网
https://golgi.sandbox.google.com/
在这里输入蛋白序列文件,下载会得到多个预测的cif文件,选择排序最靠前的就行
Chimera软件用法很简单,打开cif文件,保存为pdb文件即可,Chimera安装官网:
3.2.下载sdf:TCMSP - Traditional Chinese Medicine Systems Pharmacology Database and Analysis Platform (tcmsp-e.com)
注:我这里是中药相关的数据库,其实直接在pubchem cid中搜索就可以:
3.3文件格式修改
#把1.pdb和1.sdf修改一下即可
#uniprot下载的需要预处理,alphafold2预测的不需要
grep ' WITH ' ./1.pdb >> 1.fina.pdb && grep 'CRYST1' ./1.pdb >> 1.fina.pdb && grep 'ATOM' ./1.pdb >> 1.fina.pdb && grep '^TER' ./1.pdb >> 1.fina.pdb && echo 'END' >> 1.fina.pdb
#TCMSP下载需预处理
awk '/END/ {print; exit} {print}' 1.sdf >> 1.fina.sdf && sed -i '1s/.*/5ze6_ligand/' 1.fina.sdf
3.4运行命令
根据作者github上的说明运行命令即可,详见原网站
github链接: