2019년 1월 30일 수요일

IBM POWER8/9 (ppc64le) 환경에서의 Darknet 설치 및 test



Darknet은 C로 구현된 open source neural network famework입니다.  IBM POWER8 또는 POWER9, 즉 ppc64le 환경에서도 당연히 잘 설치됩니다.  여기서는 CentOS 7 on POWER8에서 구현했습니다.

설치는 source를 받아서 다음과 같이 compile 하기만 하면 됩니다.  Source를 수정할 필요 전혀 없습니다.

[bsyu@centos01 files]$ git clone https://github.com/pjreddie/darknet.git

[bsyu@centos01 files]$ cd darknet

[bsyu@centos01 darknet]$ make -j8

[bsyu@centos01 darknet]$ ./darknet
usage: ./darknet <function>

다만 혹시 GPU를 사용하고자 할 때는 아래와 같이 CUDA로 build되도록 Makefile을 살짝 수정해주시면 됩니다.  이 또한 ppc64le 환경에서도 build는 잘 됩니다만, 제가 가난하여 GPU가 없기 때문에 테스트는 이것으로 못했습니다.

[bsyu@centos01 darknet]$ vi Makefile
GPU=1   # default 0
CUDNN=1   # default 0
...

[bsyu@centos01 darknet]$ make -j8

[bsyu@centos01 darknet]$ ./darknet
usage: ./darknet <function>


CUDA 없이, 처음에 build한 CPU-only 버전으로도 darknet을 통해 YOLO를 테스트해볼 수 있습니다.   이 darknet 속에는 이미 YOLO를 위한 cfg 파일과 샘플용 멍멍이 사진이 들어있거든요.

[bsyu@centos01 darknet]$  ls -l cfg/yolov3.cfg data/dog.jpg
-rw-r--r-- 1 bsyu bsyu   8342 Jan 30 15:19 cfg/yolov3.cfg
-rw-r--r-- 1 bsyu bsyu 163759 Jan 30 15:19 data/dog.jpg

이 dog.jpg를 download 받아보면 아래와 같습니다.



이제 테스트를 위해, 미리 멍멍이를 감지하도록 YOLO v3로 pre-train된 weight file을 download 합니다.

[bsyu@centos01 darknet]$ wget https://pjreddie.com/media/files/yolov3.weights

이것으로 data/dog.jpg 사진 속의 object를 'detect' 하는 명령을 내려보겠습니다.

[bsyu@centos01 darknet]$ ./darknet detect cfg/yolov3.cfg yolov3.weights data/dog.jpg
layer     filters    size              input                output
    0 conv     32  3 x 3 / 1   608 x 608 x   3   ->   608 x 608 x  32  0.639 BFLOPs
    1 conv     64  3 x 3 / 2   608 x 608 x  32   ->   304 x 304 x  64  3.407 BFLOPs
    2 conv     32  1 x 1 / 1   304 x 304 x  64   ->   304 x 304 x  32  0.379 BFLOPs
    3 conv     64  3 x 3 / 1   304 x 304 x  32   ->   304 x 304 x  64  3.407 BFLOPs
    4 res    1                 304 x 304 x  64   ->   304 x 304 x  64
    5 conv    128  3 x 3 / 2   304 x 304 x  64   ->   152 x 152 x 128  3.407 BFLOPs
    6 conv     64  1 x 1 / 1   152 x 152 x 128   ->   152 x 152 x  64  0.379 BFLOPs
...
  104 conv    256  3 x 3 / 1    76 x  76 x 128   ->    76 x  76 x 256  3.407 BFLOPs
  105 conv    255  1 x 1 / 1    76 x  76 x 256   ->    76 x  76 x 255  0.754 BFLOPs
  106 yolo
Loading weights from yolov3.weights...Done!
data/dog.jpg: Predicted in 27.192135 seconds.
dog: 100%
truck: 92%
bicycle: 99%

우리가 OpenCV로 darknet을 build하지 않았기 때문에 직접 사진이 나오지는 않지만 darknet은 predictions.jpg로 그 결과를 저장합니다.

[bsyu@centos01 darknet]$ ls -ltr | tail -n 3
-rwxr-xr-x 1 bsyu bsyu    719872 Jan 30 15:29 libdarknet.so
-rwxr-xr-x 1 bsyu bsyu    841976 Jan 30 15:29 darknet
-rw-r--r-- 1 bsyu bsyu    119208 Jan 30 15:41 predictions.jpg

이 predictions.jpg을 PC로 download 받아보면 그 결과는 아래와 같습니다.



댓글 2개: