google colaboratoryはどれだけ速いのか試してみた

google colaboratoryが自機と比べてどれだけ速いのか試してみた。
メモリ4GでGPU無しの愛機

Downloading data from https://s3.amazonaws.com/img-datasets/mnist.npz
11493376/11490434 [==============================] - 13s 1us/step
x_train shape: (60000, 28, 28, 1)
Training samples: 60000
Test samples: 10000
Train on 60000 samples, validate on 10000 samples
Epoch 1/12
 - 1245s - loss: 0.2732 - acc: 0.9164 - val_loss: 0.0561 - val_acc: 0.9824
Epoch 2/12
 - 1301s - loss: 0.0917 - acc: 0.9725 - val_loss: 0.0445 - val_acc: 0.9846
Epoch 3/12
 - 1213s - loss: 0.0680 - acc: 0.9797 - val_loss: 0.0410 - val_acc: 0.9868
Epoch 4/12
 - 1175s - loss: 0.0568 - acc: 0.9827 - val_loss: 0.0313 - val_acc: 0.9895
Epoch 5/12
 - 1099s - loss: 0.0494 - acc: 0.9857 - val_loss: 0.0309 - val_acc: 0.9902
Epoch 6/12
 - 835s - loss: 0.0447 - acc: 0.9868 - val_loss: 0.0294 - val_acc: 0.9911
Epoch 7/12
 - 532s - loss: 0.0391 - acc: 0.9880 - val_loss: 0.0276 - val_acc: 0.9910
Epoch 8/12
 - 532s - loss: 0.0342 - acc: 0.9895 - val_loss: 0.0319 - val_acc: 0.9900
Epoch 9/12
 - 525s - loss: 0.0313 - acc: 0.9903 - val_loss: 0.0308 - val_acc: 0.9901
Epoch 10/12
 - 514s - loss: 0.0292 - acc: 0.9905 - val_loss: 0.0309 - val_acc: 0.9903
Epoch 11/12
 - 507s - loss: 0.0272 - acc: 0.9914 - val_loss: 0.0283 - val_acc: 0.9910
Epoch 12/12
 - 510s - loss: 0.0267 - acc: 0.9915 - val_loss: 0.0294 - val_acc: 0.9908
Test loss: 0.0293593391158749
Test accuracy: 0.9908
Elapsed time: 2:47:09.25
CPU times: user 3h 19min 27s, sys: 2h 52min 5s, total: 6h 11min 32s
Wall time: 2h 47min 9s

google colaboratory

Downloading data from https://s3.amazonaws.com/img-datasets/mnist.npz
11493376/11490434 [==============================] - 1s 0us/step
x_train shape: (60000, 28, 28, 1)
Training samples: 60000
Test samples: 10000
Train on 60000 samples, validate on 10000 samples
Epoch 1/12
 - 12s - loss: 0.2669 - acc: 0.9181 - val_loss: 0.0531 - val_acc: 0.9831
Epoch 2/12
 - 11s - loss: 0.0861 - acc: 0.9738 - val_loss: 0.0415 - val_acc: 0.9866
Epoch 3/12
 - 11s - loss: 0.0669 - acc: 0.9797 - val_loss: 0.0408 - val_acc: 0.9853
Epoch 4/12
 - 11s - loss: 0.0539 - acc: 0.9837 - val_loss: 0.0304 - val_acc: 0.9892
Epoch 5/12
 - 11s - loss: 0.0472 - acc: 0.9857 - val_loss: 0.0300 - val_acc: 0.9903
Epoch 6/12
 - 11s - loss: 0.0417 - acc: 0.9875 - val_loss: 0.0327 - val_acc: 0.9892
Epoch 7/12
 - 11s - loss: 0.0375 - acc: 0.9880 - val_loss: 0.0275 - val_acc: 0.9903
Epoch 8/12
 - 11s - loss: 0.0342 - acc: 0.9895 - val_loss: 0.0288 - val_acc: 0.9909
Epoch 9/12
 - 11s - loss: 0.0316 - acc: 0.9903 - val_loss: 0.0268 - val_acc: 0.9907
Epoch 10/12
 - 11s - loss: 0.0297 - acc: 0.9906 - val_loss: 0.0273 - val_acc: 0.9921
Epoch 11/12
 - 11s - loss: 0.0274 - acc: 0.9912 - val_loss: 0.0293 - val_acc: 0.9912
Epoch 12/12
 - 11s - loss: 0.0258 - acc: 0.9919 - val_loss: 0.0275 - val_acc: 0.9914
Test loss: 0.02745042288389286
Test accuracy: 0.9914
Elapsed time: 0:02:16.64
CPU times: user 1min 28s, sys: 52.7 s, total: 2min 21s
Wall time: 2min 16s

愛機が167分かかる処理を、google colaboratoryは約2分で83倍処理が速いことになる。惨憺たる結果である。GPUがあるとないではここまで差があるのかと愕然とさせられた。処理に時間がかかるプログラムはgoogle colaboratoryで実行するのが良いと言える。

google colaboratoryは機械学習プログラミングにはもってこいのツールだろう。

スポンサーリンク