2017년 6월 14일 수요일

MNIST를 이용한 GPU와 CPU의 deep learning 성능 차이 확인

MNIST (lenet training)

MNIST (Mixed National Institute of Standards and Technology database)
:  handwriting 숫자 이미지.  0~9까지의 손글씨 이미지 dataset
   - size-normalized, centered.
   - 28x28 size.  흑백(0,1)
   - 6만개 학습 data, 1만개 test data

여기서는 IBM PowerAI toolkit에 포함된 caffe 및 mnist example script를 사용합니다.

test home directory   /opt/DL/caffe-ibm

------------
1) mnist data download

/opt/DL/caffe-ibm/data/mnist$ ./get_mnist.sh

/opt/DL/caffe-ibm/data/mnist$ ls -la
total 53684
drwxrwxrwx 2 root     root     4096 Nov 14 19:13 .
drwxrwxrwx 5 root     root     4096 Nov 14 10:08 ..
-rwxrwxrwx 1 root     root      408 Oct 24 15:24 get_mnist.sh
-rw-r----- 1 b6p318za IBM1  7840016 Jul 21  2000 t10k-images-idx3-ubyte
-rw-r----- 1 b6p318za IBM1    10008 Jul 21  2000 t10k-labels-idx1-ubyte
-rw-r----- 1 b6p318za IBM1 47040016 Jul 21  2000 train-images-idx3-ubyte
-rw-r----- 1 b6p318za IBM1    60008 Jul 21  2000 train-labels-idx1-ubyte

2) mnist database 생성

먼저 아래 shell script의 일부를 수정합니다.

/opt/DL/caffe-ibm/examples/mnist$ vi create_mnist.sh
...
BUILD=bin
#BUILD=build/examples/mnist

그리고 그 script를 나서 수행합니다.

/opt/DL/caffe-ibm$ ./examples/mnist/create_mnist.sh
Creating lmdb...
I1214 10:15:56.708528 51473 db_lmdb.cpp:35] Opened lmdb examples/mnist/mnist_train_lmdb
I1214 10:15:56.708672 51473 convert_mnist_data.cpp:88] A total of 60000 items.
I1214 10:15:56.708679 51473 convert_mnist_data.cpp:89] Rows: 28 Cols: 28
I1214 10:15:57.020663 51473 convert_mnist_data.cpp:108] Processed 60000 files.
I1214 10:15:57.057901 51475 db_lmdb.cpp:35] Opened lmdb examples/mnist/mnist_test_lmdb
I1214 10:15:57.058055 51475 convert_mnist_data.cpp:88] A total of 10000 items.
I1214 10:15:57.058069 51475 convert_mnist_data.cpp:89] Rows: 28 Cols: 28
I1214 10:15:57.110440 51475 convert_mnist_data.cpp:108] Processed 10000 files.
Done.


3) 테스트를 CPU 로 할지 GPU 로 할지를 지정

/opt/DL/caffe-ibm$ vi ./examples/mnist/lenet_solver.prototxt
...
# solver mode: CPU or GPU
solver_mode: CPU
#solver_mode: GPU

4)  lenet training 수행

/opt/DL/caffe-ibm$ time ./examples/mnist/train_lenet.sh

-------------

GPU  :  real       26.62 user      3.89 system   0:19.56 elapsed   155% CPU
CPU  :  real  46554.36 user 1075.25 system 15:35.13 elapsed 5093% CPU

댓글 없음:

댓글 쓰기