LINK


(無償)
logo
世界中で使われるISO標準オフィスソフト(MSオフィス互換)
The Document Foundation Wiki

人気の投稿(1ヶ月間)

Ad

Ad

ラベル 分散コンピューティング の投稿を表示しています。 すべての投稿を表示
ラベル 分散コンピューティング の投稿を表示しています。 すべての投稿を表示

2020年4月17日金曜日

【Linux CentOS 7】分散コンピューティングFolding@homeに演算能力を提供する【Folding@home】

FOLDING@HOMEは、分散コンピューティングのプロジェクトの一つである。

このプロジェクトは以前からあり、世界中のPCの処理能力を活用して、
生体タンパク質の立体構造の予測などを行ってきた。
がん、種々の難病など未解明の病気の治療に大いに役立っている。

この度の新型コロナウイルスによるCOVID-19の治療方法の開発には、このウイルスの表面のタンパク質の解析が欠かせない。
今、Folding@homeでも、新型コロナウイルスのタンパク質の解析を行っているところである。
感染症の広がりは急速であり、時間の限られる中、解析には膨大な演算が必要となる。

https://foldingathome.org/covid19/

今、世界中の人々は持っているPCをこの分散コンピューティングプロジェクトに参加させ、演算能力を提供している。
そしてついに100万台のPCがプロジェクトに参加し、1.5エクサフロップスを越えたという。
これは、スーパーコンピューター上位数百台分を優に超える演算能力であるらしい。

早い治療方法の開発を目指して、さらに演算能力を提供したいと思う。

この分散コンピューティングに自分のPCを参加させる方法はとても簡単である。
提供されているソフトウェアをインストールするだけである。
Linux、Windows、MacなどのOSに対応している。
いずれのOSであってもインストールからプロジェクトへの参加は非常に簡単である。

ここでは、Linux(CentOS 7)を搭載したPCにソフトウェアをインストールする方法、
プロジェクトへの参加方法や、さらに設定方法について説明している。

ところで、Raspberry pi など、ARM系のものを持っている方は、
BOINCという分散コンピューティングプラットフォームを利用できる。
https://akira-arets.blogspot.com/2020/04/raspberrypi4-boinc-rosettahome.html
BOINCでは、Rosetta@homeというプロジェクトが同様の解析を行っている。



■インストール(fahclient)

〇パッケージのダウンロード

[root@2b00ba0a011c software]# wget https://download.foldingathome.org/releases/public/release/fahclient/centos-6.7-64bit/v7.5/fahclient-7.5.1-1.x86_64.rpm

[root@2b00ba0a011c software]# ls -all
total 2956
drwxr-xr-x 2 root root      42 Apr 16 03:49 .
dr-xr-x--- 1 root root      43 Apr 16 03:49 ..
-rw-r--r-- 1 root root 3025708 May 31  2018 fahclient-7.5.1-1.x86_64.rpm

〇インストール

[root@2b00ba0a011c software]# rpm -i --nodeps fahclient-7.5.1-1.x86_64.rpm
Starting fahclient ... OK
インストールコマンドを実行すると、自動的にプログラムが起動した。


ところで、終了と開始はそれぞれ次のコマンドで可能である。

CPUの演算能力の提供を停止したい場合
[root@2b00ba0a011c ~]# /etc/init.d/FAHClient stop

再開したい場合
[root@2b00ba0a011c ~]# /etc/init.d/FAHClient start


まずは、次のように動作確認をしてほしい。


■動作の確認

〇動作確認

上記のようにインストールすることによって自動でプログラムが起動した。

[root@2b00ba0a011c ~]# top


写真のように、FAHClient というプロセスを2つ確認することができた。
これらはワークユニットを処理するプロセスではない。
(これらは後で確認するように、互いに開いているTCPポートが異なる。)

インストール直後ではまだ、CPUはアイドル状態であることが確認できた。

しかし、しばらく待ってみると、次のtopコマンドの結果のようにCPU使用率が約50%になった。
(ところで、CPUの稼働を100%にする方法は後述している。)

このとき、FahCore_a7 というコマンドの動作を確認できた。
これにより、Folding@homeが与えたワークユニットに取り組んでいるようだとわかった。

[root@2b00ba0a011c ~]# top
top - 04:07:47 up  1:27,  1 user,  load average: 0.83, 0.74, 0.45
Tasks:  14 total,   2 running,  12 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.0 sy, 48.7 ni, 51.3 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  2046876 total,   665888 free,   345524 used,  1035464 buff/cache
KiB Swap:        0 total,        0 free,        0 used.  1521832 avail Mem
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
  225 fahclie+  39  19  287188 114964   5692 R 100.0  5.6   8:28.21 FahCore_a7

〇プロセスの優先度の確認

上記topコマンドで表示される「ni」というのは、実行優先度が変更されたユーザープロセスについて表している。

まず fahclient というユーザーが存在していることを確認した。

[root@2b00ba0a011c ~]# cat /etc/passwd | grep fahclient
fahclient:x:999:997:Folding@home Client:/var/lib/fahclient:/sbin/nologin

fahclient というユーザーのプロセスの情報を一覧した。

[root@2b00ba0a011c ~]# ps -u fahclient -al
F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
5 S   999   188     1  0  80   0 - 33345 hrtime ?        00:00:01 FAHClient
4 S   999   190   188  0  80   0 - 162960 hrtime ?       00:00:04 FAHClient
4 S   999   221   190  0  99  19 - 31467 hrtime ?        00:00:00 FAHCoreWrapper
4 R   999   225   221 99  99  19 - 71797 -      ?        00:12:31 FahCore_a7
0 R     0   253    95  0  80   0 - 13789 -      pts/0    00:00:00 ps
優先度19というのは優先度が最も低いということである。
(優先度は、-20〜19までの値をとる。-20は最優先を意味する。)


〇ログの確認を行った。

ログを確認することによって処理が進んでいることがわかった。

[root@2b00ba0a011c ~]# tail /var/lib/fahclient/log.txt       
<略>
03:59:20:WU00:FS00:0xa7:Steps: first=8250000 total=250000
03:59:22:WU00:FS00:0xa7:Completed 1 out of 250000 steps (0%)
04:23:09:WU00:FS00:0xa7:Completed 2500 out of 250000 steps (1%)
04:47:04:WU00:FS00:0xa7:Completed 5000 out of 250000 steps (2%)
WU00というのはワークユニット00を表す。ワークユニットの処理が完了すれば、次のワークユニットに処理が移り、番号が増えていく。


以上のように、CentOS 7に、rpmパッケージをダウンロードして、rpmコマンドでインストールすだけで、folding@homeが動作するということがわかった。



■WEBコントロールの利用

インストールしたFahClientパッケージだけで、ブラウザを用いたWEBコントロールを開くことができる。

オリジナル設定ファイルをバックアップしておく。
[root@2b00ba0a011c ~]# cp /etc/fahclient/config.xml /etc/fahclient/config.xml.org


〇WEBポート番号の確認

[root@2b00ba0a011c ~]# netstat -ltup4
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name 
tcp        0      0 0.0.0.0:7396            0.0.0.0:*               LISTEN      190/FAHClient     
tcp        0      0 0.0.0.0:36330           0.0.0.0:*               LISTEN      190/FAHClient     
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      46/sshd             
TCP 7396、TCP 36330 が開いていることがわかる。

そこで、wgetコマンドを用いてHTTPサーバーのポートかどうかを確認した。

[root@2b00ba0a011c ~]# wget 127.0.0.1:7396
--2020-04-16 05:40:54--  http://127.0.0.1:7396/
Connecting to 127.0.0.1:7396... connected.
HTTP request sent, awaiting response... 200 HTTP_OK

Length: 18631 (18K) [text/html]
Saving to: 'index.html'
100%[==============================================================================================================================>] 18,631      --.-K/s   in 0s   
2020-04-16 05:40:55 (183 MB/s) - 'index.html' saved [18631/18631]
このように、index.htmlが取得できたので、
TCP 7396 がHTTPポートだと考えられる。

しかし、外部にあるブラウザから接続しようとしてもアクセス許可がされていないため不可だった。
デフォルト設定ではローカルホストからしかWEBコントロールページにアクセスできない。


〇アクセス許可を設定する。

そこで、次のようにしてアクセスを許可するように促す。

(方法 1)telnetコマンドを用いる方法

・設定ファイルの書き換えを行う。

[root@2b00ba0a011c ~]# telnet localhost 36330
Welcome to the Folding@home Client command server.
Welcome to the Folding@home Client command server.
> option allow 127.0.0.1,192.168.0.0/16,172.16.0.0/12
> option web-allow 127.0.0.1,192.168.0.0/16,172.16.0.0/12
> save
> exit
> Connection closed by foreign host.

(saveコマンドを発行しなくても、しばらく待てば設定ファイルに反映された。)
すると、次のように設定ファイルが書き変わった。

設定ファイルに反映されたかどうかを確認すること。
[root@2b00ba0a011c ~]# cat /etc/fahclient/config.xml
<config>
  <!-- Folding Slot Configuration -->
  <gpu v='false'/>

  <!-- HTTP Server -->
  <allow v='127.0.0.1,192.168.0.0/16,172.16.0.0/12'/>

  <!-- Slot Control -->
  <power v='full'/>

  <!-- User Information -->
  <user v='anonymous'/>

  <!-- Web Server -->
  <web-allow v='127.0.0.1,192.168.0.0/16,172.16.0.0/12'/>

  <!-- Folding Slots -->
  <slot id='0' type='CPU'/>

・再びブラウザからのアクセスを試す

ここで、再び外部からアクセスしようとしたが、403: HTTP_FORBIDDEN となって失敗した。

ログを参照すると、外部のマシン(172.30.1.10)からのアクセスが拒否されていることがわかった。
[root@2b00ba0a011c ~]# less /var/lib/fahclient/log.txt
06:57:48:WARNING:Denied 8:172.30.1.10 access to URI:
設定ファイルに設定が書き込まれたとしても、設定ファイルがロードされなければ設定は有効にはならないのだろう。


・shutdownそして再始動(設定ファイルのロード)

そこで、再びtelnetでアクセスし、次のようにしてshutdownコマンドを送出した。

[root@2b00ba0a011c ~]# telnet localhost 36330
Welcome to the Folding@home Client command server.
Welcome to the Folding@home Client command server.
> shutdown

> Connection closed by foreign host.


shutdownの様子がログファイルに書き込まれていた。

[root@2b00ba0a011c ~]# less /var/lib/fahclient/log.txt
08:21:06:WU00:FS00:0xa7:Completed 27500 out of 250000 steps (11%)
08:23:35:FS00:Shutting core down
08:23:35:WU00:FS00:0xa7:Caught signal SIGINT(2) on PID 528
08:23:35:WU00:FS00:0xa7:Exiting, please wait. . .
08:23:44:WU00:FS00:0xa7:Folding@home Core Shutdown: INTERRUPTED
08:23:44:Clean exit
ログファイルによると、処理が中断されたようである。

しかし、すぐに何もしなくても再びワークユニット(WU00)の処理が開始された。
また、このときログファイルは新しいものに切り替わった。

再開されたことが新しいログファイルから確認できた。
また、設定ファイルが読み込まれたことも確認できた。

中断したワークユニット(WU00)は、下記に示すように、(12%)から再開された。

[root@2b00ba0a011c ~]# less /var/lib/fahclient/log.txt
08:23:47:WU00:FS00:0xa7:Completed 27772 out of 250000 steps (11%) 08:45:18:WU00:FS00:0xa7:Completed 30000 out of 250000 steps (12%)


・外部マシンのブラウザでWEBコントロールページへのアクセスを行った。

アドレス欄に、http://192.168.1.11:7396 と入力してアクセスすればよい。

次のように、WEBコントロールページが表示された。
このとき、ブラウザはFireFoxを用いた。



(以下、先程記述したtelnetでの方法で行っていれば不要)

(方法 2)FAHClientコマンドを用いる方法

ヘルプを確認すると、--send-command というオプションが使えるとわかる。

[root@2b00ba0a011c ~]# FAHClient --help
  --send-command <string>
      Send a command to an already running client.
・同様に、WEBコントロールページへのアクセス許可の設定を行う。

[root@2b00ba0a011c ~]# FAHClient --send-command 'option allow 127.0.0.0/24,192.168.0.0/16,172.16.0.0/12'
06:12:41:INFO(1):Read GPUs.txt
06:12:41:Connecting to 127.0.0.1:36330
[root@2b00ba0a011c ~]# FAHClient --send-command 'option web-allow 127.0.0.0/24,192.168.0.0/16,172.16.0.0/12'
06:14:08:INFO(1):Read GPUs.txt
06:14:08:Connecting to 127.0.0.1:36330
(saveコマンドを発行しなくても、しばらく待てば設定ファイルに反映された。)
[root@2b00ba0a011c ~]# FAHClient --send-command 'save'
06:14:33:INFO(1):Read GPUs.txt
06:14:33:Connecting to 127.0.0.1:36330
設定ファイルに反映されたかどうかを確認しておく。
[root@2b00ba0a011c ~]# cat /etc/fahclient/config.xml


・shutdownそして再始動(設定ファイルのロード)

[root@2b00ba0a011c ~]# FAHClient --send-command 'shutdown'
06:25:22:INFO(1):Read GPUs.txt
06:25:22:Connecting to 127.0.0.1:36330


(方法 3)手動で設定ファイルを書き換える方法

予め、サービスをstopさせておく必要がある。
その上で、設定ファイルを編集し、それから、startを行う。

[root@2b00ba0a011c ~]# /etc/init.d/FAHClient stop
[root@2b00ba0a011c ~]# vi /etc/fahclient/config.xml
[root@2b00ba0a011c ~]# /etc/init.d/FAHClient start



■CPU使用率の調整

〇搭載されたCPU(全コア)の使用率を100%にして処理する。

ただし、複数CPUコアを持つPCでも一つのワークユニットのみを処理する。
(後で述べる方法では、異なるワークユニットをコアごとに割り当てられる。)

次のように、パワーを変更できるコマンドがある。

[root@2b00ba0a011c ~]# FAHClient --help | grep "power"
    battery power.
  power <string=medium>
    Set the client's power level. Valid values are 'light', 'medium' or 'full'.

[root@2b00ba0a011c ~]# telnet localhost 36330
Welcome to the Folding@home Client command server.
> option power full
> save
> exit
> Connection closed by foreign host.

shutdownコマンドなどによる設定ファイルの再読み込みの強制は不要だった。

下記は、2コアCPUを持ったPCでの結果である。(topコマンド起動後、1を押下で表示)
設定をfullに変更した後は、両方のコアの使用率が100%近くになった。

(変更前)
%Cpu0  :  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.0 us,  0.0 sy,100.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st

(変更後)
%Cpu0  :  0.0 us,  0.4 sy, 99.6 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
%Cpu1  :  0.0 us,  0.8 sy, 99.2 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st



〇(複数CPUコアPCの場合)複数のCPUコアに異なるワークユニット割り当て処理させる。

デフォルトでは一つのコアのみがワークユニットを処理していた。
次のように、設定ファイルを編集することで、もう一つのコアも参加させることができた。(2コアのCPUの設定例)

[root@2b00ba0a011c ~]# vi /etc/fahclient/config.xml
<config>
  <!-- Folding Slot Configuration -->
  <gpu v='false'/>

  <!-- HTTP Server -->
  <allow v='127.0.0.1,192.168.0.0/16,172.16.0.0/12'/>

  <!-- Slot Control -->
  <power v='full'/>

  <!-- User Information -->
  <user v='anonymous'/>

  <!-- Web Server -->
  <web-allow v='127.0.0.1,192.168.0.0/16,172.16.0.0/12'/>

  <!-- Folding Slots -->
  <slot id='0' type='CPU'/>
  <slot id='1' type='CPU'/>
</config>

編集の上、既に述べた方法で設定ファイルをロードさせると、
下図のようにWEBコントロールページで、2つのCPUがワークユニットの処理を行っていることが確認できた。


また、ログにおいても、それぞれのCPUが別別にワークユニットを処理していることがわかった。

[root@2b00ba0a011c ~]# tail /var/lib/fahclient/log.txt
06:28:42:WU02:FS01:0xa7:Completed 187702 out of 500000 steps (37%)
06:28:43:WU00:FS00:0xa7:Completed 164642 out of 250000 steps (65%)
06:32:11:WU00:FS00:0xa7:Completed 165000 out of 250000 steps (66%)
06:33:02:WU02:FS01:0xa7:Completed 190000 out of 500000 steps (38%)
06:42:23:WU02:FS01:0xa7:Completed 195000 out of 500000 steps (39%)

topコマンドでは、「99.8 ni」という表示となり、ほぼ100%の使用率となった。
(2つのCPUコアを搭載したマシンのため。)



■終了方法

終了した方法によって、再開方法も異なるので注意すること。

(方法1)
現在実行中のワークユニットが完了してから終了する方法

telnetで接続して、finishコマンドを送る。
[root@2b00ba0a011c ~]# telnet localhost 36330
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Welcome to the Folding@home Client command server.
>
finishコマンドを送信する。

Welcome to the Folding@home Client command server.
>finish
>exit
> Connection closed by foreign host.


ログの確認を行った。

[root@2b00ba0a011c ~]# tail /var/lib/fahclient/log.txt
07:39:39:WU01:FS00:0xa7:Completed 95000 out of 250000 steps (38%)
07:44:28:WU00:FS01:0xa7:Completed 175000 out of 250000 steps (70%)
07:50:46:FS00:Finishing
07:50:46:FS01:Finishing

07:51:59:WU01:FS00:0xa7:Completed 97500 out of 250000 steps (39%)
07:52:50:WU00:FS01:0xa7:Completed 177500 out of 250000 steps (71%)
動作中のワークユニットの全てに対して、finishingと記載されているのがわかった。
それぞれのワークユニットの進捗が100%になるまでは停止しないので注意すること。
(今すぐ、止めてCPUを解放する方法は後述している。ただし、非推奨である。)

数時間後、ワークユニットが完了したとき、次のようなログが記載され、停止状態となった。以後、CPUの使用率も0%の状態のままとなった
省略
19:41:45:WU01:FS00:0xa7:Completed 242500 out of 250000 steps (97%)
19:54:01:WU01:FS00:0xa7:Completed 245000 out of 250000 steps (98%)
20:06:20:WU01:FS00:0xa7:Completed 247500 out of 250000 steps (99%)
20:18:15:WU01:FS00:0xa7:Completed 250000 out of 250000 steps (100%)
20:18:17:WU01:FS00:0xa7:Saving result file ../logfile_01.txt
20:18:17:WU01:FS00:0xa7:Saving result file dhdl.xvg
20:18:17:WU01:FS00:0xa7:Saving result file frame6.trr
20:18:17:WU01:FS00:0xa7:Saving result file md.log
20:18:17:WU01:FS00:0xa7:Saving result file pullf.xvg
20:18:17:WU01:FS00:0xa7:Saving result file pullx.xvg
20:18:17:WU01:FS00:0xa7:Saving result file science.log
20:18:17:WU01:FS00:0xa7:Saving result file traj_comp.xtc
20:18:17:WU01:FS00:0xa7:Folding@home Core Shutdown: FINISHED_UNIT
20:18:18:WU01:FS00:FahCore returned: FINISHED_UNIT (100 = 0x64)
20:18:18:WU01:FS00:Sending unit results: id:01 state:SEND error:NO_ERROR project:***** run:*** clone:0 gen:6 core:0x** unit:0x********************************
20:18:18:WU01:FS00:Uploading 6.41MiB to *.*.*.*
20:18:18:WU01:FS00:Connecting to *.*.*.*:****
20:18:24:WU01:FS00:Upload 30.22%
20:18:30:WU01:FS00:Upload 58.49%
20:18:36:WU01:FS00:Upload 87.74%
20:18:40:WU01:FS00:Upload complete
20:18:40:WU01:FS00:Server responded WORK_ACK (400)
20:18:40:WU01:FS00:Final credit estimate, ****.** points
20:18:41:WU01:FS00:Cleaning up
(再開するには)
この後、再開したい場合は、telnetで同様に接続してから、
shutdownコマンドを送出すれば良かった。

おそらく、finishで停止中の状態にある状態に対してshutdownしているのではないかと思う。
したがって、shutdownすることによって、次の状態へ進めて、処理が再開されると考えることができると思う。



(方法2)
強制的に終了する方法(非推奨である。前述のfinishコマンドを使うこと。)

[root@2b00ba0a011c ~]# /etc/init.d/FAHClient stop

(再開するには)
この場合は、再開したい場合は、次のようにする。
[root@2b00ba0a011c ~]# /etc/init.d/FAHClient start


以上



<参考>

・How To Folding@home: FAHClient config & control manual page
< https://forums.anandtech.com/threads/folding-home-fahclient-config-control-manual-page.2574018/ > 2020年4月16日

・Sending Commands to Running FAHClient [Arch Linux]
< https://foldingforum.org/viewtopic.php?f=88&t=25885 > 2020年4月16日

・oguya/fah-config.xml
< https://gist.github.com/oguya/5924b94c1be6ae9e070d > 2020年4月16日

・3rd party FAHClient API
< https://github.com/FoldingAtHome/fah-control/wiki/3rd-party-FAHClient-API > 2020年4月16日

・Folding@Home: Linux FAHClient Command Line Installation/Usage
< http://jhurani.com/linux/2018/05/11/folding_at_home.html > 2020年4月16日

・Fedora 31にamdgpu-proを(一応)入れてRADEONでFolding@homeを動かす
< https://qiita.com/204504bySE/items/03ca5015ec95190b5e2d > 2020年4月16日

・Folding@Home COMMAND LINE ONLY OPTIONS
< https://foldingathome.org/support/faq/installation-guides/linux/command-line-options/ > 2020年4月16日

・Stop Folding, Complete current WU
< https://foldingforum.org/viewtopic.php?f=61&t=24854 > 2020年4月16日



・Folding@home LINUX
< https://foldingathome.org/support/faq/installation-guides/linux/ > 2020年4月16日

・TERMINAL INSTALLATION FOR REDHAT / CENTOS / FEDORA
< https://foldingathome.org/faqs/installation-guides/linux/manual-installation-optional-advanced/terminal-installation-for-redhat-centos-fedora/ > 2020年4月16日

・TERMINAL INSTALLATION FOR DEBIAN / MINT / UBUNTU
< https://foldingathome.org/faqs/installation-guides/linux/manual-installation-optional-advanced/terminal-installation-for-debian-mint-ubuntu/ > 2020年4月16日

・MANUAL INSTALLATION (ADVANCED)
< https://foldingathome.org/support/faq/installation-guides/linux/manual-installation-advanced/ > 2020年4月16日

・COMMAND LINE ONLY OPTIONS
< https://foldingathome.org/support/faq/installation-guides/linux/command-line-options/ > 2020年4月16日

・fahclient
< https://download.foldingathome.org/releases/public/release/fahclient/centos-6.7-64bit/v7.5/ > 2020年4月16日


https://download.foldingathome.org/releases/public/release/fahclient/centos-6.7-64bit/v7.5/


・Guide how to run Foldathome and FAHControl and contribute to model cures against COVID-19
< https://forum.manjaro.org/t/guide-how-to-run-foldathome-and-fahcontrol-and-contribute-to-model-cures-against-covid-19/132911 > 2020年4月16日

・Folding@home: FAHClient config & control manual page
< https://forums.anandtech.com/threads/folding-home-fahclient-config-control-manual-page.2574018/ > 2020年4月16日

・LTT Folding Team's Emergency Response to Covid-19
< https://linustechtips.com/main/topic/1164541-ltt-folding-teams-emergency-response-to-covid-19/page/522/ > 2020年4月16日

〇GPU
・Contribute to Coronavirus Research with Folding@home
< https://www.rs-online.com/designspark/contribute-to-coronavirus-research-with-foldinghome > 2020年4月16日

〇DOCKER
・What is Folding@Home? What Are They Trying to Do?
< https://www.percona.com/blog/2020/03/20/covid-19-one-way-to-take-action/ > 2020年4月16日

・covperc/fah By covperc
< https://hub.docker.com/r/covperc/fah > 2020年4月16日


・Folding@home
< https://ja.wikipedia.org/wiki/Folding@home > 2020年4月16日

・Sabayon Linux と分散コンピューティング( Folding@home / Rosetta@home )で COVID-19(新型コロナウイルス感染症)に対抗する
< https://qiita.com/EarthSimilarityIndex/items/f938a89b183a695c3d5f > 2020年4月16日

・Folding@homeを動かしてみた
< https://blog.n-z.jp/blog/2020-03-06-foldingathome.html > 2020年4月16日

〇その他
・topコマンドの使い方・見方
< https://linuxserver.jp/linux/topコマンド/ >

・nice - プログラムを実行する優先度を変更 - Linuxコマンド
< https://webkaru.net/linux/nice-command/ > 2020年4月16日

・Linux - topコマンドでCPU使用率をコア単位で表示する方法
< https://qiita.com/makaaso/items/031bf1559d1c6b10e52d > 2020年4月20日


・ウイルスとの戦いがネット上に: Folding@Home が COVID-19 との戦いのために 1.5 エクサフロップスを達成
< https://blogs.nvidia.co.jp/2020/04/09/foldingathome-exaflop-coronavirus/ > 2020年4月17日

・「Folding@home」の演算能力が1.5EFLOPS超え
< https://pc.watch.impress.co.jp/docs/news/1245535.html > 2020年4月17日

2020年4月12日日曜日

【Raspberry pi 4 / Raspbian】分散コンピューティングRosetta@homeに参加してタンパク質の立体構造解析に貢献する【Raspbian】


<はじめに>

Raspberry pi 4 (4GBメモリモデル)にRaspbian等を搭載していれば、
BOINCというシステムを通して、分散コンピューティングプロジェクトに参加できる。

ここでは、上記システムへのBOINCの導入、Rosetta@homeというタンパク質解析のための分散コンピューティングプロジェクトに参加するための手順を説明している。

現時点(11 Apr 2020, 15:01:59 UTC)で、Rosetta@homeの参加者数、ジョブの数は次のようになっている。
Total queued jobs: 2,880,916
In progress: 1,172,305
Successes last 24h: 900,001
Users  (last day ): 1,343,478 (+594)
Hosts  (last day ): 2,770,801 (+9418)


<ウイルスの持つタンパク質>

タンパク質の立体構造を解析することによって、例えば新型コロナウイルスの表面タンパク質の機能を調べることができるようになる。
また、これにより似通った安定したタンパク質を生み出すことができ、新型コロナウイルスの治療に役立つ情報にすることができるようになる。

<タンパク質と遺伝子とアミノ酸>

タンパク質は、遺伝子によって設計されたアミノ酸配列から成り立っている。
しかしこのアミノ酸配列からどのようなタンパク質の立体構造が成り立つかは、スーパーコンピューターによる解析が必要である。
タンパク質の立体構造は何通りにも考えられるので、その中から最も安定な立体構造を検索して、実際のウイルスのタンパク質の構造を予測する必要がある。

<分散コンピューティングとスーパーコンピューター>

分散コンピューティングでは、プロジェクトに参加したPCに小さなタスクを与えて解析してもらう。
その結果、分散コンピューティングでは、スーパーコンピューター並み、それ以上の計算能力を得られる。
分散コンピューティングへの参加者が増えるほど、研究者は仕事を早くできるようになると考えられる。

Rasberry piを持っていなくても、Windows、Linux、Macなどからも分散コンピューティングへの参加は可能である。
たとえば、folding@homeというプロジェクトがあるのでぐぐってみてください。
【Linux CentOS 7】分散コンピューティングFolding@homeに演算能力を提供する【Folding@home】も参考にしてください。


ここでは、Rasberry pi 4 + Raspbian で、タンパク質の分散コンピューティングプロジェクトであるRosetta@homeに参加する方法を扱う。



■ハードウェア要件の確認

ハードウェア要件
・Raspberry pi 4 or 3 (2GB RAM モデル)以上
・SDメモリが充分にあること。

ここでは、Raspberry pi 4(4GB RAM)を用い、OSはRaspbian(デスクトップ機能あり)が動作している。
OSのインストール手順は、次のページを参考にしてください。

【Raspbian Buster September 2019】OSインストールから初期セットアップ(rootユーザー、SSHログイン、システム更新、ヘッドレス運用、microSD丸ごとバックアップ、リストアなど)



■Raspbianを64bitOSに切り替える。

sudo su でrootになって操作した。
あるいは、上記ページを参考にして、rootのパスワードを設定して、suする。
(以下同様とする。)

○config.txtを編集するので、バックアップをとった。

root@raspberrypi:/home/pi# cp /boot/config.txt /boot/config.txt.org


○(設定変更前の)unameの結果を確認した。

root@raspberrypi:/home/pi# uname -a
Linux raspberrypi 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux
「ARMv7l」アーキテクチャ(32bit)として認識していることがわかる。


(参考として)
Raspberry pi 4 or 3 は、「ARMv8」アーキテクチャの64bit CPUを搭載している。
しかし以上の結果のように、現行のRaspbianはRaspberry pi 4 or 3を「ARMv7l」アーキテクチャ(32bit)として認識している。

「ARMv8」は64bitの”AArch64”実行モードと32bitの”AArch32”実行モードを切り替えて動作できるようになっている。
32bitの”AArch32”実行モードは32bitの「ARMv7」(以前のRaspberry pi に搭載)との互換性を維持する。
現行のRaspbianは以前のRaspberry piでも使用されるため、互換性維持のためにRaspberry pi 4 or 3であっても、デフォルトでは32bitの「ARMv7」として認識されると考えられる。

しかし以下のように設定することによって、現行のRaspbianにおいてもRaspberry pi 4 or 3の持つCPUを「ARMv8」アーキテクチャを持つものとして認識する。


○config.txtを編集した。

最後の行にマークしたように1行追加した。

root@raspberrypi:/home/pi# nano /boot/config.txt
# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4
# uncomment for composite PAL
#sdtv_mode=2
#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
[all]
#dtoverlay=vc4-fkms-v3d
arm_64bit=1

・保存した。(ファイル名が表示されるのでそのままエンターで上書きした。)
[CTRL]+O Write Out
File Name to Write: /boot/config.txt
エンターを押す
[ Wrote 67 lines ]
・nanoを終了した。
[CTRL]+X Exit


○設定の有効化のためにラズパイの再起動を行った。

root@raspberrypi:/home/pi# reboot


○再起動後、sshログインし、rootになった。

○(設定変更後の)unameの結果を確認した。

マークしたように64という文字が確認できた。

root@raspberrypi:/home/pi# uname -a
Linux raspberrypi 4.19.75-v8+ #1270 SMP PREEMPT Tue Sep 24 18:59:17 BST 2019 aarch64 GNU/Linux
”AArch64”実行モードで動作している。



■必要なパッケージのインストールと設定

○boincパッケージのインストール

root@raspberrypi:/home/pi# apt-get update
root@raspberrypi:/home/pi# apt-get install boinc-client boinc-manager boinctui
The following additional packages will be installed:
  libboinc7 libwxbase3.0-0v5 libwxgtk-webview3.0-gtk3-0v5 libwxgtk3.0-gtk3-0v5
Suggested packages:
  boinc-client-opencl boinc-client-nvidia-cuda libgl1-mesa-glx
The following NEW packages will be installed:
  boinc-client boinc-manager libboinc7 libwxbase3.0-0v5 libwxgtk-webview3.0-gtk3-0v5 libwxgtk3.0-gtk3-0v5
0 upgraded, 6 newly installed, 0 to remove and 2 not upgraded.
Need to get 6,662 kB of archives.
After this operation, 23.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

○設定ファイルの編集

下記、緑のマーカー部分を追加した。

root@raspberrypi:/home/pi# nano /etc/boinc-client/cc_config.xml
<!--
This is a minimal configuration file cc_config.xml of the BOINC core client.
For a complete list of all available options and logging flags and their
meaning see: https://boinc.berkeley.edu/wiki/client_configuration
-->
<cc_config>
  <log_flags>
    <task>1</task>
    <file_xfer>1</file_xfer>
    <sched_ops>1</sched_ops>
  </log_flags>
  <options>
    <alt_platform>aarch64-unknown-linux-gnu</alt_platform>
  </options>
</cc_config>
もし、他のマシンで動作しているBOINCマネージャやboinctuiから、このマシンをリモートで管理したい場合には、次の設定も、<options>に加えておくとよい。
ただし、セキュリティーに注意が必要である。家庭のLAN内であれば心配ないのではないか。
<allow_remote_gui_rpc>1</allow_remote_gui_rpc>



システムの再起動を行った。

root@raspberrypi:/home/pi# reboot



■BOINC Managerの起動、タスクの稼働状況確認

下記、デスクトップ環境での操作を取り扱っている。
同様のことは、CUI端末において、boinctui コマンドでも可能である。
(ただし、TUIについてはここでは解説していない。)


ディスプレイの接続されていないRaspberry pi 4でも、
設定すればデスクトップにVNCでリモートアクセスすることができる。
下記ページに設定ためのリンクを載せていますので参考にてください。

【Raspbian Buster September 2019】OSインストールから初期セットアップ(rootユーザー、SSHログイン、システム更新、ヘッドレス運用、microSD丸ごとバックアップ、リストアなど)


<解析タスク割り当て前>

○デスクトップのラズベリーアイコンから、BOINC Manager を起動した。

参考画像のように、ラズベリーアイコンから、System Toolsを辿り、
その中に、BOINC Managerを見つけた。

すると、次のようなウインドウが二つ開いた。

カテゴリーと、プロジェクトを選択した。
参加するプロジェクトは、Rosetta@homeである。

警告が出るがそのまま「Yes」をクリックした。

ログインの必要がある。
初めてなので、「No,new user」を選び、
今後ログインで使う自分のメールアドレスを入力、
そして、パスワードを設定した。

自動でブラウザが起動した。
WEBで、先のアカウント情報をRosettaのシステムに登録した。
(WEBのURLにクエリストリングが含まれていることから、自分のメールアドレスと関連づけられているようである。)



つづいて、チームの参加や作成を促されるページも開くが、
今回は参加も作成も行わないようにした。
そのままブラウザを閉じた。

すぐには、タスクが割り当てられなかった。
「No work available to process」という表示が長い間続いた。
そのまま気長に放置しておいた。(Work が与えられるまで気長に待つ必要がある。)


解析タスクが割り当てられるまで何もすることがない。

boinc-client.serviceの稼働状況の確認を行った。

システムは正常に稼働しているようである。
しかしまだ、タンパク質解析のためのタスクが与えられていない状態だとわかった。

root@raspberrypi:/home/pi# systemctl status boinc-client
● boinc-client.service - Berkeley Open Infrastructure Network Computing Client
   Loaded: loaded (/lib/systemd/system/boinc-client.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-04-11 09:33:50 JST; 28s ago
     Docs: man:boinc(1)
 Main PID: 5087 (boinc)
    Tasks: 2 (limit: 4261)
   Memory: 2.9M
   CGroup: /system.slice/boinc-client.service
           └─5087 /usr/bin/boinc
Apr 11 09:33:50 raspberrypi boinc[5087]: dir_open: Could not open directory 'slots' from '/var/lib/boinc-client'.
Apr 11 09:33:50 raspberrypi boinc[5087]: 11-Apr-2020 09:33:50 [---] Checking active tasks
Apr 11 09:33:50 raspberrypi boinc[5087]: 11-Apr-2020 09:33:50 [---] Setting up GUI RPC socket
Apr 11 09:33:50 raspberrypi boinc[5087]: 11-Apr-2020 09:33:50 [---] gui_rpc_auth.cfg is empty - no GUI RPC password protection
Apr 11 09:33:50 raspberrypi boinc[5087]: 11-Apr-2020 09:33:50 [---] Checking presence of 0 project files
Apr 11 09:33:50 raspberrypi boinc[5087]: 11-Apr-2020 09:33:50 Initialization completed
Apr 11 09:33:50 raspberrypi boinc[5087]: 11-Apr-2020 09:33:50 [Rosetta@home] Sending scheduler request: To fetch work.
Apr 11 09:33:50 raspberrypi boinc[5087]: 11-Apr-2020 09:33:50 [Rosetta@home] Requesting new tasks for CPU
Apr 11 09:33:53 raspberrypi boinc[5087]: 11-Apr-2020 09:33:53 [Rosetta@home] Scheduler request completed: got 0 new tasks
Apr 11 09:33:53 raspberrypi boinc[5087]: 11-Apr-2020 09:33:53 [Rosetta@home] No tasks sent

<解析タスク割り当て後>
後程、タスクが割り当てられ、次のように確認できた。

後程、見てみると、解析中になっていることがわかった。


Advanced View表示をした。

ところで、このBOINC マネージャーがフリーズすることがあったので、
その場合は、次のようにプロセス番号を調べて、番号を指定してkillすればよかった。

root@raspberrypi:/home/pi# ps -u myusername | grep boincmgr
12345 ?        00:00:03 boincmgr
root@raspberrypi:/home/pi# kill 12345


さて、タンパク質の解析中の場合は以下の表示となった。

root@raspberrypi:/home/pi# systemctl status boinc-client
● boinc-client.service - Berkeley Open Infrastructure Network Computing Client
   Loaded: loaded (/lib/systemd/system/boinc-client.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2020-04-11 09:33:50 JST; 13h ago
     Docs: man:boinc(1)
 Main PID: 5087 (boinc)
    Tasks: 11 (limit: 4261)
   Memory: 3.0G
   CGroup: /system.slice/boinc-client.service
           ├─1222 ../../projects/boinc.bakerlab.org_rosetta/rosetta_for_devices_4.12_aarch64-unknown-linux-gnu -run:protocol jd2_scripting -parser:protocol predicto
           ├─1464 ../../projects/boinc.bakerlab.org_rosetta/rosetta_for_devices_4.12_aarch64-unknown-linux-gnu -run:protocol jd2_scripting @flags_rb_04_11_21136_207
           ├─4110 ../../projects/boinc.bakerlab.org_rosetta/rosetta_for_devices_4.12_aarch64-unknown-linux-gnu -run:protocol jd2_scripting @flags_rb_04_11_21136_207
           └─5087 /usr/bin/boinc
Apr 11 22:27:28 raspberrypi boinc[5087]: 11-Apr-2020 22:27:28 [Rosetta@home] Started upload of *****_Junior_HalfRoid_vs_COVID-19_design1_dev_SAVE_ALL_OUT_NOJRAN_
Apr 11 22:27:34 raspberrypi boinc[5087]: 11-Apr-2020 22:27:34 [Rosetta@home] Finished upload of *****_Junior_HalfRoid_vs_COVID-19_design1_dev_SAVE_ALL_OUT_NOJRAN
Apr 11 22:50:05 raspberrypi boinc[5087]: 11-Apr-2020 22:50:05 [Rosetta@home] Sending scheduler request: To report completed tasks.
Apr 11 22:50:05 raspberrypi boinc[5087]: 11-Apr-2020 22:50:05 [Rosetta@home] Reporting 4 completed tasks
Apr 11 22:50:05 raspberrypi boinc[5087]: 11-Apr-2020 22:50:05 [Rosetta@home] Requesting new tasks for CPU
Apr 11 22:50:07 raspberrypi boinc[5087]: 11-Apr-2020 22:50:07 [Rosetta@home] Scheduler request completed: got 1 new tasks
Apr 11 22:50:09 raspberrypi boinc[5087]: 11-Apr-2020 22:50:09 [Rosetta@home] Started download of *****_Junior_HalfRoid_vs_COVID-19_design1_dev.zip
Apr 11 22:50:09 raspberrypi boinc[5087]: 11-Apr-2020 22:50:09 [Rosetta@home] Started download of *****_Junior_HalfRoid_vs_COVID-19_design1_dev.flags
Apr 11 22:50:11 raspberrypi boinc[5087]: 11-Apr-2020 22:50:11 [Rosetta@home] Finished download of *****_Junior_HalfRoid_vs_COVID-19_design1_dev.flags
Apr 11 22:50:13 raspberrypi boinc[5087]: 11-Apr-2020 22:50:13 [Rosetta@home] Finished download of *****_Junior_HalfRoid_vs_COVID-19_design1_dev.zip

ところで、

必要があれば、USB接続HDDにBOINCワークディレクトリを移動することもできる。
これによって、365日24時間の運用でも、SDの劣化の防止が期待できると考えられる。
次のページを参照してください。

【Raspberry Pi 4 B / Raspbian】BOINCの作業領域を外付けUSB HDDドライブに移してSDの劣化を防止する【BOINC 7.14.2+dfsg-3】


以上



<参考>
・Rosetta@home
< https://boinc.bakerlab.org/ > 2020年4月11日

・Set your Processors to ANALYSE for the COVID-19 virus with Folding@Home or Rosetta@Home
< https://www.element14.com/community/thread/75254/l/set-your-processors-to-analyse-for-the-covid-19-virus > 2020年4月11日

・Rosetta@home on Raspbian Pi 4
< https://www.element14.com/community/people/gam3t3ch/blog/2020/04/09/rosettahome-on-raspbian-pi-4 > 2020年4月11日

・Turning Your Raspberry Pi Into a Science Research Station Via BOINC
< https://dzone.com/articles/turning-your-raspberry-pi-into-a-science-research > 2020年4月11日

・How to Fight Coronavirus With Your Raspberry Pi
< https://www.tomshardware.com/how-to/fight-coronavirus-with-raspberry-pi > 2020年4月11日

・E14community チームの情報
< https://boinc.bakerlab.org/rosetta/team_display.php?teamid=19110 > 2020年4月11日

・Raspberry Pi BOINC Tutorial
< https://pimylifeup.com/raspberry-pi-boinc/ > 2020年4月15日

・Controlling BOINC remotely
< https://boinc.berkeley.edu/wiki/Controlling_BOINC_remotely > 2020年4月25日


〇CPUアーキテクチャについて

・ARM、64ビットアーキテクチャ「ARMv8」の概要を公開
< https://news.mynavi.jp/article/20111031-arm_v8/2 > 2020年4月15日

・ARMアーキテクチャ
< https://ja.wikipedia.org/wiki/ARMアーキテクチャ > 2020年4月15日

・ARM64 on Raspberry Pi 4
< http://marksrpicluster.blogspot.com/2019/12/arm64-on-raspberry-pi-4.html > 2020年4月15日

・armv7とarm64とarmhfの違い
< https://teratail.com/questions/190228 > 2020年4月15日

・ARM、64bit化される次世代アーキテクチャー「ARMv8」を発表
< https://ascii.jp/elem/000/000/645/645995/ > 2020年4月15日



Ad

Ad