LoginSignup
6
1

More than 5 years have passed since last update.

AWSのp2・p3インスタンスのベンチマーク

Posted at

DeepLearning用にAWSでp系インスタンスを使うのですが、p2インスタンスとp3インスタンスのどちらを使うべきなのか迷うことがあったのでベンチマークを取ってみました。

環境情報

  • リージョン:オレゴン
  • AMI:Deep Learning AMI (Ubuntu) Version 8.0 - ami-0bbbd373 (Amazon AMIs)
  • インスタンス:p2.xlarge・p3.2xlarge
    • スポットインスタンスを利用
    • 参考情報ですが、実験時p2.xlargeが$0.2783、p3.2xlargeが$1.0159でした(もちろん変動しますのでご注意を)
  • EBS:gp2 100GB
    • 最適化なし・暗号化なし。

ベンチマーク結果

TensorFlowのResNetの学習(+推論)を使って計測しました。
データセットは CIFAR-10 です。
※実験の詳細な手順は後述しています。

結果は以下のようになりました。5回実行した結果の平均時間です。

p2.xlarge p3.2xlarge
179.10 sec 74.16 sec

画像処理においては、p2.xlargeをp3.2xlargeにするとざっくり 2倍強の速度が出る という結果となりました。
選択の際の目安程度にはなるかと思います。

ベンチマーク計測手順

ご興味がある人はご確認ください。以下、p2インスタンス・p3インスタンス共に共通です。

# p系インスタンスにSSHしておく

# TensorFlow(+Keras2) with Python3 (CUDA 9/MKL)に切り替え
source activate tensorflow_p36

# tensorflow/modelsをclone(実行環境のTensorFlowのバージョンに合わせる)
git clone -b r1.7.0 https://github.com/tensorflow/models.git

# tensorflow/modelsの環境設定
export PYTHONPATH="$PYTHONPATH:/home/ubuntu/models:/home/ubuntu/models/official"
cd models/official/resnet

# データセットを取得
python cifar10_download_and_extract.py

# 一部書き換え
vim cifar10_main.py

# 実行
python cifar10_main.py --resnet_size 14 --train_epochs 10

vimで以下のように書き換えてます。

$ git diff
diff --git a/official/resnet/cifar10_main.py b/official/resnet/cifar10_main.py
index 443a251..7c984d8 100644
--- a/official/resnet/cifar10_main.py
+++ b/official/resnet/cifar10_main.py
@@ -222,8 +222,12 @@ def main(argv):
   flags = parser.parse_args(args=argv[1:])

   input_function = flags.use_synthetic_data and get_synth_input_fn() or input_fn
-  resnet_run_loop.resnet_main(flags, cifar10_model_fn, input_function)

+  import timeit
+  loop=5
+  result = timeit.timeit(lambda: resnet_run_loop.resnet_main(flags, cifar10_model_fn, input_function), number=loop)
+  print(result / loop)
6
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
1