0

mpi4py デモ ディレクトリの hellowworld.py スクリプトのテストに従って、3 つのノードで mpi4py サポートを使用して mpi を正常に構成しました。

gms@host:~/development/mpi$ mpiexec -f machinefile -n 10 python ~/development/mpi4py/demo/helloworld.py

Hello, World! I am process 3 of 10 on host.
Hello, World! I am process 1 of 10 on worker1.
Hello, World! I am process 6 of 10 on host.
Hello, World! I am process 2 of 10 on worker2.
Hello, World! I am process 4 of 10 on worker1.
Hello, World! I am process 9 of 10 on host.
Hello, World! I am process 5 of 10 on worker2.
Hello, World! I am process 7 of 10 on worker1.
Hello, World! I am process 8 of 10 on worker2.
Hello, World! I am process 0 of 10 on host.

私は現在、これを ipython で機能させようとしており、次のように、私のマシンファイルを $IPYTHON_DIR/profile_mpi/ipcluster_config.py ファイルに追加しました。

c.MPILauncher.mpi_args = ["-machinefile", "/home/gms/development/mpi/machinefile"]

次に、次のコマンドを使用して、ヘッド ノードで iPython ノートブックを起動します。ipython notebook --profile=mpi --ip=* --port=9999 --no-browser &

ほら、ローカル ネットワーク上の別のデバイスから問題なくアクセスできます。ただし、iPython ノートブックから helloworld.py を実行すると、ヘッド ノードからのみ応答が返されます。Hello, World! I am process 0 of 10 on host.

10個のエンジンでiPythonからmpiを始めたのですが...

念のため、これらのパラメーターをさらに構成しました

$IPYTHON_DIR/profile_mpi/ipcluster_config.py 内

c.IPClusterEngines.engine_launcher_class = 'MPIEngineSetLauncher'

$IPYTHON_DIR/profile_mpi/ipengine_config.py で

c.MPI.use = 'mpi4py'

$IPYTHON_DIR/profile_mpi/ipcontroller_config.py で

c.HubFactory.ip = '*'

ただし、これらも役に立ちませんでした。

これを正しく機能させるために何が欠けていますか?

アップデート 1 を編集

現在、ワーカー ノードに NFS マウントされたディレクトリがあり、「現在、ipcluster では、IPYTHONDIR/profile_/security ディレクトリがコントローラとエンジンの両方から見える共有ファイル システム上にあることが必要です」という要件を満たしています。ipclusterコマンドを使用して、コントローラーとエンジンを起動できるようにしますipcluster start --profile=mpi -n 6 &

したがって、これをヘッド ノードで発行すると、次のようになります。

2016-03-04 20:31:26.280 [IPClusterStart] Starting ipcluster with [daemon=False] 2016-03-04 20:31:26.283 [IPClusterStart] Creating pid file: /home/gms/.config/ipython/profile_mpi/pid/ipcluster.pid 2016-03-04 20:31:26.284 [IPClusterStart] Starting Controller with LocalControllerLauncher 2016-03-04 20:31:27.282 [IPClusterStart] Starting 6 Engines with MPIEngineSetLauncher 2016-03-04 20:31:57.301 [IPClusterStart] Engines appear to have started successfully

次に、同じコマンドを発行して他のノードでエンジンを起動しますが、次のようになります。

2016-03-04 20:31:33.092 [IPClusterStart] Removing pid file: /home/gms/.config/ipython/profile_mpi/pid/ipcluster.pid 2016-03-04 20:31:33.095 [IPClusterStart] Starting ipcluster with [daemon=False] 2016-03-04 20:31:33.100 [IPClusterStart] Creating pid file: /home/gms/.config/ipython/profile_mpi/pid/ipcluster.pid 2016-03-04 20:31:33.111 [IPClusterStart] Starting Controller with LocalControllerLauncher 2016-03-04 20:31:34.098 [IPClusterStart] Starting 6 Engines with MPIEngineSetLauncher [1]+ Stopped ipcluster start --profile=mpi -n 6

確認なしでEngines appear to have started successfully...

さらに紛らわしいことps auに、ワーカー ノードで a を実行すると、次のようになります。

gms       3862  0.1  2.5  38684 23740 pts/0    T    20:31   0:01 /usr/bin/python /usr/bin/ipcluster start --profile=mpi -n 6
gms       3874  0.1  1.7  21428 16772 pts/0    T    20:31   0:01 /usr/bin/python -c from IPython.parallel.apps.ipcontrollerapp import launch_new_instance; launch_new_instance() --profile-dir /home/gms/.co
gms       3875  0.0  0.2   4768  2288 pts/0    T    20:31   0:00 mpiexec -n 6 -machinefile /home/gms/development/mpi/machinefile /usr/bin/python -c from IPython.parallel.apps.ipengineapp import launch_new
gms       3876  0.0  0.4   5732  4132 pts/0    T    20:31   0:00 /usr/bin/ssh -x 192.168.1.1 "/usr/bin/hydra_pmi_proxy" --control-port 192.168.1.200:36753 --rmk user --launcher ssh --demux poll --pgid 0 -
gms       3877  0.0  0.1   4816  1204 pts/0    T    20:31   0:00 /usr/bin/hydra_pmi_proxy --control-port 192.168.1.200:36753 --rmk user --launcher ssh --demux poll --pgid 0 --retries 10 --proxy-id 1
gms       3878  0.0  0.4   5732  4028 pts/0    T    20:31   0:00 /usr/bin/ssh -x 192.168.1.201 "/usr/bin/hydra_pmi_proxy" --control-port 192.168.1.200:36753 --rmk user --launcher ssh --demux poll --pgid 0
gms       3879  0.0  0.6   8944  6008 pts/0    T    20:31   0:00 /usr/bin/python -c from IPython.parallel.apps.ipengineapp import launch_new_instance; launch_new_instance() --profile-dir /home/gms/.config
gms       3880  0.0  0.6   8944  6108 pts/0    T    20:31   0:00 /usr/bin/python -c from IPython.parallel.apps.ipengineapp import launch_new_instance; launch_new_instance() --profile-dir /home/gms/.config

プロセス 3376 および 3378 の IP アドレスは、クラスター内の他のホストのものです。しかし...

ipython を使用して同様のテストを直接実行すると、ローカルホストからの応答しか得られません (ただし、元の投稿に記載されているように、これは mpi と mpi4py で直接動作します)。

gms@head:~/development/mpi$ ipython test.py
head[3834]: 0/1

gms@head:~/development/mpi$ mpiexec -f machinefile -n 10 ipython test.py
worker1[3961]: 4/10
worker1[3962]: 7/10
head[3946]: 6/10
head[3944]: 0/10
worker2[4054]: 5/10
worker2[4055]: 8/10
head[3947]: 9/10
worker1[3960]: 1/10
worker2[4053]: 2/10
head[3945]: 3/10

構成が正しいと確信していますが、まだ明らかな何かが欠けているようです。ipclusterワーカー ノードで起動すると、次のように表示されます。2016-03-04 20:31:33.092 [IPClusterStart] Removing pid file: /home/gms/.config/ipython/profile_mpi/pid/ipcluster.pid

アップデート 2 を編集

これは、何が起こっているかを文書化するためのものであり、うまくいけば、最終的にこれが機能する理由は次のとおりです。

ログファイルを消去して再発行しましたipcluster start --profile=mpi -n 6 &

そして、エンジン用の 6 つのログ ファイルと、コントローラー用の 1 つのログ ファイルが表示されます。

drwxr-xr-x 2 gms gms 12288 Mar  6 03:28 .
drwxr-xr-x 7 gms gms  4096 Mar  6 03:31 ..
-rw-r--r-- 1 gms gms  1313 Mar  6 03:28 ipcontroller-15664.log
-rw-r--r-- 1 gms gms   598 Mar  6 03:28 ipengine-15669.log
-rw-r--r-- 1 gms gms   598 Mar  6 03:28 ipengine-15670.log
-rw-r--r-- 1 gms gms   499 Mar  6 03:28 ipengine-4405.log
-rw-r--r-- 1 gms gms   499 Mar  6 03:28 ipengine-4406.log
-rw-r--r-- 1 gms gms   499 Mar  6 03:28 ipengine-4628.log
-rw-r--r-- 1 gms gms   499 Mar  6 03:28 ipengine-4629.log 

ipcontroller のログを見ると、登録されているエンジンは 1 つだけのようです。

2016-03-06 03:28:12.469 [IPControllerApp] Hub listening on tcp://*:34540 for registration.
2016-03-06 03:28:12.480 [IPControllerApp] Hub using DB backend: 'NoDB'
2016-03-06 03:28:12.749 [IPControllerApp] hub::created hub
2016-03-06 03:28:12.751 [IPControllerApp] writing connection info to /home/gms/.config/ipython/profile_mpi/security/ipcontroller-client.json
2016-03-06 03:28:12.754 [IPControllerApp] writing connection info to /home/gms/.config/ipython/profile_mpi/security/ipcontroller-engine.json
2016-03-06 03:28:12.758 [IPControllerApp] task::using Python leastload Task scheduler
2016-03-06 03:28:12.760 [IPControllerApp] Heartmonitor started
2016-03-06 03:28:12.808 [IPControllerApp] Creating pid file: /home/gms/.config/ipython/profile_mpi/pid/ipcontroller.pid
2016-03-06 03:28:14.792 [IPControllerApp] client::client 'a8441250-d3d7-4a0b-8210-dae327665450' requested 'registration_request'
2016-03-06 03:28:14.800 [IPControllerApp] client::client '12fd0bcc-24e9-4ad0-8154-fcf1c7a0e295' requested 'registration_request'
2016-03-06 03:28:18.764 [IPControllerApp] registration::finished registering engine 1:'12fd0bcc-24e9-4ad0-8154-fcf1c7a0e295'
2016-03-06 03:28:18.768 [IPControllerApp] engine::Engine Connected: 1
2016-03-06 03:28:20.800 [IPControllerApp] registration::purging stalled registration: 0

6 つのエンジンのそれぞれを登録する必要はありませんか?

エンジンのログのうち 2 つは、正常に登録されているように見えます。

2016-03-06 03:28:13.746 [IPEngineApp] Initializing MPI:
2016-03-06 03:28:13.746 [IPEngineApp] from mpi4py import MPI as mpi
mpi.size = mpi.COMM_WORLD.Get_size()
mpi.rank = mpi.COMM_WORLD.Get_rank()

2016-03-06 03:28:14.735 [IPEngineApp] Loading url_file     u'/home/gms/.config/ipython/profile_mpi/security/ipcontroller-engine.json'
2016-03-06 03:28:14.780 [IPEngineApp] Registering with controller at tcp://127.0.0.1:34540
2016-03-06 03:28:15.282 [IPEngineApp] Using existing profile dir:    
u'/home/gms/.config/ipython/profile_mpi'
2016-03-06 03:28:15.286 [IPEngineApp] Completed registration with id 1

もう一方が登録している間id 0

しかし、他の 4 つのエンジンではタイムアウト エラーが発生しました。

2016-03-06 03:28:14.676 [IPEngineApp] Initializing MPI:
2016-03-06 03:28:14.689 [IPEngineApp] from mpi4py import MPI as mpi
mpi.size = mpi.COMM_WORLD.Get_size()
mpi.rank = mpi.COMM_WORLD.Get_rank()

2016-03-06 03:28:14.733 [IPEngineApp] Loading url_file u'/home/gms/.config/ipython/profile_mpi/security/ipcontroller-engine.json'
2016-03-06 03:28:14.805 [IPEngineApp] Registering with controller at tcp://127.0.0.1:34540
2016-03-06 03:28:16.807 [IPEngineApp] Registration timed out after 2.0 seconds

うーん...明日、ipythonの再インストールを試みるかもしれません。

アップデート 3 を編集

競合するバージョンの ipython がインストールされました (apt-get と pip のように見えます)。を使用してアンインストールおよび再インストールしてpip install ipython[all]います...

アップデート 4 を編集

誰かがこれが役に立つと思ってくれることを願っています.

とにかく、自分の環境を分離するためにvirtualenvをインストールしましたが、ある程度成功したようです。各ノードで「ipcluster start -n 4 --profile=mpi」を起動し、ヘッド ノードに ssh で戻り、テスト スクリプトを実行しました。最初にipcluster. 次の出力:平行性の兆候つまり、いくつかの並列計算を実行しています。

ただし、すべてのノードを照会するテスト スクリプトを実行すると、ヘッド ノードのみが取得されます。

ここに並列処理はありません

しかし、繰り返しになりますが、まっすぐにmpiexecコマンドを実行すると、すべてがうまくいきません。

さらに混乱を招くことに、ノード上のプロセスを見ると、それらが連携していることを示すあらゆる種類の動作が見られます。プロセスの監視

そして、私のログには何も異常はありません。2 番目のテスト スクリプトでノードが返されないのはなぜですか (ここに含まれるコード:):

# test_mpi.py
import os
import socket
from mpi4py import MPI

MPI = MPI.COMM_WORLD

print("{host}[{pid}]: {rank}/{size}".format(
    host=socket.gethostname(),
    pid=os.getpid(),
    rank=MPI.rank,
    size=MPI.size,
))
4

1 に答える 1

0

理由はわかりませんが、ipcluster_config.py ファイルを再作成し、再度 c.MPILauncher.mpi_args = ["-machinefile", "path_to_file/machinefile"] を追加しましたが、今回はうまくいきました - 奇妙な理由で。これは前に持っていたと断言できますが、残念ながら...

于 2016-03-26T01:25:48.050 に答える