chainerMNのGPU実行について

989 views
Skip to first unread message

acro.k...@gmail.com

unread,
Mar 22, 2018, 12:33:06 AM3/22/18
to Chainer Japanese User Group
お世話になっております。

GPU環境でchainermnのtrain_mnist.pyのサンプルコードを
動かそうとしているのですが、以下のメッセージが出て止まってしまいます。
-gを外してCPU実行すると正常に動きます。
対処法をご存知でしたら教えていただけないでしょうか。

$ mpiexec -n 4 python examples/mnist/train_mnist.py -g
=====================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= EXIT CODE: 139
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
=====================================================================================
APPLICATION TERMINATED WITH THE EXIT STRING: Segmentation fault (signal 11)

環境
os:
 Ubuntu 16.04
gpu:
 GeForce GTX 1080 4枚
 
python 3.6.3 :: Anaconda custom (64-bit)
chainer 2.0.2
cuda 9.1
openmpi 3.0.0
nccl 2.1.15
mpi4py 2.0.0

公式のStep-by-Step TroubleshootingのEXIT CODE:11のところは見ていますが、対処方法がよく分からず抜け出せずにいます。

Keisuke Fukuda

unread,
Mar 22, 2018, 12:54:14 AM3/22/18
to acro.k...@gmail.com, Chainer Japanese User Group
福田と申します。

トラブルシューティングの中身について、どこまで確認されたでしょうか?
先頭から一つずつ確認いただければと思います。
現象を見る限り、MPIがCUDA-awareでない点が問題に見えます。
の項を含め、順番に確認してみていただけますか?

また、OpenMPI 3系列は、GPU間通信がハングする問題があることが知られていますので、
OpenMPI 2.1.2 をお使いください。


最後のエラーメッセージの項については、違うエラーについてですので
適用できないと思われます。


よろしくお願いいたします



--
このメールは Google グループのグループ「Chainer Japanese User Group」に登録しているユーザーに送られています。
このグループから退会し、グループからのメールの配信を停止するには chainer-jp+unsubscribe@googlegroups.com にメールを送信してください。
このグループに投稿するには chain...@googlegroups.com にメールを送信してください。
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/chainer-jp/c88b2d79-6a11-4bdb-8b1c-e8fd6942ecc8%40googlegroups.com にアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。



--
FUKUDA, Keisuke <福田圭祐>
Tokyo, Japan
Email: keisuk...@gmail.com

ktok

unread,
Mar 22, 2018, 12:52:27 PM3/22/18
to Chainer Japanese User Group
福田さん

コメントありがとうございます。
トラブルシューティングの中身について確認してみましたが、
Check if MPI is CUDA-awareの部分が動かないですね。。
(それ以外の部分は想定される動作が確認できました)

その後、
OpenMPI 3.0.0をmake cleanして、
教えていただいたOpenMPI 2.1.2を入れ直し、cupyを再ビルドしてみましたが、
同様のEXIT CODE: 139のエラーが出てしまいます。

手順としては公式
(https://github.com/chainer/chainermn/blob/master/docs/source/installation/guide.rst)を参考に

$ ./configure --with-cuda
$ make -j4
$ sudo make install

でいれています。

2018年3月22日木曜日 13時33分06秒 UTC+9 ktok:

Keisuke Fukuda

unread,
Mar 22, 2018, 10:49:31 PM3/22/18
to ktok, Chainer Japanese User Group
以下の点をご確認ください
MPIがCUDA-awareになっていないということだと思うので、
特に(1)が問題だと思います。また、その後、(2)もご確認ください

(1) 実行の際、新しくインストールしたMPIへ正しくパスが通っているかを確認してください。
具体的には、 PATH, LD_LIBRARY_PATH の2つです
ありがちなのは、mpi4pyインストール時に使われる mpicc / mpicxx というコンパイラのラッパーと、
実行時に使われる mpiexecという実行コマンドが噛み合っていなくて動かないケースです。
(特に自分でインストールされた場合は、 パッケージで導入した /usr にあるものと、
自分で導入した /usr/local にあるものが混在する可能性があります)


(2) MPIを再ビルド/インストールし直したあとに、mpi4pyを入れ直したか
その際、 pip install mpi4py --no-cache-dir というコマンドで行ってください



よろしくお願いします
福田



--
このメールは Google グループのグループ「Chainer Japanese User Group」に登録しているユーザーに送られています。
このグループから退会し、グループからのメールの配信を停止するには chainer-jp+unsubscribe@googlegroups.com にメールを送信してください。
このグループに投稿するには chain...@googlegroups.com にメールを送信してください。
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/chainer-jp/f8b01da8-ddf9-47ba-b799-c6275969dc8e%40googlegroups.com にアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。
Message has been deleted
Message has been deleted
Message has been deleted

ktok

unread,
Mar 29, 2018, 5:27:38 AM3/29/18
to Chainer Japanese User Group
福田さん

返信が遅くなり申し訳ありません。ありがとうございます。
結果としては解決して動くようにはなりました。
(1)をためしてmpi4pyがchainermnと共存して入ったものと自分で手動で入れたものが二つ入っていたことが分かり、
入れなおして動くようになりました。

ただもう一点問題が発生していて、
GPUで2並列で学習させた場合にlossがnanになってしまい学習が進みません。
$ mpiexec -n 2 python examples/mnist/train_mnist.py -g
=====
epoch       main/loss   validation/main/loss  main/accuracy  validation/main/accuracy  elapsed_time
1            nan          nan                      0.101733        0.098                         3.30826
2            nan          nan                      0.100933        0.098                         4.86105
3            nan          nan                      0.100933        0.098                         6.35061
4            nan          nan                      0.100933        0.098                         8.02655
5            nan          nan                      0.100933        0.098                         9.5444
=====

GPU1並列やCPU2並列ではlossが下がっていき学習が進むのですが。。
$ mpiexec -n 4 python examples/mnist/train_mnist.py
$ mpiexec -n 1 python examples/mnist/train_mnist.py -g

また以下はGPU2並列でも進みます。
$ mpiexec -n 2 python examples/mnist/train_mnist_model_parallel.py -g
$ mpiexec -n 2 python examples/mnist/train_mnist_dual_parallel.py -g

何かご存知でしたら教えてください。

2018年3月22日木曜日 13時33分06秒 UTC+9 ktok:

Keisuke Fukuda

unread,
Apr 1, 2018, 11:57:50 PM4/1/18
to ktok, Chainer Japanese User Group
MPIの方の問題は治ったとのこと、ひとまずよかったです。

NaN問題についてですが、
Chaierをデバッグモードで動かすと、レイヤー毎にNaNをチェックしてくれますので、
こちらを試してみていただけますか?

環境変数 CHAINER_DEBUG=1 とするのが簡単かと思います。


また、実行時に、先頭に
==========================================
Num process (COMM_WORLD): 2
Using GPUs
Using hierarchical communicator
Num unit: 1000
Num Minibatch-size: 100
Num epoch: 20
==========================================
といったような表示が出ると思うのですがこちらを省略せずに張っていただくと
問題解決に役立つかもしれません。

よろしくお願いいたします。
福田



--
このメールは Google グループのグループ「Chainer Japanese User Group」に登録しているユーザーに送られています。
このグループから退会し、グループからのメールの配信を停止するには chainer-jp+unsubscribe@googlegroups.com にメールを送信してください。
このグループに投稿するには chain...@googlegroups.com にメールを送信してください。
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/chainer-jp/a4daf0e0-d56a-4a9c-b8f2-0ccb9bf65396%40googlegroups.com にアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。

Keisuke Fukuda

unread,
Apr 2, 2018, 12:15:40 AM4/2/18
to ktok, Chainer Japanese User Group
一点、書き漏れがありました。
Chainerのバージョンが、最初のメールによりますと 2.0.2 ということで、
これは既にかなり古いバージョンとなっています。

試しに、最新バージョン(4系のβリリース、もしくは3系列)で
発生するかどうか試していただけますでしょうか。

また、CuPY, ChainerMNのバージョンも書かれていないようですので
教えていただけますか。

よろしくお願いします
福田

Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

ktok

unread,
Apr 3, 2018, 12:24:07 AM4/3/18
to Chainer Japanese User Group
回答ありがとうございます。
まずバージョンですが、3系の誤りです。失礼しました。

train_mnist.py(Data Parallel)は動作せず train_mnist_model_parallel.pyが動作する状態です。
例外を確認すると、最初の予測部で出力されているようです。しかし、計算自体はnanになる可能性は低いと考えております。
(何度か投稿しているのですがページを離れると投稿が消えてしまうのはなぜなのでしょう。。)

■バージョン
chainer (3.5.0)
cupy (2.5.0)
chainermn (1.2.0)

■実行コマンド
chainermn直下で実行
$ CHAINER_DEBUG=1 mpiexec -n 4 python examples/mnist/train_mnist.py --gpu
==========================================
Num process (COMM_WORLD): 4
Using GPUs
Using hierarchical communicator
Num unit: 1000
Num Minibatch-size: 100
Num epoch: 20
==========================================
epoch       main/loss   validation/main/loss  main/accuracy  validation/main/accuracy  elapsed_time
Exception in main training loop: NaN is detected on forward computation of LinearFunction
Traceback (most recent call last):
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 299, in run
    update()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 223, in update
    self.update_core()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 234, in update_core
    optimizer.update(loss_func, *in_arrays)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainermn/optimizers.py", line 20, in update
    loss = lossfun(*args, **kwds)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/model/classifier.py", line 114, in __call__
    self.y = self.predictor(*args, **kwargs)
  File "examples/mnist/train_mnist.py", line 27, in __call__
    h1 = F.relu(self.l1(x))
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/connection/linear.py", line 129, in __call__
    return linear.linear(x, self.W, self.b)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/functions/connection/linear.py", line 175, in linear
    y, = LinearFunction().apply(args)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/function_node.py", line 258, in apply
    raise RuntimeError(msg)
Will finalize trainer extensions and updater before reraising the exception.
Exception in main training loop: NaN is detected on forward computation of LinearFunction
Traceback (most recent call last):
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 299, in run
    update()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 223, in update
    self.update_core()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 234, in update_core
    optimizer.update(loss_func, *in_arrays)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainermn/optimizers.py", line 20, in update
    loss = lossfun(*args, **kwds)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/model/classifier.py", line 114, in __call__
    self.y = self.predictor(*args, **kwargs)
  File "examples/mnist/train_mnist.py", line 27, in __call__
    h1 = F.relu(self.l1(x))
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/connection/linear.py", line 129, in __call__
    return linear.linear(x, self.W, self.b)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/functions/connection/linear.py", line 175, in linear
    y, = LinearFunction().apply(args)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/function_node.py", line 258, in apply
    raise RuntimeError(msg)
Will finalize trainer extensions and updater before reraising the exception.
Exception in main training loop: NaN is detected on forward computation of LinearFunction
Traceback (most recent call last):
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 299, in run
    update()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 223, in update
    self.update_core()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 234, in update_core
    optimizer.update(loss_func, *in_arrays)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainermn/optimizers.py", line 20, in update
    loss = lossfun(*args, **kwds)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/model/classifier.py", line 114, in __call__
    self.y = self.predictor(*args, **kwargs)
  File "examples/mnist/train_mnist.py", line 27, in __call__
    h1 = F.relu(self.l1(x))
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/connection/linear.py", line 129, in __call__
    return linear.linear(x, self.W, self.b)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/functions/connection/linear.py", line 175, in linear
    y, = LinearFunction().apply(args)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/function_node.py", line 258, in apply
    raise RuntimeError(msg)
Will finalize trainer extensions and updater before reraising the exception.
Traceback (most recent call last):
  File "examples/mnist/train_mnist.py", line 124, in <module>
    main()
  File "examples/mnist/train_mnist.py", line 120, in main
    trainer.run()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 313, in run
    six.reraise(*sys.exc_info())
  File "/home/user/anaconda3/lib/python3.6/site-packages/six.py", line 693, in reraise
    raise value
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 299, in run
    update()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 223, in update
    self.update_core()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 234, in update_core
    optimizer.update(loss_func, *in_arrays)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainermn/optimizers.py", line 20, in update
    loss = lossfun(*args, **kwds)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/model/classifier.py", line 114, in __call__
    self.y = self.predictor(*args, **kwargs)
  File "examples/mnist/train_mnist.py", line 27, in __call__
    h1 = F.relu(self.l1(x))
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/connection/linear.py", line 129, in __call__
    return linear.linear(x, self.W, self.b)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/functions/connection/linear.py", line 175, in linear
    y, = LinearFunction().apply(args)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/function_node.py", line 258, in apply
    raise RuntimeError(msg)
RuntimeError: NaN is detected on forward computation of LinearFunction
Exception in main training loop: NaN is detected on forward computation of LinearFunction
Traceback (most recent call last):
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 299, in run
    update()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 223, in update
    self.update_core()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 234, in update_core
    optimizer.update(loss_func, *in_arrays)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainermn/optimizers.py", line 20, in update
    loss = lossfun(*args, **kwds)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/model/classifier.py", line 114, in __call__
    self.y = self.predictor(*args, **kwargs)
  File "examples/mnist/train_mnist.py", line 27, in __call__
    h1 = F.relu(self.l1(x))
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/connection/linear.py", line 129, in __call__
    return linear.linear(x, self.W, self.b)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/functions/connection/linear.py", line 175, in linear
    y, = LinearFunction().apply(args)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/function_node.py", line 258, in apply
    raise RuntimeError(msg)
Will finalize trainer extensions and updater before reraising the exception.
Traceback (most recent call last):
  File "examples/mnist/train_mnist.py", line 124, in <module>
    main()
  File "examples/mnist/train_mnist.py", line 120, in main
    trainer.run()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 313, in run
    six.reraise(*sys.exc_info())
  File "/home/user/anaconda3/lib/python3.6/site-packages/six.py", line 693, in reraise
    raise value
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 299, in run
    update()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 223, in update
    self.update_core()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 234, in update_core
    optimizer.update(loss_func, *in_arrays)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainermn/optimizers.py", line 20, in update
    loss = lossfun(*args, **kwds)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/model/classifier.py", line 114, in __call__
    self.y = self.predictor(*args, **kwargs)
  File "examples/mnist/train_mnist.py", line 27, in __call__
    h1 = F.relu(self.l1(x))
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/connection/linear.py", line 129, in __call__
    return linear.linear(x, self.W, self.b)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/functions/connection/linear.py", line 175, in linear
    y, = LinearFunction().apply(args)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/function_node.py", line 258, in apply
    raise RuntimeError(msg)
RuntimeError: NaN is detected on forward computation of LinearFunction
Traceback (most recent call last):
  File "examples/mnist/train_mnist.py", line 124, in <module>
    main()
  File "examples/mnist/train_mnist.py", line 120, in main
    trainer.run()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 313, in run
    six.reraise(*sys.exc_info())
  File "/home/user/anaconda3/lib/python3.6/site-packages/six.py", line 693, in reraise
    raise value
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 299, in run
    update()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 223, in update
    self.update_core()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 234, in update_core
    optimizer.update(loss_func, *in_arrays)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainermn/optimizers.py", line 20, in update
    loss = lossfun(*args, **kwds)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/model/classifier.py", line 114, in __call__
    self.y = self.predictor(*args, **kwargs)
  File "examples/mnist/train_mnist.py", line 27, in __call__
    h1 = F.relu(self.l1(x))
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/connection/linear.py", line 129, in __call__
    return linear.linear(x, self.W, self.b)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/functions/connection/linear.py", line 175, in linear
    y, = LinearFunction().apply(args)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/function_node.py", line 258, in apply
    raise RuntimeError(msg)
RuntimeError: NaN is detected on forward computation of LinearFunction
Traceback (most recent call last):
  File "examples/mnist/train_mnist.py", line 124, in <module>
    main()
  File "examples/mnist/train_mnist.py", line 120, in main
    trainer.run()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 313, in run
    six.reraise(*sys.exc_info())
  File "/home/user/anaconda3/lib/python3.6/site-packages/six.py", line 693, in reraise
    raise value
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 299, in run
    update()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 223, in update
    self.update_core()
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 234, in update_core
    optimizer.update(loss_func, *in_arrays)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainermn/optimizers.py", line 20, in update
    loss = lossfun(*args, **kwds)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/model/classifier.py", line 114, in __call__
    self.y = self.predictor(*args, **kwargs)
  File "examples/mnist/train_mnist.py", line 27, in __call__
    h1 = F.relu(self.l1(x))
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/links/connection/linear.py", line 129, in __call__
    return linear.linear(x, self.W, self.b)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/functions/connection/linear.py", line 175, in linear
    y, = LinearFunction().apply(args)
  File "/home/user/anaconda3/lib/python3.6/site-packages/chainer/function_node.py", line 258, in apply
    raise RuntimeError(msg)
RuntimeError: NaN is detected on forward computation of LinearFunction
-------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code.. Per user-direction, the job has been aborted.
-------------------------------------------------------
--------------------------------------------------------------------------
mpiexec detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

  Process name: [[4540,1],1]
  Exit code:    1
--------------------------------------------------------------------------


2018年3月22日木曜日 13時33分06秒 UTC+9 ktok:

Kenta Oono

unread,
Apr 4, 2018, 9:13:24 PM4/4/18
to Chainer Japanese User Group
大野です.

> (何度か投稿しているのですがページを離れると投稿が消えてしまうのはなぜなのでしょう。。)
管理権限を持っておりますので確認した所,スパムの可能性があるとして投稿が保留されておりました.
保留されたメッセージは内容的には既に投稿されたものとほぼ同一のようですが,
保留を解除して投稿する必要はございますでしょうか

また,北島様のメールも1件保留されておりましたので許可いたしました.

よろしくお願いいたします.

2018年4月3日火曜日 13時24分07秒 UTC+9 ktok:

Keisuke Fukuda

unread,
Apr 4, 2018, 9:44:07 PM4/4/18
to ktok, Chainer Japanese User Group
実行結果ありがとうございます。

おっしゃる通り、計算自体がNANになる可能性はほぼ無いと思います。
一点確認させていただきたいのですが、実行は1台のマシンで
行っていますか?
複数台のマシンの場合、全てのマシンで、MNISTのデータが破損せずに
正しく保存されているでしょうか…?
データ自体は、
$HOME/.chainer/dataset/pfnet/chainer/mnist
に保存されています。単純に削除すれば、次回実行時に再ダウンロードされると思います。


よろしくお願いいたします
福田



--
このメールは Google グループのグループ「Chainer Japanese User Group」に登録しているユーザーに送られています。
このグループから退会し、グループからのメールの配信を停止するには chainer-jp+unsubscribe@googlegroups.com にメールを送信してください。
このグループに投稿するには chain...@googlegroups.com にメールを送信してください。
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/chainer-jp/e8797ec6-8296-4f2e-805d-26544df93430%40googlegroups.com にアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。

ktok

unread,
Apr 5, 2018, 2:43:04 AM4/5/18
to Chainer Japanese User Group
福田さん

回答ありがとうございます。

> おっしゃる通り、計算自体がNANになる可能性はほぼ無いと思います。
> 一点確認させていただきたいのですが、実行は1台のマシンで
> 行っていますか?

今回実行している環境は1台構成複数GPUになります。
データ破損のことを考慮し、データ削除の後再度実行しましたが、データが壊れている可能性は低いとみています。
もし、仮にこの仮説が正しいとすれば、-nが1の場合でもnanが出力されると考えております。

$ CHAINER_DEBUG=1 mpiexec -n 2 python examples/mnist/train_mnist.py --gpu

epoch       main/loss   validation/main/loss  main/accuracy  validation/main/accuracy  elapsed_time
1           nan         nan                   0.0997334      0.098                     15.2728
2           nan         nan                   0.0998334      0.098                     25.1267

$ CHAINER_DEBUG=1 mpiexec -n 1 python examples/mnist/train_mnist.py --gpu

epoch       main/loss   validation/main/loss  main/accuracy  validation/main/accuracy  elapsed_time
1           0.191821    0.106549              0.941067       0.9673                    19.3157
2           0.074825    0.073879              0.976267       0.9773                    37.7363
3           0.0464692   0.0915299             0.984865       0.9744                    56.0868
4           0.0375635   0.0692075             0.987449       0.978201                  68.3884
5           0.0270365   0.0834781             0.990998       0.9794                    72.2976
6           0.0242452   0.0825581             0.991948       0.9797                    76.2265
7           0.0237657   0.0840107             0.992482       0.9794                    80.1549
8           0.0174403   0.0904471             0.994215       0.9796                    84.0958
9           0.0191774   0.0924441             0.993915       0.98                      88.0793
10          0.0128983   0.0835699             0.995749       0.9803                    91.9896

どうぞ、よろしくお願いいたします。

2018年4月5日木曜日 10時44分07秒 UTC+9 Keisuke Fukuda:
このグループから退会し、グループからのメールの配信を停止するには chainer-jp+...@googlegroups.com にメールを送信してください。
このグループに投稿するには chain...@googlegroups.com にメールを送信してください。
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/chainer-jp/e8797ec6-8296-4f2e-805d-26544df93430%40googlegroups.com にアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。

ktok

unread,
Apr 5, 2018, 2:43:48 AM4/5/18
to Chainer Japanese User Group
大野さん

こちらは伝えたいことは投稿できているので大丈夫です。
お気遣いありがとうございます。

2018年4月5日木曜日 10時13分24秒 UTC+9 Kenta Oono:

ktok

unread,
Apr 10, 2018, 12:39:46 AM4/10/18
to Chainer Japanese User Group
すみません、こちらお分かりになる方いらっしゃったら教えていただけると幸いです。。

2018年4月5日木曜日 15時43分04秒 UTC+9 ktok:

Keisuke Fukuda

unread,
Apr 10, 2018, 1:03:30 AM4/10/18
to ktok, Chainer Japanese User Group
福田です。

わたしの方でも考えておりますが、わたしの手元で再現しないので
ちょっと手詰まりと言うか、なかなか対処を考えるのが難しいです。

基本的には何かが壊れているのだと思いますが。
もう少し、読み込み直後のデータの状態や、各レイヤの状態等を詳細に調べれば
解決可能だとは思うのですが、ちょっと手軽な方法が思いつきません。

各種情報をDumpするようにしたブランチをわたしの方で作り、その出力を送っていただいて調べるという
感じになるかなあと思います。もうちょっとだけお待ちください…


福田


このグループから退会し、グループからのメールの配信を停止するには chainer-jp+unsubscribe@googlegroups.com にメールを送信してください。
このグループに投稿するには chain...@googlegroups.com にメールを送信してください。
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/chainer-jp/5afdea96-8b2b-4271-8daa-447b35fef0b9%40googlegroups.com にアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。

ktok

unread,
Apr 10, 2018, 6:31:57 AM4/10/18
to Chainer Japanese User Group
福田さん

解析ありがとうございます。

こちらでも解析を進めており、Printデバッグを挟みながら実行しました。
最初の一度ではなく、何回か学習処理している後にパラメータ側がNaNになっています。
シングルGPUでの実行では出ていないことより、
マルチGPUがNaNの原因に並列化などが影響している可能性が高いです。

Data Parallelのコードなので、実行しているGPUの情報を
提供できればデバッグのお役に立てる可能性があります。

よろしくお願いいたします。

■ログ
==========================================
Num process (COMM_WORLD): 2
Using GPUs
Using hierarchical communicator
Num unit: 1000
Num Minibatch-size: 100
Num epoch: 20
==========================================

iteration 0
iteration 0
input: False
W: False
b: False
input: False
W: False
b: False
iteration 1
input: False
W: False
b: False
epoch       main/loss   validation/main/loss  main/accuracy  validation/main/accuracy  elapsed_time
iteration 1
input: False
W: False
b: False
iteration 2
iteration 2
input: False
W: False
b: False
input: False
W: False
b: False
iteration 3
iteration 3
input: False
W: True
b: True

■編集コード
コメントは削除しております。
1. chainer/training/updater.py
    def update(self):
        print ("iteration",self.iteration)
        self.update_core()
        self.iteration += 1
        
2. examples/mnist/train_mnist.py
class MLP(chainer.Chain):
    def __init__(self, n_units, n_out):
        super(MLP, self).__init__(
            # the size of the inputs to each layer will be inferred
            l1=L.Linear(784, n_units),  # n_in -> n_units
            l2=L.Linear(n_units, n_units),  # n_units -> n_units
            l3=L.Linear(n_units, n_out),  # n_units -> n_out
        )

    def __call__(self, x):
        print ("input:",cuda.get_array_module(x).isnan(x).any())
        print("W:", cupy.isnan(self.l1.W.data).any())
        print("b:", cupy.isnan(self.l1.b.data).any())
        h1 = F.relu(self.l1(x))
        h2 = F.relu(self.l2(h1))
        return self.l3(h2)

2018年4月10日火曜日 14時03分30秒 UTC+9 Keisuke Fukuda:
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/chainer-jp/5afdea96-8b2b-4271-8daa-447b35fef0b9%40googlegroups.com にアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。

Keisuke Fukuda

unread,
Apr 16, 2018, 11:55:20 PM4/16/18
to ktok, Chainer Japanese User Group
反応が遅くて申し訳ありません。

ChainerMNのユニットテストを走らせてみると何か
わかるかもしれませんので、以下のコマンドを試していただけますか?

# 既存のChainerMNを削除
$ pip uninstall -y chainermn

# ChainerMNのリポジトリをダウンロード
$ cd chainermn

# pytestをインストール
$ pip install pytest

# ユニットテストを実行
$ mpiexec -n 4 pytest --color=yes --full-trace --random-order-seed=0 -s -v -m 'not slow'


福田

このグループから退会し、グループからのメールの配信を停止するには chainer-jp+unsubscribe@googlegroups.com にメールを送信してください。
このグループに投稿するには chain...@googlegroups.com にメールを送信してください。
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/chainer-jp/532b5c51-10ed-4bf4-95e8-b748a0baffe9%40googlegroups.com にアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。

Keisuke Fukuda

unread,
Apr 17, 2018, 1:26:32 AM4/17/18
to ktok, Chainer Japanese User Group
すいません、先程のコマンド実行例でいくつか行が抜けていました。

ただしくは以下です。
# 既存のChainerMNを削除
$ pip uninstall -y chainermn

# ChainerMNのリポジトリをダウンロード
$ cd chainermn
$ python setup.py develop
$ git checkout v1.2.0

# pytestをインストール
$ pip install pytest

# ユニットテストを実行
$ mpiexec -n 4 pytest --color=yes --full-trace --random-order-seed=0 -s -v -m 'not slow'

よろしくお願いいたします
福田


ktok

unread,
May 7, 2018, 10:04:52 PM5/7/18
to Chainer Japanese User Group
福田さん

ありがとうございます。
そして返信ができておらず申し訳ございません。
こちらのchainermnの対応ですが、現在他のタスクでGPUを使っており、
試せていない状況が続いています。
また試した際に返信させていただきたいと思いますので、
よろしくお願いします。

2018年4月17日火曜日 14時26分32秒 UTC+9 Keisuke Fukuda:
<br clear="al

Sho Nitta

unread,
May 30, 2018, 9:22:55 AM5/30/18
to Chainer Japanese User Group
新田と申します。同じような状況になってしまいましたので、質問させていただきます。

* Ubuntu16.04
* ChainerMN1.3.0
* Chainer4.1.0
* Cupy4.1.0
* mpi4py3.0.0
* OpenMPI3.0.1
* NCCL2.1.5

のでChainerMNのMNISTのサンプルを回しています。しかしながら、main/lossではNaNしか出力されません。
インストールに関するChainerMNのトラブルシューティングのページは一応すべて確認済みです。
状況は以下の通りです。すべてシングルノード、2枚のGPU(GeForce1080Ti)を積んでます。

正しく回るのが...
* CPUの場合
* GPU1枚の場合(mpiexec -n 1 python train_mnist.py -g)

NaNがmain/lossに現れるのが...
* GPU2枚の場合(mpiexec -n 2 python train_mnist.py -g)

GPU2枚の場合について、CHAINER_DEBUG=1として調べていくと、

* chainer.linksについては計算がうまくいっている
* chainer.functionsのものをなにかしら使用した時点でNaNになる

という結果になっていました。なにかしら調べる点等ございましたら、教えていただけると助かります。

新田

Keisuke Fukuda

unread,
May 31, 2018, 2:19:04 AM5/31/18
to Sho Nitta, Chainer Japanese User Group
新田様、
福田と申します。

最初の iteration から NaN が発生してしまっているのでしょうか。

PrintReportのところに、trigger=(1, 'iteration') を追加して、結果を教えていただけますか?

また、CHAINER_DEBUGを設定した場合、NaNが発生した場合RuntimeErrorが発生すると
思うのですが、エラーメッセージも含め、すべての出力を貼っていただいてもよいでしょうか?

よろしくお願いいたします
福田


--
このメールは Google グループのグループ「Chainer Japanese User Group」に登録しているユーザーに送られています。
このグループから退会し、グループからのメールの配信を停止するには chainer-jp+unsubscribe@googlegroups.com にメールを送信してください。
このグループに投稿するには chain...@googlegroups.com にメールを送信してください。
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/chainer-jp/6ec405f4-5e03-42ad-86d4-ad0b772f4a46%40googlegroups.com にアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。


Sho Nitta

unread,
May 31, 2018, 5:20:22 AM5/31/18
to Chainer Japanese User Group
福田様

早速のご返信ありがとうございました。新田です。
各iterationごとにプリントした場合の結果です。はじめの2回はmain/lossがnanではなかったです。
このあとは20Epochの終わりまでnanになっていました。Accuracyは最後までだいたい0.1付近です。
このときnvidia-smiで1秒毎にモニタリングをしていたのですが、Volatile GPU-Utilがはじめは
10%/100%程度であったのに対し、20Epoch付近では2%/100%となっており、
次第に片方の値が下がっていくように感じました。
==========================================
Num process (COMM_WORLD): 2
Using GPUs
Using pure_nccl communicator

Num unit: 1000
Num Minibatch-size: 100
Num epoch: 20
==========================================
epoch       main/loss   validation/main/loss  main/accuracy  validation/main/accuracy  elapsed_time
0           2.30471                           0.09                                     27.7116      
0           2.31043                           0.13                                     27.8626      
0           nan                               0.09                                     28.1173      
0           nan                               0.12                                     28.1252      
0           nan                               0.1                                      28.131       
0           nan                               0.13                                     28.1364      
0           nan                               0.08                                     28.1419      
0           nan                               0.09                                     28.1497      
0           nan                               0.09                                     28.1559      
0           nan                               0.12                                     28.162       
0           nan                               0.09                                     28.1673      
0           nan                               0.13                                     28.2069   

CHAINER_DEBUG=1のときは、RuntimeErrorでした。
それを踏まえて、CHAINER_DEBUG=1を外し、調べた結果が前回述べたものでした。
RuntimeErrorの全文は以下の通りです。この出力がされたあと、なにも起きません。
何卒よろしくお願いします。

==========================================
Num process (COMM_WORLD): 2
Using GPUs
Using pure_nccl communicator

Num unit: 1000
Num Minibatch-size: 100
Num epoch: 20
==========================================
Exception in main training loop: NaN is detected on forward computation of LinearFunction
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/trainer.py", line 306, in run
    update()
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/updaters/standard_updater.py", line 149, in update
    self.update_core()
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/updaters/standard_updater.py", line 160, in update_core
    optimizer.update(loss_func, *in_arrays)
  File "/usr/local/lib/python2.7/dist-packages/chainermn/optimizers.py", line 19, in update
    loss = lossfun(*args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/chainer/links/model/classifier.py", line 114, in __call__
    self.y = self.predictor(*args, **kwargs)
  File "train_mnist.py", line 26, in __call__
    h1 = F.relu(self.l1(x))
  File "/usr/local/lib/python2.7/dist-packages/chainer/links/connection/linear.py", line 129, in __call__
    return linear.linear(x, self.W, self.b)
  File "/usr/local/lib/python2.7/dist-packages/chainer/functions/connection/linear.py", line 234, in linear
    y, = LinearFunction().apply(args)
  File "/usr/local/lib/python2.7/dist-packages/chainer/function_node.py", line 284, in apply

    raise RuntimeError(msg)
Will finalize trainer extensions and updater before reraising the exception.
Traceback (most recent call last):
  File "train_mnist.py", line 123, in <module>
    main()
  File "train_mnist.py", line 119, in main
    trainer.run()
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/trainer.py", line 320, in run
    six.reraise(*sys.exc_info())
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/trainer.py", line 306, in run
    update()
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/updaters/standard_updater.py", line 149, in update
    self.update_core()
  File "/usr/local/lib/python2.7/dist-packages/chainer/training/updaters/standard_updater.py", line 160, in update_core
    optimizer.update(loss_func, *in_arrays)
  File "/usr/local/lib/python2.7/dist-packages/chainermn/optimizers.py", line 19, in update
    loss = lossfun(*args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/chainer/links/model/classifier.py", line 114, in __call__
    self.y = self.predictor(*args, **kwargs)
  File "train_mnist.py", line 26, in __call__
    h1 = F.relu(self.l1(x))
  File "/usr/local/lib/python2.7/dist-packages/chainer/links/connection/linear.py", line 129, in __call__
    return linear.linear(x, self.W, self.b)
  File "/usr/local/lib/python2.7/dist-packages/chainer/functions/connection/linear.py", line 234, in linear
    y, = LinearFunction().apply(args)
  File "/usr/local/lib/python2.7/dist-packages/chainer/function_node.py", line 284, in apply

    raise RuntimeError(msg)
RuntimeError: NaN is detected on forward computation of LinearFunction
epoch       main/loss   validation/main/loss  main/accuracy  validation/main/accuracy  elapsed_time
0           2.31306                           0.11                                     26.9303      


2018年5月31日木曜日 15時19分04秒 UTC+9 Keisuke Fukuda:
このグループから退会し、グループからのメールの配信を停止するには chainer-jp+...@googlegroups.com にメールを送信してください。
このグループに投稿するには chain...@googlegroups.com にメールを送信してください。
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/chainer-jp/6ec405f4-5e03-42ad-86d4-ad0b772f4a46%40googlegroups.com にアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。

Keisuke Fukuda

unread,
Jun 1, 2018, 1:33:33 AM6/1/18
to Sho Nitta, Chainer Japanese User Group
新田様、

結果のご報告ありがとうございました。

2点、追加で確認をお願いできますでしょうか?

(1)GPUのチェック
1GPUでの実行時はOKということですが、2台目のGPUがハードウェア的におかしいという可能性
も考えられますので、2台目のGPUを使っての1GPU実行を試してみていただけますか?

(2)NCCLを使わない
同様に、GPUの問題でNCCLによる通信が壊れている可能性があります。
ログによれば現在 pure_nccl communicator を使っているとのことですが、
naiveコミュニケーター、及びflatコミュニケーターを試していただけますか?

以上よろしくお願いいたします
福田



このグループから退会し、グループからのメールの配信を停止するには chainer-jp+unsubscribe@googlegroups.com にメールを送信してください。
このグループに投稿するには chain...@googlegroups.com にメールを送信してください。
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/chainer-jp/cd4c8c00-70ae-49fd-aab5-b2781ee5849c%40googlegroups.com にアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。

Sho Nitta

unread,
Jun 1, 2018, 5:21:22 AM6/1/18
to Chainer Japanese User Group
福田様

(1)GPUの確認
ChainerMNのものではないですが、chainerのMNISTのサンプルで
GPU2枚とも正しく実行できました。

(2)NCCLの確認
naiveはCPUで回せることが確認できました。
またflatでは今までと同じように3回目からNaNになってしまいました。
以下に実行結果を載せておきます。

よろしくお願いします。
新田

mpiexec -n 2 python trian_mnist.py —communicator flat -g

==========================================
epoch       main/loss   validation/main/loss  main/accuracy  validation/main/accuracy  elapsed_time
[J0           2.29593                           0.16                                     27.5726       
[J0           2.29869                           0.15                                     27.6162       
[J0           nan                               0.12                                     27.931        
[J0           nan                               0.1                                      27.9468       
[J0           nan                               0.17                                     27.9624       
[J0           nan                               0.06                                     27.9781       
[J0           nan                               0.16                                     27.9939       
[J0           nan                               0.12                                     28.0089       
[J0           nan                               0.16                                     28.0242       
[J0           nan                               0.1                                      28.0395       
[J0           nan                               0.09                                     28.055        
[J0           nan                               0.14                                     28.0704       
[J0           nan                               0.12                                     28.0864       
[J0           nan                               0.11                                     28.1021       
[J0           nan                               0.09                                     28.1174       
[J0           nan                               0.09                                     28.1329     



2018年6月1日金曜日 14時33分33秒 UTC+9 Keisuke Fukuda:
このディスカッションをウェブ上で閲覧するには https://groups.google.com/d/msgid/chainer-jp/cd4c8c00-70ae-49fd-aab5-b2781ee5849c%40googlegroups.com にアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。

ssu...@preferred.jp

unread,
Jun 5, 2018, 9:22:17 AM6/5/18
to Chainer Japanese User Group
新田様

PFNの鈴木です。福田に代わりまして対応させていただきます。
まず、GPUとNCCLの確認、ありがとうございます。
確認していただいた結果から、1. GPUは2つとも問題ない、2.NCCLの問題ではない
と考えられます。
また、以前チェックしていただいた結果を見ると、MPI周りの不具合な気がしています。
このため、再度トラブルシューティングをご確認いただいてもよろしいでしょうか?
また、それとは別にお使いのCUDAのバージョンとGPUのドライバーのバージョンを教えていただいてもよろしいでしょうか?


2018年6月1日金曜日 18時21分22秒 UTC+9 Sho Nitta:

Sho Nitta

unread,
Jun 5, 2018, 9:54:30 AM6/5/18
to Chainer Japanese User Group
鈴木様

新田です。
以下のウェブサイトのStep-by-Step troubleShootingはシングルノードにおいて、エラーなく回りました。

バージョンについてなのですが、
前にご相談させていただいたときは
CUDA:8.0
ドライバー:384(ごめんなさい、はっきりとは覚えてないです)

しかしながら、他のPCで、CUDA9.2での動作確認がとれたので、
CUDA9.2を入れなおしまして、現在は

CUDA:9.2
ドライバー:396.26
です。しかしながら問題のあったPCではうまくまわっていないのが現状です。
nvidia-smiでチェックしている際に、
片方のGPUの使用率がほとんど上がっていないのが気になります。

よろしくお願いします。

新田

2018年6月5日火曜日 22時22分17秒 UTC+9 ssu...@preferred.jp:

ssu...@preferred.jp

unread,
Jun 5, 2018, 8:51:06 PM6/5/18
to Chainer Japanese User Group
新田様

PFNの鈴木です。ご確認ありがとうございます。
1点確認なのですが、
> しかしながら、他のPCで、CUDA9.2での動作確認がとれたので、
というのは他のPCであればChainerMNのmnistが動いたということでしょうか?

また、Chainerのdebug modeで例外が出るタイミングやログの出力の様子から、
MPIが正しくGPUのメモリを使ってマルチプロセスで通信できていない気がします。
このため、MPIがちゃんと動いているのか確認するためにChainerMNのユニットテストを動かしていただいてもよろしいでしょうか?

具体的には以下のようにしてテストを実行していただき、出力されたログをすべて貼ってください。
```
pip install pytest mock
git clone g...@github.com:chainer/chainermn.git
cd chainermn
mpirun -n 2 pytest --full-trace -x --capture=no -s -v -m 'not slow' tests/chainermn_tests/communicator_tests/test_communicator.py
```

以上、よろしくお願いいたします。

2018年6月5日火曜日 22時54分30秒 UTC+9 Sho Nitta:

Sho Nitta

unread,
Jun 8, 2018, 9:16:06 PM6/8/18
to Chainer Japanese User Group
鈴木様

返信が遅くなり申し訳ありません。

CUDA9.2における動作確認というのは、ChainerMNのmnistが
動いたということです。NaNも返ってきていません。

また指定されたコードの出力ログを以下に添付しておきます。
以上よろしくお願いします。

mpirun -n 2 pytest --full-trace -x --capture=no -s -v -m 'not slow' tests/chainermn_tests/communicator_tests/test_communicator.py
Usage: pytest [OPTIONS] [testfile [testpattern]]

examples:

pytest path/to/mytests.py
pytest path/to/mytests.py TheseTests
pytest path/to/mytests.py TheseTests.test_thisone
pytest path/to/mytests.py -m '(not long and database) or regr'

pytest one (will run both test_thisone and test_thatone)
pytest path/to/mytests.py -s not (will skip test_notthisone)


pytest: error: no such option: --full-trace
Usage: pytest [OPTIONS] [testfile [testpattern]]

examples:

pytest path/to/mytests.py
pytest path/to/mytests.py TheseTests
pytest path/to/mytests.py TheseTests.test_thisone
pytest path/to/mytests.py -m '(not long and database) or regr'

pytest one (will run both test_thisone and test_thatone)
pytest path/to/mytests.py -s not (will skip test_notthisone)


pytest: error: no such option: --full-trace

-------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
-------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing

the job to be terminated. The first process to do so was:

  Process name: [[52748,1],0]
  Exit code:    2
--------------------------------------------------------------------------


2018年6月6日水曜日 9時51分06秒 UTC+9 ssu...@preferred.jp:

ssu...@preferred.jp

unread,
Jun 9, 2018, 6:35:14 AM6/9/18
to Chainer Japanese User Group
新田様

PFNの鈴木です。
ご確認ありがとうございます。
CUDA 9.2で動いたとのことですが、お使いのOpenMPIのバージョンは問題の起きているマシンと同じものを使っているのでしょうか?

また、unittestのコマンドですが、ちゃんと動かないものを指定してしまい、大変失礼しました。
再度こちらを実行していただけますでしょうか?
mpirun -n 2 pytest --capture=no -s -v -x tests/chainermn_tests/communicator_tests/test_communicator.py

これでもunittestが動かない場合はオプションを全部削って以下のように実行してみてください。
mpirun -n 2 pytest tests/communicator_tests/test_communicator.py

以上、よろしくお願いいたします。

2018年6月9日土曜日 10時16分06秒 UTC+9 Sho Nitta:

Sho Nitta

unread,
Jun 9, 2018, 8:10:18 AM6/9/18
to Chainer Japanese User Group
鈴木様

早速のご返信ありがとうございます。

まず、OpenMPIは同じ3.0.1を使用しております。

またunittestについてですが、以下に出力を順番に載せておきます。(****で区切りました)
2つ目のオプションを削った場合のみ、うまく動いているように思えます。

以上よろしくお願いします。

新田

mpirun -n 2 pytest --capture=no -s -v -x tests/chainermn_tests/communicator_tests/test_communicator.py
Usage: pytest [OPTIONS] [testfile [testpattern]]

examples:

pytest path/to/mytests.py
pytest path/to/mytests.py TheseTests
pytest path/to/mytests.py TheseTests.test_thisone
pytest path/to/mytests.py -m '(not long and database) or regr'

pytest one (will run both test_thisone and test_thatone)
pytest path/to/mytests.py -s not (will skip test_notthisone)


pytest: error: no such option: --capture

Usage: pytest [OPTIONS] [testfile [testpattern]]

examples:

pytest path/to/mytests.py
pytest path/to/mytests.py TheseTests
pytest path/to/mytests.py TheseTests.test_thisone
pytest path/to/mytests.py -m '(not long and database) or regr'

pytest one (will run both test_thisone and test_thatone)
pytest path/to/mytests.py -s not (will skip test_notthisone)


pytest: error: no such option: --capture

-------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
-------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

  Process name: [[24119,1],1]
  Exit code:    2
--------------------------------------------------------------------------

*****************************************************************************

mpirun -n 2 pytest tests/chainermn_tests/communicator_tests/test_communicator.py
=======================  test_communicator.py  =======================
=======================  test_communicator.py  =======================
/usr/local/lib/python2.7/dist-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
/usr/local/lib/python2.7/dist-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
/usr/local/lib/python2.7/dist-packages/chainer/utils/experimental.py:105: FutureWarning: chainermn.communicators.CommunicatorBase.allreduce is experimental. The interface can change in the future.
  FutureWarning)
/usr/local/lib/python2.7/dist-packages/chainer/utils/experimental.py:105: FutureWarning: chainermn.communicators.CommunicatorBase.allreduce is experimental. The interface can change in the future.
  FutureWarning)
..../usr/local/lib/python2.7/dist-packages/chainer/utils/experimental.py:105: FutureWarning: chainermn.communicators.MpiCommunicatorBase.alltoall is experimental. The interface can change in the future.
  FutureWarning)
/usr/local/lib/python2.7/dist-packages/chainer/utils/experimental.py:105: FutureWarning: chainermn.communicators.MpiCommunicatorBase.alltoall is experimental. The interface can change in the future.
  FutureWarning)
..../usr/local/lib/python2.7/dist-packages/chainer/utils/experimental.py:105: FutureWarning: chainermn.communicators.MpiCommunicatorBase.recv is experimental. The interface can change in the future.
  FutureWarning)
/usr/local/lib/python2.7/dist-packages/chainer/utils/experimental.py:105: FutureWarning: chainermn.communicators.MpiCommunicatorBase.send is experimental. The interface can change in the future.
  FutureWarning)
.....
----------------------------------------------------------------------
Ran 7 tests in 0.039s

OK
.*******************************************************************************


----------------------------------------------------------------------
Ran 7 tests in 0.013s

OK
*******************************************************************************

2018年6月9日土曜日 19時35分14秒 UTC+9 ssu...@preferred.jp:

ssu...@preferred.jp

unread,
Jun 9, 2018, 6:23:26 PM6/9/18
to Chainer Japanese User Group
新田様

PFNの鈴木です。確認、ありがとうございます。
貼っていただいたログを見たところ、実行されたテスト少なすぎるので、ちゃんと実行できていないように感じます。
どのテストが実行されているのか確認するために以下のように-vを付けて実行することは可能でしょうか?

```
mpirun -n 2 pytest -v tests/chainermn_tests/communicator_tests/test_communicator.py
```
手元で最新版のChainerMNで確認したところ、全部で28個のテストが実行されるようです。

以上、よろしくお願いいたします。

2018年6月9日土曜日 21時10分18秒 UTC+9 Sho Nitta:

Sho Nitta

unread,
Jun 11, 2018, 9:11:08 PM6/11/18
to Chainer Japanese User Group
鈴木様

実行したところ、7つのテストしか行われていないようです。
ログを以下にはっておきます。

mpirun -n 2 pytest -v tests/chainermn_tests/communicator_tests/test_communicator.py
=======================  test_communicator.py  =======================
=======================  test_communicator.py  =======================
/usr/local/lib/python2.7/dist-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
/usr/local/lib/python2.7/dist-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
test_allreduce_cpu (test_communicator.TestNonContiguousArray) ... test_allreduce_cpu (test_communicator.TestNonContiguousArray) ... /usr/local/lib/python2.7/dist-packages/chainer/utils/experimental.py:105: FutureWarning: chainermn.communicators.CommunicatorBase.allreduce is experimental. The interface can change in the future.

  FutureWarning)
/usr/local/lib/python2.7/dist-packages/chainer/utils/experimental.py:105: FutureWarning: chainermn.communicators.CommunicatorBase.allreduce is experimental. The interface can change in the future.
  FutureWarning)
ok
ok
test_allreduce_gpu (test_communicator.TestNonContiguousArray) ... test_allreduce_gpu (test_communicator.TestNonContiguousArray) ... ok
test_alltoall_cpu (test_communicator.TestNonContiguousArray) ... ok
test_alltoall_cpu (test_communicator.TestNonContiguousArray) ... /usr/local/lib/python2.7/dist-packages/chainer/utils/experimental.py:105: FutureWarning: chainermn.communicators.MpiCommunicatorBase.alltoall is experimental. The interface can change in the future.

  FutureWarning)
/usr/local/lib/python2.7/dist-packages/chainer/utils/experimental.py:105: FutureWarning: chainermn.communicators.MpiCommunicatorBase.alltoall is experimental. The interface can change in the future.
  FutureWarning)
ok
ok
test_alltoall_gpu (test_communicator.TestNonContiguousArray) ... test_alltoall_gpu (test_communicator.TestNonContiguousArray) ... ok
ok
test_send_cpu (test_communicator.TestNonContiguousArray) ... test_send_cpu (test_communicator.TestNonContiguousArray) ... /usr/local/lib/python2.7/dist-packages/chainer/utils/experimental.py:105: FutureWarning: chainermn.communicators.MpiCommunicatorBase.send is experimental. The interface can change in the future.
  FutureWarning)
ok

/usr/local/lib/python2.7/dist-packages/chainer/utils/experimental.py:105: FutureWarning: chainermn.communicators.MpiCommunicatorBase.recv is experimental. The interface can change in the future.
  FutureWarning)
ok
test_send_gpu (test_communicator.TestNonContiguousArray) ... test_send_gpu (test_communicator.TestNonContiguousArray) ... ok
ok
test_invalid_allreduce_grad_dtype (test_communicator.TestPureNcclCommunicator) ... test_invalid_allreduce_grad_dtype (test_communicator.TestPureNcclCommunicator) ... ok
ok


----------------------------------------------------------------------
----------------------------------------------------------------------
Ran 7 tests in 0.014s

Ran 7 tests in 0.014s

OKOK

*******************************************************************************
*******************************************************************************

2018年6月10日日曜日 7時23分26秒 UTC+9 ssu...@preferred.jp:

ssu...@preferred.jp

unread,
Jun 12, 2018, 1:53:54 AM6/12/18
to Chainer Japanese User Group
新田様

PFNの鈴木です。
実行ありがとうございます。

肝心なテストが実行されていないようです。
このため以下のことを確認してもらってもよろしいでしょうか?

1. pytestのバージョンの確認
以下のコマンドでpytestのバージョンが確認できます。
$ pytest --version

私のバージョンは以下の通りです。
3.6.1

2. communicator_tests/test_communicator.pyがmasterと同じか?
tests/chainermn_tests/communicator_tests/test_communicator.pyの中身が同じかどうか確認してください。
特に、def test_communicator_gpu(param)があるかどうかを確認してください。

以上、よろしくお願いいたします。

2018年6月12日火曜日 10時11分08秒 UTC+9 Sho Nitta:

Sho Nitta

unread,
Jun 12, 2018, 2:30:22 AM6/12/18
to Chainer Japanese User Group
鈴木様

新田です。
pytestのバージョンを確認したところ、2.8.7でした。(pytest --versionができず、pip freezeで確認しました。)
なので、3.6.1にアップデート後以下のログでアップデートの確認が取れました。
***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
pytest --version
This is pytest version 3.6.1, imported from /usr/local/lib/python2.7/dist-packages/pytest.pyc
***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****

次にmasterと同じかについてなのですが、def test_communicator_gpu(param)はありました。
中身は同じかと思われます。

以上のことを確認後、再度前回教えていただいたチェックをしてみました。ログは以下の通りで、28個のチェック項目が読まれていそうです。
ただし、途中で実行でFAILEDになり、そこから進まない状態です。

mpirun -n 2 pytest -v tests/chainermn_tests/communicator_tests/test_communicator.py
============================= test session starts ==============================
platform linux2 -- Python 2.7.12, pytest-3.6.1, py-1.5.3, pluggy-0.6.0 -- /usr/bin/python
cachedir: .pytest_cache
rootdir: /mnt/d/chainermn, inifile:
============================= test session starts ==============================
platform linux2 -- Python 2.7.12, pytest-3.6.1, py-1.5.3, pluggy-0.6.0 -- /usr/bin/python
cachedir: .pytest_cache
rootdir: /mnt/d/chainermn, inifile:
collected 28 items                                                            
collecting 1 item                                                             
collected 28 items                                                             r_cpu[param0]

tests/chainermn_tests/communicator_tests/test_communicator.py::test_communicator_cpu[param0] PASSED [  3%]PASSED [  3%]
tests/chainermn_tests/communicator_tests/test_communicator.py::test_communicator_gpu[param0]
tests/chainermn_tests/communicator_tests/test_communicator.py::test_communicator_gpu[param0] PASSED [  7%]PASSED [  7%]
tests/chainermn_tests/communicator_tests/test_communicator.py::test_communicator_gpu[param1]
tests/chainermn_tests/communicator_tests/test_communicator.py::test_communicator_gpu[param1] FAILED [ 10%]
tests/chainermn_tests/communicator_tests/test_communicator.py::test_communicator_gpu[param2]


2018年6月12日火曜日 14時53分54秒 UTC+9 ssu...@preferred.jp:

ssu...@preferred.jp

unread,
Jun 12, 2018, 9:31:20 PM6/12/18
to Chainer Japanese User Group
新田様

PFNの鈴木です。
unittestの実行ありがとうございます。

テスト結果から、GPUのnaive communicator(param0)は正しく動作している一方、flat communicator(param1)が正しく動いていないので、やはりcommunicator周りで問題が発生しているようです。
しかもこの際、片方のプロセスだけFAILEDしていて、処理が固まるということはFAILEDしていないプロセスは正しく計算できているということになるかと思います。
初めて見る現象なため、お使いのpythonのパッケージのバージョンを確認したいのですが、`pip freeze` の出力結果を送っていただくことは可能でしょうか?

また、正確な原因はわからないものの、以下のようなことをすると解決する可能性はあります。
1.テスト結果や今までの出力結果から、現在使用中のCUDAのバージョンとOpenMPIのコンパイルのときに使用したCUDAのバージョン、CuPyのCUDAのバージョンがかみ合っていない可能性がある。
このため、OpenMPIの再コンパイルとCuPyの再コンパイルを試す。
2. インストールされているpythonのパッケージのバージョンが古い可能性もあるため、pyenv等を使って新しいpythonの環境を構築し直す。
3. お使いのOpenMPIはCUDAの一部の機能が正しく動作していないとバグ報告があるものなため、別のOpenMPIのバージョン(例えば、v2.1.3)を試す。

以上、よろしくお願いいたします。

2018年6月12日火曜日 15時30分22秒 UTC+9 Sho Nitta:

Sho Nitta

unread,
Jun 14, 2018, 2:22:08 AM6/14/18
to Chainer Japanese User Group
鈴木様

ご返信ありがとうございます。新田です。

`pip freeze`の結果は以下のようになりました。他に列挙していただいた解決する可能性のある
ものについては後日試させていただきます。

何卒よろしくお願いいたします。

新田

pip freeze
absl-py==0.2.0
adium-theme-ubuntu==0.3.4
alabaster==0.7.7
appdirs==1.4.3
astor==0.6.2
astroid==1.4.4
atomicwrites==1.1.5
attrs==18.1.0
audioread==2.1.5
Babel==1.3
backports-abc==0.5
backports.shutil-get-terminal-size==1.0.0
backports.weakref==1.0rc1
beautifulsoup4==4.4.1
bleach==1.5.0
certifi==2018.4.16
cffi==1.11.5
chainer==4.1.0
chainermn==1.3.0
chardet==2.3.0
cloudpickle==0.5.2
configparser==3.5.0
cupy==4.1.0
cvxopt==1.1.4
cycler==0.9.0
Cython==0.28.3
decorator==4.0.6
docutils==0.12
entrypoints==0.2.3
enum34==1.1.6
fastrlock==0.3
filelock==3.0.4
funcsigs==1.0.2
functools32==3.2.3.post2
future==0.16.0
futures==3.2.0
gast==0.2.0
grpcio==1.11.0
h5py==2.7.1
html5lib==0.9999999
ipykernel==4.8.2
ipython==5.6.0
ipython-genutils==0.2.0
ipywidgets==7.2.1
jdcal==1.0
jedi==0.9.0
Jinja2==2.8
joblib==0.9.4
jsonschema==2.6.0
jupyter==1.0.0
jupyter-client==5.2.3
jupyter-console==5.2.0
jupyter-core==4.4.0
Keras==2.0.0
lazy-object-proxy==1.2.1
librosa==0.6.0
llvmlite==0.23.0
logilab-common==1.1.0
lxml==3.5.0
Mako==1.0.7
Markdown==2.6.11
MarkupSafe==0.23
matplotlib==1.5.1
mercurial==3.7.3
mir-eval==0.4
mistune==0.8.3
mock==2.0.0
more-itertools==4.2.0
mpi4py==3.0.0
multiprocessing==2.6.2.1
nbconvert==5.3.1
nbformat==4.4.0
nose==1.3.7
notebook==5.4.1
numba==0.38.0
numexpr==2.4.3
numpy==1.14.3
numpydoc==0.8.0
opencv-contrib-python==3.4.1.15
opencv-python==3.4.1.15
openpyxl==2.3.0
pandas==0.17.1
pandocfilters==1.4.2
pathlib==1.0.1
pathlib2==2.3.2
patsy==0.4.1
pbr==4.0.2
pexpect==4.0.1
pickleshare==0.7.4
Pillow==3.1.2
pluggy==0.6.0
prompt-toolkit==1.0.15
protobuf==3.5.2.post1
psutil==3.4.2
ptyprocess==0.5
py==1.5.3
pycodestyle==2.4.0
pycparser==2.18
pycurl==7.43.0
pyflakes==1.1.0
Pygments==2.1
pylint==1.5.2
PyMySQL==0.7.2
PyOpenGL==3.1.0
pyparsing==2.0.3
pytest==3.6.1
python-dateutil==2.4.2
pytools==2018.4
pytz==2014.10
PyYAML==3.12
pyzmq==15.2.0
QtAwesome==0.4.4
qtconsole==4.3.1
QtPy==1.4.1
resampy==0.2.0
roman==2.0.0
rope==0.10.7
scandir==1.7
scikit-learn==0.19.1
scipy==1.1.0
seaborn==0.8.1
Send2Trash==1.5.0
simplegeneric==0.8.1
simplejson==3.8.1
singledispatch==3.4.0.3
six==1.11.0
SoundFile==0.10.2
Sphinx==1.3.6
sphinx-rtd-theme==0.1.9
spyder==3.2.8
statsmodels==0.6.1
tables==3.2.2
tensorboard==1.8.0
tensorflow==1.8.0
termcolor==1.1.0
terminado==0.8.1
testpath==0.3.1
Theano==1.0.1
torch==0.4.0
tornado==4.5.3
traitlets==4.3.2
unity-lens-photos==1.0
urllib3==1.22
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.14.1
widgetsnbextension==3.2.1
wrapt==1.8.0
xdot==0.6
xlrd==0.9.4
xlwt==0.7.5

2018年6月13日水曜日 10時31分20秒 UTC+9 ssu...@preferred.jp:
Reply all
Reply to author
Forward
0 new messages