ESM をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
本家様 [[https://github.com/facebookresearch/esm>+https:/...
pipy[[https://pypi.org/project/fair-esm/>+https://pypi.or...
Evolutionary Scale Modeling (esm): Pretrained language mo...
#code(nonumber){{
This repository contains code and pre-trained weights for...
including our state-of-the-art ESM-2 and ESMFold, as well...
Transformer protein language models were introduced in th...
(deepL様翻訳)
このリポジトリには、Facebook AI ResearchによるTransformer...
これには、最先端のESM-2やESMFoldに加え、MSA Transformer、...
Transformerタンパク質言語モデルは、論文「Biological struc...
}}
インストール環境はこんな感じ
#code(nonumber){{
[root@r9 ~]# cat /etc/redhat-release
Rocky Linux release 9.7 (Blue Onyx)
[root@r9 ~]# cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX Open Kernel Module for x86_64 ...
GCC version: gcc version 11.5.0 20240719 (Red Hat 11.5.0...
[root@r9 ~]# nvidia-smi -L
GPU 0: NVIDIA RTX PRO 2000 Blackwell (UUID: GPU-40660e37-...
[root@r9 ~]#
}}
blackwellですが、このESMは3年前から更新していない(今時点...
そしてこの修正が正しいのか微妙。なので3年前のGPU、adaと...
***構築開始 [#o8d1dea4]
ここでは[[crYOLO]]のようにpyenv/anacondaの環境を拵えて、...
#code(nonumber){{
git clone https://github.com/yyuu/pyenv.git /apps/pyenv
export PYENV_ROOT=/apps/pyenv
export PATH=$PYENV_ROOT/bin:$PATH
pyenv install miniforge3-26.1.1-3
source /apps/pyenv/versions/miniforge3-26.1.1-3/etc/profi...
conda update conda
(既に環境があるなら)
source /apps/pyenv/versions/miniforge3-26.1.1-3/etc/profi...
}}
あとcuda-toolkit環境も用意します。conda仮想実行環境に含め...
#code(nonumber){{
[root@r9 ~]# dnf localinstall /Public/cuda/cuda-repo-rhel...
[root@r9 ~]# dnf install cuda-toolkit-12-8 -y
[root@r9 ~]# dnf remove cuda-repo-rhel9-12-8-local-12.8.1...
[root@r9 ~]# vi /apps/modulefiles/cuda/12.8
#%Module1.0
set cuda /usr/local/cuda-12.8
setenv CUDA_HOME $cuda
setenv CUDA_PATH $cuda
prepend-path PATH $cuda/bin
prepend-path LD_LIBRARY_PATH $cuda/lib64
prepend-path MANPATH $cuda/share/man
prepend-path LIBRARY_PATH $cuda/lib64
prepend-path CPATH $cuda/include
[root@r9 ~]# module use /apps/modulefiles/
[root@r9 ~]# module load cuda/12.8
[root@r9 ~]# nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2025 NVIDIA Corporation
Built on Fri_Feb_21_20:23:50_PST_2025
Cuda compilation tools, release 12.8, V12.8.93
Build cuda_12.8.r12.8/compiler.35583870_0
[root@r9 ~]#
}}
次に
Githubに「python <= 3.9 and pytorch」とあるので、condaでp...
#code(nonumber){{
[root@r9 ~]# conda create -n ESM python=3.9 numpy matplot...
[root@r9 ~]# conda activate ESM
(ESM) [root@r9 ~]# conda list
:
matplotlib 3.9.4 py39hf3d152...
matplotlib-base 3.9.4 py39h16632d...
munkres 1.1.4 pyhd8ed1ab_...
ncurses 6.6 hdb14827_0 ...
numpy 2.0.2 py39h9cb892...
:
python 3.9.23 hc30ae73_0_...
:
(ESM) [root@r9 ~]#
}}
ここで pytorchは[[https://pytorch.org/get-started/locally...
アーカイブをみると[[https://download.pytorch.org/whl/torc...
使っているGPUはblackwellなので cuda-12.8 以降が前提. ここ...
#code(nonumber){{
(ESM) [root@r9 ~]# pip install "https://download-r2.pytor...
(ESM) [root@r9 ~]# conda list
:
matplotlib 3.9.4 py39hf3d152...
matplotlib-base 3.9.4 py39h16632d...
mpmath 1.3.0 pypi_0 ...
munkres 1.1.4 pyhd8ed1ab_...
ncurses 6.6 hdb14827_0 ...
networkx 3.2.1 pypi_0 ...
numpy 2.0.2 py39h9cb892...
:
python 3.9.23 hc30ae73_0_...
:
torch 2.7.0+cu128 pypi_0 ...
:
(ESM) [root@r9 ~]#
(テスト)
(ESM) [root@r9 ~]# python
Python 3.9.23 | packaged by conda-forge | (main, Jun 4 2...
[GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more...
>>>
>>> import torch
>>> print(torch.cuda.is_available())
True
>>> print(torch.cuda.get_device_name())
NVIDIA RTX PRO 2000 Blackwell
>>>
>>> quit();
(ESM) [root@r9 ~]#
}}
これで下準備は完了
っで
#code(nonumber){{
(ESM) [root@r9 ~]# pip install fair-esm[esmfold]
(ESM) [root@r9 ~]# conda list
:
deepspeed 0.5.9 pypi_0 ...
:
fair-esm 2.0.0 pypi_0 ...
:
(ESM) [root@r9 ~]# pip install 'dllogger @ git+https://gi...
(ESM) [root@r9 ~]# conda list
:
dllogger 1.1.0 pypi_0 ...
:
(ESM) [root@r9 ~]#
}}
ドキュメントとかでは次は「pip install 'openfold @ git+htt...
buildが上手くいかない.
なのでソースを取ってきてソースに修正を加えます
#code(nonumber){{
(ESM) [root@r9 ~]# git clone https://github.com/aqlaborat...
(ESM) [root@r9 ~]# cd openfold
(ESM) [root@r9 openfold]# git checkout 4b41059694619831a7...
}}
そしてちょいと修正します
#code(diff,nonumber){{
diff --git a/openfold/utils/seed.py b/openfold/utils/seed...
index b45b813..76cd788 100644
--- a/openfold/utils/seed.py
+++ b/openfold/utils/seed.py
@@ -2,7 +2,7 @@ import os
import logging
import random
import numpy as np
-from pytorch_lightning.utilities.seed import seed_everyt...
+from lightning_fabric.utilities.seed import seed_everyth...
from openfold.utils.suppress_output import SuppressLogging
diff --git a/setup.py b/setup.py
index 1d5c3a0..ca45408 100644
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,7 @@ version_dependent_macros = [
]
extra_cuda_flags = [
- '-std=c++14',
+ '-std=c++17',
'-maxrregcount=50',
'-U__CUDA_NO_HALF_OPERATORS__',
'-U__CUDA_NO_HALF_CONVERSIONS__',
}}
その上で
#code(nonumber){{
(ESM) [root@r9 openfold]# which nvcc <-- nvcc にPATHが...
/usr/local/cuda-12.8/bin/nvcc
(ESM) [root@r9 openfold]# pip install . --no-build-isolat...
(ESM) [root@r9 openfold]# pip uninstall -y deepspeed
(ESM) [root@r9 openfold]# pip install --no-build-isolatio...
:
deepspeed 0.19.0 pypi_0 ...
:
(ESM) [root@r9 openfold]#
}}
あと一部openfoldで修正箇所があります
deepspeedが 0.5.9 --> 0.19.0 に変更になったためです
#code(diff,nonumber){{
--- /apps/pyenv/versions/miniforge3-26.1.1-3/envs/ESM/lib...
+++ /apps/pyenv/versions/miniforge3-26.1.1-3/envs/ESM/lib...
@@ -195,7 +195,8 @@
d = x.dtype
deepspeed_is_initialized = (
deepspeed_is_installed and
- deepspeed.utils.is_initialized()
+ hasattr(deepspeed, "comm") and
+ deepspeed.comm.is_initialized()
)
if(d is torch.bfloat16 and not deepspeed_is_init...
with torch.cuda.amp.autocast(enabled=False):
@@ -227,7 +228,8 @@
d = t.dtype
deepspeed_is_initialized = (
deepspeed_is_installed and
- deepspeed.utils.is_initialized()
+ hasattr(deepspeed, "comm") and
+ deepspeed.comm.is_initialized()
)
if(d is torch.bfloat16 and not deepspeed_is_initiali...
with torch.cuda.amp.autocast(enabled=False):
}}
ここでテストを実施します
#code(nonumber){{
(ESM) [root@r9 openfold]# python -c "import openfold; pri...
OK
(ESM) [root@r9 openfold]# python -c "from openfold.utils....
CUDA kernel OK
(ESM) [root@r9 openfold]# conda deactivate
[root@r9 ~]#
}}
っで一応完成っぽい
EnvironmentModules
#code(nonumber){{
[root@r9 ~]# vi /apps/modulefiles/ESM
#%Module
module load cuda/12.8
set root /apps/pyenv/versions/miniforge3-26.1....
prepend-path PATH $root/bin
prepend-path LD_LIBRARY_PATH $root/lib
[root@r9 ~]#
}}
使い方としては module load されて、自分のホームディレクト...
&size(10){最近は、自分でconda環境を用意してそこで運用とい...
#code(nonumber){{
[saber@r9 ~]$ git clone https://github.com/facebookresear...
[saber@r9 ~]$ cd ESM/
[saber@r9 ESM]$ ls -lF
total 84
-rw-r--r-- 1 saber saber 268 May 12 23:44 CODE_OF_CONDU...
-rw-r--r-- 1 saber saber 1253 May 12 23:44 CONTRIBUTING.md
-rw-r--r-- 1 saber saber 888 May 12 23:44 environment.yml
drwxr-xr-x 5 saber saber 4096 May 12 23:44 esm/
drwxr-xr-x 7 saber saber 4096 May 12 23:44 examples/
-rw-r--r-- 1 saber saber 1271 May 12 23:44 hubconf.py
-rw-r--r-- 1 saber saber 1088 May 12 23:44 LICENSE
-rw-r--r-- 1 saber saber 132 May 12 23:44 pyproject.toml
-rw-r--r-- 1 saber saber 46320 May 12 23:44 README.md
drwxr-xr-x 3 saber saber 98 May 12 23:44 scripts/
-rw-r--r-- 1 saber saber 1514 May 12 23:44 setup.py
drwxr-xr-x 2 saber saber 173 May 12 23:44 tests/
[saber@r9 ESM]$
}}
っでテスト
#code(nonumber){{
[saber@r9 ESM]$ module load ESM
Loading ESM
Loading requirement: cuda/12.8
[saber@r9 ESM]$
[saber@r9 ESM]$ which python
/apps/pyenv/versions/miniforge3-26.1.1-3/envs/ESM/bin/pyt...
[saber@r9 ESM]$ python -V
Python 3.9.23
[saber@r9 ESM]$ python
Python 3.9.23 | packaged by conda-forge | (main, Jun 4 2...
[GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more...
>>>
>>> import torch
>>> import esm
>>>
>>> model, alphabet = esm.pretrained.esm2_t33_650M_UR50D()
Downloading: "https://dl.fbaipublicfiles.com/fair-esm/mod...
Downloading: "https://dl.fbaipublicfiles.com/fair-esm/reg...
>>>
>>> batch_converter = alphabet.get_batch_converter()
>>> model.eval()
ESM2(
(embed_tokens): Embedding(33, 1280, padding_idx=1)
(layers): ModuleList(
(0-32): 33 x TransformerLayer(
(self_attn): MultiheadAttention(
(k_proj): Linear(in_features=1280, out_features=1...
(v_proj): Linear(in_features=1280, out_features=1...
(q_proj): Linear(in_features=1280, out_features=1...
(out_proj): Linear(in_features=1280, out_features...
(rot_emb): RotaryEmbedding()
)
(self_attn_layer_norm): LayerNorm((1280,), eps=1e-0...
(fc1): Linear(in_features=1280, out_features=5120, ...
(fc2): Linear(in_features=5120, out_features=1280, ...
(final_layer_norm): LayerNorm((1280,), eps=1e-05, e...
)
)
(contact_head): ContactPredictionHead(
(regression): Linear(in_features=660, out_features=1,...
(activation): Sigmoid()
)
(emb_layer_norm_after): LayerNorm((1280,), eps=1e-05, e...
(lm_head): RobertaLMHead(
(dense): Linear(in_features=1280, out_features=1280, ...
(layer_norm): LayerNorm((1280,), eps=1e-05, elementwi...
)
)
>>>
>>>
>>> data = [
... ("protein1", "MKTVRQERLKSIVRILERSKEPVSGAQLAEELSVS...
... ("protein2", "KALTARQQEVFDLIRDHISQTGMPPTRAEIAQRLG...
... ("protein2 with mask","KALTARQQEVFDLIRD<mask>ISQT...
... ("protein3", "K A <mask> I S Q"),
... ]
>>>
>>>
>>> batch_labels, batch_strs, batch_tokens = batch_conver...
>>> batch_lens = (batch_tokens != alphabet.padding_idx).s...
>>>
>>> with torch.no_grad():
... results = model(batch_tokens, repr_layers=[33], r...
...
>>> token_representations = results["representations"][33]
>>>
>>> sequence_representations = []
>>> for i, tokens_len in enumerate(batch_lens):
... sequence_representations.append(token_representat...
...
>>>
>>> import matplotlib.pyplot as plt
>>> for (_, seq), tokens_len, attention_contacts in zip(d...
... plt.matshow(attention_contacts[: tokens_len, : to...
... plt.title(seq)
... plt.show()
}}
ここで画面が表示されます. &size(10){画面を閉じると次の画...
&ref(2022y11m23d_121239900.png,nolink); &ref(2022y11m23d_...
っでさらにテスト
ESMFフォールド構造予測
#code(nonumber){{
[illya@rockylinux ~]$ python
Python 3.9.15 (main, Nov 4 2022, 16:13:54)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more...
>>> import torch
>>> import esm
>>> model = esm.pretrained.esmfold_v1()
Downloading: "https://dl.fbaipublicfiles.com/fair-esm/mod...
Downloading: "https://dl.fbaipublicfiles.com/fair-esm/mod...
Downloading: "https://dl.fbaipublicfiles.com/fair-esm/reg...
>>>
>>>
>>>
>>> exit()
[illya@rockylinux ~]$
}}
***ubuntu24 [#k47bbaa8]
#code(nonumber){{
root@ubuntu24:~# grep VERSION_ID /etc/os-release
VERSION_ID="24.04"
root@ubuntu24:~# cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX Open Kernel Module for x86_64 ...
GCC version: gcc version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~...
root@ubuntu24:~# nvidia-smi -L
GPU 0: NVIDIA RTX PRO 2000 Blackwell (UUID: GPU-40660e37-...
root@ubuntu24:~#
}}
#code(nonumber){{
git clone https://github.com/yyuu/pyenv.git /apps/pyenv
export PYENV_ROOT=/apps/pyenv
export PATH=$PYENV_ROOT/bin:$PATH
pyenv install miniforge3-26.3.2-1
source /apps/pyenv/versions/miniforge3-26.3.2-1/etc/profi...
conda update conda
module load cuda/12.9
conda create -n ESM python=3.9 numpy matplotlib biotite p...
conda activate ESM
pip install https://download-r2.pytorch.org/whl/cu129/tor...
pip install fair-esm[esmfold]
pip install 'dllogger @ git+https://github.com/NVIDIA/dll...
git clone https://github.com/aqlaboratory/openfold.git
cd openfold
git checkout 4b41059694619831a7db195b7e0988fc4ff3a307
vi openfold/utils/seed.py
vi setup.py
pip install . --no-build-isolation --no-use-pep517
pip uninstall -y deepspeed
pip install --no-build-isolation deepspeed
vi /apps/pyenv/versions/miniforge3-26.3.2-1/envs/ESM/lib/...
}}
終了行:
本家様 [[https://github.com/facebookresearch/esm>+https:/...
pipy[[https://pypi.org/project/fair-esm/>+https://pypi.or...
Evolutionary Scale Modeling (esm): Pretrained language mo...
#code(nonumber){{
This repository contains code and pre-trained weights for...
including our state-of-the-art ESM-2 and ESMFold, as well...
Transformer protein language models were introduced in th...
(deepL様翻訳)
このリポジトリには、Facebook AI ResearchによるTransformer...
これには、最先端のESM-2やESMFoldに加え、MSA Transformer、...
Transformerタンパク質言語モデルは、論文「Biological struc...
}}
インストール環境はこんな感じ
#code(nonumber){{
[root@r9 ~]# cat /etc/redhat-release
Rocky Linux release 9.7 (Blue Onyx)
[root@r9 ~]# cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX Open Kernel Module for x86_64 ...
GCC version: gcc version 11.5.0 20240719 (Red Hat 11.5.0...
[root@r9 ~]# nvidia-smi -L
GPU 0: NVIDIA RTX PRO 2000 Blackwell (UUID: GPU-40660e37-...
[root@r9 ~]#
}}
blackwellですが、このESMは3年前から更新していない(今時点...
そしてこの修正が正しいのか微妙。なので3年前のGPU、adaと...
***構築開始 [#o8d1dea4]
ここでは[[crYOLO]]のようにpyenv/anacondaの環境を拵えて、...
#code(nonumber){{
git clone https://github.com/yyuu/pyenv.git /apps/pyenv
export PYENV_ROOT=/apps/pyenv
export PATH=$PYENV_ROOT/bin:$PATH
pyenv install miniforge3-26.1.1-3
source /apps/pyenv/versions/miniforge3-26.1.1-3/etc/profi...
conda update conda
(既に環境があるなら)
source /apps/pyenv/versions/miniforge3-26.1.1-3/etc/profi...
}}
あとcuda-toolkit環境も用意します。conda仮想実行環境に含め...
#code(nonumber){{
[root@r9 ~]# dnf localinstall /Public/cuda/cuda-repo-rhel...
[root@r9 ~]# dnf install cuda-toolkit-12-8 -y
[root@r9 ~]# dnf remove cuda-repo-rhel9-12-8-local-12.8.1...
[root@r9 ~]# vi /apps/modulefiles/cuda/12.8
#%Module1.0
set cuda /usr/local/cuda-12.8
setenv CUDA_HOME $cuda
setenv CUDA_PATH $cuda
prepend-path PATH $cuda/bin
prepend-path LD_LIBRARY_PATH $cuda/lib64
prepend-path MANPATH $cuda/share/man
prepend-path LIBRARY_PATH $cuda/lib64
prepend-path CPATH $cuda/include
[root@r9 ~]# module use /apps/modulefiles/
[root@r9 ~]# module load cuda/12.8
[root@r9 ~]# nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2025 NVIDIA Corporation
Built on Fri_Feb_21_20:23:50_PST_2025
Cuda compilation tools, release 12.8, V12.8.93
Build cuda_12.8.r12.8/compiler.35583870_0
[root@r9 ~]#
}}
次に
Githubに「python <= 3.9 and pytorch」とあるので、condaでp...
#code(nonumber){{
[root@r9 ~]# conda create -n ESM python=3.9 numpy matplot...
[root@r9 ~]# conda activate ESM
(ESM) [root@r9 ~]# conda list
:
matplotlib 3.9.4 py39hf3d152...
matplotlib-base 3.9.4 py39h16632d...
munkres 1.1.4 pyhd8ed1ab_...
ncurses 6.6 hdb14827_0 ...
numpy 2.0.2 py39h9cb892...
:
python 3.9.23 hc30ae73_0_...
:
(ESM) [root@r9 ~]#
}}
ここで pytorchは[[https://pytorch.org/get-started/locally...
アーカイブをみると[[https://download.pytorch.org/whl/torc...
使っているGPUはblackwellなので cuda-12.8 以降が前提. ここ...
#code(nonumber){{
(ESM) [root@r9 ~]# pip install "https://download-r2.pytor...
(ESM) [root@r9 ~]# conda list
:
matplotlib 3.9.4 py39hf3d152...
matplotlib-base 3.9.4 py39h16632d...
mpmath 1.3.0 pypi_0 ...
munkres 1.1.4 pyhd8ed1ab_...
ncurses 6.6 hdb14827_0 ...
networkx 3.2.1 pypi_0 ...
numpy 2.0.2 py39h9cb892...
:
python 3.9.23 hc30ae73_0_...
:
torch 2.7.0+cu128 pypi_0 ...
:
(ESM) [root@r9 ~]#
(テスト)
(ESM) [root@r9 ~]# python
Python 3.9.23 | packaged by conda-forge | (main, Jun 4 2...
[GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more...
>>>
>>> import torch
>>> print(torch.cuda.is_available())
True
>>> print(torch.cuda.get_device_name())
NVIDIA RTX PRO 2000 Blackwell
>>>
>>> quit();
(ESM) [root@r9 ~]#
}}
これで下準備は完了
っで
#code(nonumber){{
(ESM) [root@r9 ~]# pip install fair-esm[esmfold]
(ESM) [root@r9 ~]# conda list
:
deepspeed 0.5.9 pypi_0 ...
:
fair-esm 2.0.0 pypi_0 ...
:
(ESM) [root@r9 ~]# pip install 'dllogger @ git+https://gi...
(ESM) [root@r9 ~]# conda list
:
dllogger 1.1.0 pypi_0 ...
:
(ESM) [root@r9 ~]#
}}
ドキュメントとかでは次は「pip install 'openfold @ git+htt...
buildが上手くいかない.
なのでソースを取ってきてソースに修正を加えます
#code(nonumber){{
(ESM) [root@r9 ~]# git clone https://github.com/aqlaborat...
(ESM) [root@r9 ~]# cd openfold
(ESM) [root@r9 openfold]# git checkout 4b41059694619831a7...
}}
そしてちょいと修正します
#code(diff,nonumber){{
diff --git a/openfold/utils/seed.py b/openfold/utils/seed...
index b45b813..76cd788 100644
--- a/openfold/utils/seed.py
+++ b/openfold/utils/seed.py
@@ -2,7 +2,7 @@ import os
import logging
import random
import numpy as np
-from pytorch_lightning.utilities.seed import seed_everyt...
+from lightning_fabric.utilities.seed import seed_everyth...
from openfold.utils.suppress_output import SuppressLogging
diff --git a/setup.py b/setup.py
index 1d5c3a0..ca45408 100644
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,7 @@ version_dependent_macros = [
]
extra_cuda_flags = [
- '-std=c++14',
+ '-std=c++17',
'-maxrregcount=50',
'-U__CUDA_NO_HALF_OPERATORS__',
'-U__CUDA_NO_HALF_CONVERSIONS__',
}}
その上で
#code(nonumber){{
(ESM) [root@r9 openfold]# which nvcc <-- nvcc にPATHが...
/usr/local/cuda-12.8/bin/nvcc
(ESM) [root@r9 openfold]# pip install . --no-build-isolat...
(ESM) [root@r9 openfold]# pip uninstall -y deepspeed
(ESM) [root@r9 openfold]# pip install --no-build-isolatio...
:
deepspeed 0.19.0 pypi_0 ...
:
(ESM) [root@r9 openfold]#
}}
あと一部openfoldで修正箇所があります
deepspeedが 0.5.9 --> 0.19.0 に変更になったためです
#code(diff,nonumber){{
--- /apps/pyenv/versions/miniforge3-26.1.1-3/envs/ESM/lib...
+++ /apps/pyenv/versions/miniforge3-26.1.1-3/envs/ESM/lib...
@@ -195,7 +195,8 @@
d = x.dtype
deepspeed_is_initialized = (
deepspeed_is_installed and
- deepspeed.utils.is_initialized()
+ hasattr(deepspeed, "comm") and
+ deepspeed.comm.is_initialized()
)
if(d is torch.bfloat16 and not deepspeed_is_init...
with torch.cuda.amp.autocast(enabled=False):
@@ -227,7 +228,8 @@
d = t.dtype
deepspeed_is_initialized = (
deepspeed_is_installed and
- deepspeed.utils.is_initialized()
+ hasattr(deepspeed, "comm") and
+ deepspeed.comm.is_initialized()
)
if(d is torch.bfloat16 and not deepspeed_is_initiali...
with torch.cuda.amp.autocast(enabled=False):
}}
ここでテストを実施します
#code(nonumber){{
(ESM) [root@r9 openfold]# python -c "import openfold; pri...
OK
(ESM) [root@r9 openfold]# python -c "from openfold.utils....
CUDA kernel OK
(ESM) [root@r9 openfold]# conda deactivate
[root@r9 ~]#
}}
っで一応完成っぽい
EnvironmentModules
#code(nonumber){{
[root@r9 ~]# vi /apps/modulefiles/ESM
#%Module
module load cuda/12.8
set root /apps/pyenv/versions/miniforge3-26.1....
prepend-path PATH $root/bin
prepend-path LD_LIBRARY_PATH $root/lib
[root@r9 ~]#
}}
使い方としては module load されて、自分のホームディレクト...
&size(10){最近は、自分でconda環境を用意してそこで運用とい...
#code(nonumber){{
[saber@r9 ~]$ git clone https://github.com/facebookresear...
[saber@r9 ~]$ cd ESM/
[saber@r9 ESM]$ ls -lF
total 84
-rw-r--r-- 1 saber saber 268 May 12 23:44 CODE_OF_CONDU...
-rw-r--r-- 1 saber saber 1253 May 12 23:44 CONTRIBUTING.md
-rw-r--r-- 1 saber saber 888 May 12 23:44 environment.yml
drwxr-xr-x 5 saber saber 4096 May 12 23:44 esm/
drwxr-xr-x 7 saber saber 4096 May 12 23:44 examples/
-rw-r--r-- 1 saber saber 1271 May 12 23:44 hubconf.py
-rw-r--r-- 1 saber saber 1088 May 12 23:44 LICENSE
-rw-r--r-- 1 saber saber 132 May 12 23:44 pyproject.toml
-rw-r--r-- 1 saber saber 46320 May 12 23:44 README.md
drwxr-xr-x 3 saber saber 98 May 12 23:44 scripts/
-rw-r--r-- 1 saber saber 1514 May 12 23:44 setup.py
drwxr-xr-x 2 saber saber 173 May 12 23:44 tests/
[saber@r9 ESM]$
}}
っでテスト
#code(nonumber){{
[saber@r9 ESM]$ module load ESM
Loading ESM
Loading requirement: cuda/12.8
[saber@r9 ESM]$
[saber@r9 ESM]$ which python
/apps/pyenv/versions/miniforge3-26.1.1-3/envs/ESM/bin/pyt...
[saber@r9 ESM]$ python -V
Python 3.9.23
[saber@r9 ESM]$ python
Python 3.9.23 | packaged by conda-forge | (main, Jun 4 2...
[GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more...
>>>
>>> import torch
>>> import esm
>>>
>>> model, alphabet = esm.pretrained.esm2_t33_650M_UR50D()
Downloading: "https://dl.fbaipublicfiles.com/fair-esm/mod...
Downloading: "https://dl.fbaipublicfiles.com/fair-esm/reg...
>>>
>>> batch_converter = alphabet.get_batch_converter()
>>> model.eval()
ESM2(
(embed_tokens): Embedding(33, 1280, padding_idx=1)
(layers): ModuleList(
(0-32): 33 x TransformerLayer(
(self_attn): MultiheadAttention(
(k_proj): Linear(in_features=1280, out_features=1...
(v_proj): Linear(in_features=1280, out_features=1...
(q_proj): Linear(in_features=1280, out_features=1...
(out_proj): Linear(in_features=1280, out_features...
(rot_emb): RotaryEmbedding()
)
(self_attn_layer_norm): LayerNorm((1280,), eps=1e-0...
(fc1): Linear(in_features=1280, out_features=5120, ...
(fc2): Linear(in_features=5120, out_features=1280, ...
(final_layer_norm): LayerNorm((1280,), eps=1e-05, e...
)
)
(contact_head): ContactPredictionHead(
(regression): Linear(in_features=660, out_features=1,...
(activation): Sigmoid()
)
(emb_layer_norm_after): LayerNorm((1280,), eps=1e-05, e...
(lm_head): RobertaLMHead(
(dense): Linear(in_features=1280, out_features=1280, ...
(layer_norm): LayerNorm((1280,), eps=1e-05, elementwi...
)
)
>>>
>>>
>>> data = [
... ("protein1", "MKTVRQERLKSIVRILERSKEPVSGAQLAEELSVS...
... ("protein2", "KALTARQQEVFDLIRDHISQTGMPPTRAEIAQRLG...
... ("protein2 with mask","KALTARQQEVFDLIRD<mask>ISQT...
... ("protein3", "K A <mask> I S Q"),
... ]
>>>
>>>
>>> batch_labels, batch_strs, batch_tokens = batch_conver...
>>> batch_lens = (batch_tokens != alphabet.padding_idx).s...
>>>
>>> with torch.no_grad():
... results = model(batch_tokens, repr_layers=[33], r...
...
>>> token_representations = results["representations"][33]
>>>
>>> sequence_representations = []
>>> for i, tokens_len in enumerate(batch_lens):
... sequence_representations.append(token_representat...
...
>>>
>>> import matplotlib.pyplot as plt
>>> for (_, seq), tokens_len, attention_contacts in zip(d...
... plt.matshow(attention_contacts[: tokens_len, : to...
... plt.title(seq)
... plt.show()
}}
ここで画面が表示されます. &size(10){画面を閉じると次の画...
&ref(2022y11m23d_121239900.png,nolink); &ref(2022y11m23d_...
っでさらにテスト
ESMFフォールド構造予測
#code(nonumber){{
[illya@rockylinux ~]$ python
Python 3.9.15 (main, Nov 4 2022, 16:13:54)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more...
>>> import torch
>>> import esm
>>> model = esm.pretrained.esmfold_v1()
Downloading: "https://dl.fbaipublicfiles.com/fair-esm/mod...
Downloading: "https://dl.fbaipublicfiles.com/fair-esm/mod...
Downloading: "https://dl.fbaipublicfiles.com/fair-esm/reg...
>>>
>>>
>>>
>>> exit()
[illya@rockylinux ~]$
}}
***ubuntu24 [#k47bbaa8]
#code(nonumber){{
root@ubuntu24:~# grep VERSION_ID /etc/os-release
VERSION_ID="24.04"
root@ubuntu24:~# cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX Open Kernel Module for x86_64 ...
GCC version: gcc version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~...
root@ubuntu24:~# nvidia-smi -L
GPU 0: NVIDIA RTX PRO 2000 Blackwell (UUID: GPU-40660e37-...
root@ubuntu24:~#
}}
#code(nonumber){{
git clone https://github.com/yyuu/pyenv.git /apps/pyenv
export PYENV_ROOT=/apps/pyenv
export PATH=$PYENV_ROOT/bin:$PATH
pyenv install miniforge3-26.3.2-1
source /apps/pyenv/versions/miniforge3-26.3.2-1/etc/profi...
conda update conda
module load cuda/12.9
conda create -n ESM python=3.9 numpy matplotlib biotite p...
conda activate ESM
pip install https://download-r2.pytorch.org/whl/cu129/tor...
pip install fair-esm[esmfold]
pip install 'dllogger @ git+https://github.com/NVIDIA/dll...
git clone https://github.com/aqlaboratory/openfold.git
cd openfold
git checkout 4b41059694619831a7db195b7e0988fc4ff3a307
vi openfold/utils/seed.py
vi setup.py
pip install . --no-build-isolation --no-use-pep517
pip uninstall -y deepspeed
pip install --no-build-isolation deepspeed
vi /apps/pyenv/versions/miniforge3-26.3.2-1/envs/ESM/lib/...
}}
ページ名:
1