레이블이 Poughkeepsie인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Poughkeepsie인 게시물을 표시합니다. 모든 게시물 표시

2018년 9월 6일 목요일

Poughkeepsie 센터에서 LSF cluster 이용하여 tensorflow 수행하는 방법 안내

** 이는 IBM Poughkeepsie benchmark center의 cluster에서 LSF를 이용해 테스트를 수행하시는 분들을 위한 guide입니다.


먼저 별도로 통보받으신 VPN SW와 VPN id/passwd를 이용해 Poughkeepsie benchmark center cluster에 VPN 연결을 하셔야 합니다.

그 다음에, 이미 통보받으신대로 p10login4.pbm.ihost.com 라는 주소로 putty 등을 이용해 ssh 접속을 하십시요.   (아래 그림 참조)



접속할 때의 userid 및 passwd는 VPN id/passwd와는 별도로 통보받으신 userid/passwd (서버 linux OS용) 입니다.

p10login4에 접속하신 뒤, 먼저 anaconda3를 설치하시기 바랍니다.  설치하실 때 default로 제시되는 directory를 그대로 이용하시는 것이 좋습니다.  이유는 /gpfs/gpfs_gl4_16mb/ 밑의 directory가 GPFS(요즘 이름은 Spectrum Scale)라는 공유파일시스템로서 cluster 내의 모든 work node에 mount 되어 있는 것이기 때문입니다.  거기에 설치해야 나중에 어느 work node에서 job을 수행하더라도 이 anaconda를 사용하실 수 있습니다.

[b8p217za@p10login4 ~]$ wget https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-ppc64le.sh

[b8p217za@p10login4 ~]$ chmod a+x Anaconda3-5.2.0-Linux-ppc64le.sh

[b8p217za@p10login4 ~]$ ./Anaconda3-5.2.0-Linux-ppc64le.sh
...
[/gpfs/gpfs_gl4_16mb/b8p217/b8p217za/anaconda3] >>>
...
Do you wish the installer to prepend the Anaconda3 install location
to PATH in your /gpfs/gpfs_gl4_16mb/b8p217/b8p217za/.bashrc ? [yes|no]
[no] >>> yes

설치가 끝난 뒤에는 .bashrc을 다시 수행하셔서 기본 python이 anaconda3에서 나오는 것인지 확인하십시요.

[b8p217za@p10login4 ~]$ . /gpfs/gpfs_gl4_16mb/b8p217/b8p217za/.bashrc

[b8p217za@p10login4 ~]$ which python
~/anaconda3/bin/python

그 다음으로는 tensorflow 운용에 필요한 dependent package들을 설치하셔야 합니다.  다음의 명령을 내리시면 됩니다.

[b8p217za@p10login4 ~]$ /opt/DL/tensorflow/bin/install_dependencies
...

The following NEW packages will be INSTALLED:

    absl-py:                    0.1.10-py36_0              file://opt/DL/conda-pkgs
    astor:                      0.6.2-py_0                 file://opt/DL/conda-pkgs
    blas:                       1.0-openblas
    gast:                       0.2.0-py36_0               file://opt/DL/conda-pkgs
    grpcio:                     1.10.0-py36hf484d3e_0      file://opt/DL/conda-pkgs
    libprotobuf:                3.5.0-hf484d3e_0           file://opt/DL/conda-pkgs
    powerai-tensorflow-prereqs: 1.8.0_31721.7987738-py36_0 file:///opt/DL/tensorflow/conda-pkgs
    protobuf:                   3.5.0-py36_0               file://opt/DL/conda-pkgs
    termcolor:                  1.1.0-py36_0               file://opt/DL/conda-pkgs
    toposort:                   1.5-py36_0                 file://opt/DL/conda-pkgs
...
Proceed ([y]/n)? y


이제 tensorflow를 사용하시기 위해 환경변수 설정 script를 다음과 같이 수행하십시요.   이 script를 수행하시면 아래와 같이 PATH, PYTHONPATH들이 설정되면서 PowerAI에 포함된 tensorflow를 사용하실 수 있게 됩니다.

[b8p217za@p10login4 ~]$ source /opt/DL/tensorflow/bin/tensorflow-activate

[b8p217za@p10login4 ~]$ env | grep PATH
MANPATH=/vol/ibmplatform/lsf/10.1/man:/usr/share/lmod/lmod/share/man::
MODULEPATH_ROOT=/gpfs/gpfs_gl4_16mb/lmod/P8
LD_LIBRARY_PATH=/vol/ibmplatform/lsf/10.1/linux3.10-glibc2.17-ppc64le/lib:/usr/local/cuda-9.2/lib64:/usr/local/cuda-9.2/extras/CUPTI/lib64:/opt/DL/tensorflow/lib
PATH=/gpfs/gpfs_gl4_16mb/b8p217/b8p217za/anaconda3/bin:/vol/ibmplatform/lsf/10.1/linux3.10-glibc2.17-ppc64le/etc:/vol/ibmplatform/lsf/10.1/linux3.10-glibc2.17-ppc64le/bin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/ibutils/bin:/gpfs/gpfs_gl4_16mb/b8p217/b8p217za/.local/bin:/gpfs/gpfs_gl4_16mb/b8p217/b8p217za/bin:/opt/DL/tensorflow/bin
MODULEPATH=/etc/modulefiles:/usr/share/modulefiles:/gpfs/gpfs_gl4_16mb/lmod/P8/Linux:/gpfs/gpfs_gl4_16mb/lmod/P8/Core:/gpfs/gpfs_gl4_16mb/lmod/P8/rhel/7.5/core
PYTHONPATH=/opt/DL/tensorflow/lib/python3.6/site-packages:/opt/DL/tensorflow/lib/python3.6/site-packages/external/protobuf_archive/python:/opt/DL/tensorflow/lib/python3.6/site-packages/external/six_archive

이제 tensorflow를 사용하실 준비가 끝났습니다.   그러나 이 서버에서 직접 tensorflow training을 수행하시면 안 됩니다.  이 서버는 어디까지나 login 서버일 뿐, V100이 장착된 AC922 서버가 아닙니다.  다음과 같이 job scheduler인 LSF에게 job을 submit 하는 방식으로 training을 수행하셔야 합니다.

먼저, 수행하실 tensorflow python code를 확인하십시요.   여기서는 아래의 cnn_mnist_lms.py를 LSF로 수행하는 것을 해보겠습니다.  참고로, 이 cnn_mnist_lms.py는 /opt/DL/tensorflow/lib/python3.6/site-packages/tensorflow/examples/tutorials/layers/cnn_mnist.py를 LMS로 변환한 example code입니다.

[b8p217za@p10login4 ~]$ ls -l /opt/DL/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/lms/examples/cnn_mnist_lms.py
-rw-r--r-- 1 root root 6203 Jun  5 08:31 /opt/DL/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/lms/examples/cnn_mnist_lms.py

위 code를 LSF로 수행하시려면 다음과 같이 하시면 됩니다.   즉 아래의 파란색 부분만 덧붙이시면 됩니다.

[b8p217za@p10login4 ~]$ bsub -R "rusage[ngpus_excl_p=4]" -q ac922_v100 -o ./1.out -e ./1.err python /opt/DL/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/lms/examples/cnn_mnist_lms.py
Job <243511> is submitted to queue <ac922_v100>.

-q는 queue 이름입니다.  안내받으신 대로 ac922_v100을 쓰시면 됩니다.  -o는 output file을, -e는 error message file을 지정합니다.

결과물은 위에서 지정한 대로라면 login 서버의 현재 directory에 1.out이라는 file에 저장되고, 혹시 error가 생겼다면 그 메시지는 1.err라는 file에 저장됩니다.

그리고 "rusage[ngpus_excl_p=4]" 라는 것은 GPU 4개를 exclusive mode로 쓰려고 하니 가용한 GPU 개수가 4개인 서버에서 수행하라는 뜻입니다.  만약 1개만 쓰실 거라면 그 숫자를 1로 지정하시면 됩니다.  만약 MPI로 작성하신 code를 mpirun 명령을 통해 돌리시는 거라면, AC922 1대에 설치된 GPU 개수가 4장이지만 ngpus_excl_p=8 또는 12 등 4보다 더 큰 숫자로 두셔도 됩니다.  물론 보통의 deep learning training에서는 4개 이하를 쓰시겠지요.

위의 job number에 대해서 bhist 명령을 내리면 job이 어느 work node로 allocation되었는지 또 언제 시작되었고 (만약 끝났다면) 언제 끝났는지 알 수 있습니다.  아래의 경우는 p10a02라는 work node에 할당되었으나, 뭔가 문제가 있어서 시작된지 6초만에 fail 났습니다.

[b8p217za@p10login4 ~]$ bhist -l 243511

Job <243511>, User <b8p217za>, Project <default>, Command <python /opt/DL/tenso
                     rflow/lib/python3.6/site-packages/tensorflow/contrib/lms/e
                     xamples/cnn_mnist_lms.py>
Wed Sep  5 22:45:59: Submitted from host <p10login4>, to Queue <ac922_v100>, CW
                     D <$HOME>, Output File <./1.out>, Error File <./1.err>, Re
                     quested Resources <rusage[ngpus_excl_p=4]>;
Wed Sep  5 22:45:59: Dispatched 1 Task(s) on Host(s) <p10a02>, Allocated 1 Slot
                     (s) on Host(s) <p10a02>, Effective RES_REQ <select[type ==
                      local] order[r15s:pg] rusage[ngpus_excl_p=4.00] >;
Wed Sep  5 22:46:00: Starting (Pid 7426);
Wed Sep  5 22:46:06: External Message "p10a02:gpus=0,1,2,3;" was posted from "b
                     8p217za" to message box 0;
Wed Sep  5 22:46:06: Running with execution home </gpfs/gpfs_gl4_16mb/b8p217/b8
                     p217za>, Execution CWD </gpfs/gpfs_gl4_16mb/b8p217/b8p217z
                     a>, Execution Pid <7426>;
Wed Sep  5 22:46:06: Exited with exit code 2. The CPU time used is 0.4 seconds;
Wed Sep  5 22:46:06: Completed <exit>;

MEMORY USAGE:
MAX MEM: 7 Mbytes;  AVG MEM: 7 Mbytes

Summary of time in seconds spent in various states by  Wed Sep  5 22:46:06
  PEND     PSUSP    RUN      USUSP    SSUSP    UNKWN    TOTAL
  0        0        7        0        0        0        7

Error가 난 이유는 아래와 같이 해당 example code가 work node인 p10a02 서버의 local directory에 설치되어 있지 않기 때문입니다.

[b8p217za@p10login4 ~]$ cat 1.err
python: can't open file '/opt/DL/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/lms/examples/cnn_mnist_lms.py': [Errno 2] No such file or directory

위 error를 수정하기 위해 POK center에 연락하여 각 node들에서 # yum install power-mldl-py3로 필요 fileset들의 update를 요청했습니다.   (sudo 권한이 필요한 일입니다.)

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

POK center로부터 update 수행했다는 연락을 받았고, 다시 수행해본 수행 결과는 아래와 같습니다.

[b8p217za@p10login4 ~]$ bsub -R "rusage[ngpus_excl_p=4]" -q ac922_v100 -o ./1.out -e ./1.err python /opt/DL/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/lms/examples/cnn_mnist_lms.py
Job <244143> is submitted to queue <ac922_v100>.


[b8p217za@p10login4 ~]$ bhist -l 244143

Job <244143>, User <b8p217za>, Project <default>, Command <python /opt/DL/tenso
                     rflow/lib/python3.6/site-packages/tensorflow/contrib/lms/e
                     xamples/cnn_mnist_lms.py>
Thu Sep  6 21:27:03: Submitted from host <p10login4>, to Queue <ac922_v100>, CW
                     D <$HOME>, Output File <./1.out>, Error File <./1.err>, Re
                     quested Resources <rusage[ngpus_excl_p=4]>;
Thu Sep  6 21:27:04: Dispatched 1 Task(s) on Host(s) <p10a01>, Allocated 1 Slot
                     (s) on Host(s) <p10a01>, Effective RES_REQ <select[type ==
                      local] order[r15s:pg] rusage[ngpus_excl_p=4.00] >;
Thu Sep  6 21:27:05: Starting (Pid 76857);
Thu Sep  6 21:27:12: External Message "p10a01:gpus=0,1,2,3;" was posted from "b
                     8p217za" to message box 0;
Thu Sep  6 21:27:12: Running with execution home </gpfs/gpfs_gl4_16mb/b8p217/b8
                     p217za>, Execution CWD </gpfs/gpfs_gl4_16mb/b8p217/b8p217z
                     a>, Execution Pid <76857>;
Thu Sep  6 21:29:28: Done successfully. The CPU time used is 204.2 seconds;
Thu Sep  6 21:29:35: Post job process done successfully;

MEMORY USAGE:
MAX MEM: 4.2 Gbytes;  AVG MEM: 3 Gbytes

Summary of time in seconds spent in various states by  Thu Sep  6 21:29:35
  PEND     PSUSP    RUN      USUSP    SSUSP    UNKWN    TOTAL
  1        0        144      0        0        0        145


1초 만에 "p10a01" node로 dispatch 되어 2분 16초 만에 성공적으로 training을 완료했습니다.  

결과물이 저장되는 1.out 파일을 열어보면 아래와 같은 내용이 담겨 있습니다.  


[b8p217za@p10login4 ~]$ cat 1.out

Sender: LSF System <p10lsf@p10a01>
Subject: Job 244143: <python /opt/DL/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/lms/examples/cnn_mnist_lms.py> in cluster <pok_tc_cloud> Done

Job <python /opt/DL/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/lms/examples/cnn_mnist_lms.py> was submitted from host <p10login4> by user <b8p217za> in cluster <pok_tc_cloud> at Thu Sep  6 21:27:03 2018.
Job was executed on host(s) <p10a01>, in queue <ac922_v100>, as user <b8p217za> in cluster <pok_tc_cloud> at Thu Sep  6 21:27:04 2018.
</gpfs/gpfs_gl4_16mb/b8p217/b8p217za> was used as the home directory.
</gpfs/gpfs_gl4_16mb/b8p217/b8p217za> was used as the working directory.
Started at Thu Sep  6 21:27:04 2018.
Terminated at Thu Sep  6 21:29:29 2018.
Results reported at Thu Sep  6 21:29:29 2018.

Your job looked like:

------------------------------------------------------------
# LSBATCH: User input
python /opt/DL/tensorflow/lib/python3.6/site-packages/tensorflow/contrib/lms/examples/cnn_mnist_lms.py
------------------------------------------------------------

Successfully completed.

Resource usage summary:

    CPU time :                                   204.17 sec.
    Max Memory :                                 4393 MB
    Average Memory :                             3106.20 MB
    Total Requested Memory :                     -
    Delta Memory :                               -
    Max Swap :                                   -
    Max Processes :                              3
    Max Threads :                                346
    Run time :                                   147 sec.
    Turnaround time :                            146 sec.

The output (if any) follows:

Successfully downloaded train-images-idx3-ubyte.gz 9912422 bytes.
Extracting MNIST-data/train-images-idx3-ubyte.gz
Successfully downloaded train-labels-idx1-ubyte.gz 28881 bytes.
Extracting MNIST-data/train-labels-idx1-ubyte.gz
Successfully downloaded t10k-images-idx3-ubyte.gz 1648877 bytes.
Extracting MNIST-data/t10k-images-idx3-ubyte.gz
Successfully downloaded t10k-labels-idx1-ubyte.gz 4542 bytes.
Extracting MNIST-data/t10k-labels-idx1-ubyte.gz
Saving graph to: /tmp/tmpeuq76pnh
{'accuracy': 0.96890002, 'loss': 0.10233325, 'global_step': 20000}


PS:

Read file <./1.err> for stderr output of this job.


그리고 training 과정 중의 메시지는 아래와 같이 1.err에 저장됩니다.   여기서는 일부만 copy & paste 했습니다.

[b8p217za@p10login4 ~]$ cat 1.err
...
INFO:tensorflow:Saving checkpoints for 20000 into /tmp/tmpeuq76pnh/model.ckpt.
INFO:tensorflow:Loss for final step: 0.103957.
INFO:tensorflow:Calling model_fn.
INFO:tensorflow:Done calling model_fn.
INFO:tensorflow:Starting evaluation at 2018-09-07-01:29:27
INFO:tensorflow:Graph was finalized.
2018-09-06 21:29:27.207180: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1435] Adding visible gpu devices: 0, 1, 2, 3
2018-09-06 21:29:27.207305: I tensorflow/core/common_runtime/gpu/gpu_device.cc:923] ...
2018-09-06 21:29:27.208973: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1053] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:3 with 14127 MB memory) -> physical GPU (device: 3, name: Tesla V100-SXM2-16GB, pci bus id: 0035:04:00.0, compute capability: 7.0)
INFO:tensorflow:Restoring parameters from /tmp/tmpeuq76pnh/model.ckpt-20000
INFO:tensorflow:Running local_init_op.
INFO:tensorflow:Done running local_init_op.
INFO:tensorflow:Finished evaluation at 2018-09-07-01:29:27
INFO:tensorflow:Saving dict for global step 20000: accuracy = 0.9689, global_step = 20000, loss = 0.102333


2017년 8월 2일 수요일

IBM Poughkeepsie 벤치마크 센터에서의 LSF를 이용한 deep learning training 수행

이번 posting에서는 IBM Poughkeepsie (POK) 벤치마크 센터를 이용하여 Minsky 서버를 이용한 deep learning 성능 벤치마크 테스트를 수행하는 방법에 대해 알아보겠습니다.  단, 여기서의 주 내용은 POK 센터 수퍼컴 클러스터의 개략적인 GPFS 및 LSF 환경 및 그 사용방법에 대한 가이드일 뿐이고, 이 수퍼컴을 사용하기 위한 신청/승인 절차는 다루지 않습니다.   이 수퍼컴 클러스터는 IBM HW/SW의 구매를 고려 중이신 고객분들의 capacity sizing 등 각종 PoC와 performance benchmark test를 위해 사용됩니다.

먼저, IBM 영업측을 통해서 POK 벤치마크 센터의 사용 승인을 받으시면 VPN 연결 방법 및 관련 id/passwd를 받게 됩니다.

VPN 연결 뒤에 연결하셔야 하는 서버는 실제로 고객분이 성능 테스트를 수행하실 서버가 아니라, login 서버라고 하는 서버입니다.  POK 벤치마크 센터의 수퍼컴은 수십대의 POWER8 서버로 되어 있는데, 고객분들은 이 서버들 중 하나를 할당 받는 형태로 테스트를 하는 것이 아니라 이 서버들의 computing power를 LSF라고 하는 job scheduler를 통해 할당받는 것입니다.  고객분들이 접속하시는 이 login 서버는 job scheduler의 master 서버 역할을 하며, 여기서는 다음과 같은 것을 수행하실 수 있습니다.

- 수행하려는 application과 data의 컴파일 및 설치
- 수행를 위해 필요한 shell script 등의 작성과 간단한 동작 여부 테스트

간혹 이 login 서버에서 아예 성능 테스트를 돌려버리시는 분들이 있는데, 그럴 경우 제대로 된 성능을 얻기 어려울 뿐만 아니라 이 수퍼컴을 이용하시는 전세계의 많은 다른 고객분들께도 폐를 끼치는 행위가 되므로 절대 그러지 마시기를 부탁드립니다.  많은 수퍼컴 클러스터에서는 그런 일을 막기 위해 login 서버의 사양을 일부러 작은 것으로 하거나 GPU가 달려 있지 않은 것으로 구성하기도 합니다.

이 login 서버와 수퍼컴 노드들은 모두 Spetrum Scale (옛이름 GPFS)라는 병렬파일시스템으로 묶여있습니다.  즉, 어느 서버에 login하더라도 (내장 disk를 이용한 일부 파일시스템을 제외하고는) 모두 같은 파일시스템이 마운트 되어 있는 것을 보실 수 있으며, login 서버에서 저장해 놓은 파일들은 수퍼컴 내의 어느 서버에서도 다 read/write할 수 있습니다.  물론 각 user id도 login 서버와 수퍼컴 노드들에서 다 동일하게 만들어져 있고, user의 홈 디렉토리도 이 GPFS 파일시스템으로 되어 있으므로 login 서버의 홈 디렉토리에 저장된 내용은 어느 노드에서라도 다 동일하게 보실 수 있습니다.

Login 서버에 접속하시면 다음과 같이 여러 filesystem들이 마운트 되어 있는 것을 보실 수 있습니다.  그 중 앞이 /gpfs 로 시작되는 파일시스템들이 Spectrum Scale (GPFS) 파일시스템들입니다.  고객분은 시스템 userid/passwd를 받으실 때 어느 특정 GPFS 파일시스템을 사용하라는 가이드를 받으실 것입니다.  대부분의 경우, /gpfs/gpfs_gl4_16mb를 사용하라는 가이드를 받으실 것이고, 또 홈 디렉토리가 이미 그 파일시스템으로 잡혀 있을 것입니다.

b7p193aa@p10login1:~$ pwd
/gpfs/gpfs_gl4_16mb/home/b7p193aa

b7p193aa@p10login1:~$ df -h
Filesystem                                    Size  Used Avail Use% Mounted on
udev                                          243G     0  243G   0% /dev
tmpfs                                          52G  778M   51G   2% /run
/dev/sda2                                     879G   42G  793G   5% /
tmpfs                                         256G   17M  256G   1% /dev/shm
tmpfs                                         5.0M     0  5.0M   0% /run/lock
tmpfs                                         256G     0  256G   0% /sys/fs/cgroup
cgmfs                                         128K     0  128K   0% /run/cgmanager/fs
fserv3.pbm.ihost.com:/export/ibmplatform       98G   38G   61G  39% /vol/ibmplatform
tmpfs                                          52G     0   52G   0% /run/user/0
gpfs_gl4_16mb_bench                           221T  123T   98T  56% /gpfs/gpfs_gl4_16mb_bench
gpfs_gl4_8mb                                   75T   23T   53T  30% /gpfs/gpfs_gl4_8mb
gpfs_gs2_512k                                 2.1T  1.9T  130G  94% /gpfs/gpfs_gs2_512k
gpfs_stage1                                    66T   57T  8.7T  87% /gpfs/gpfs_stage1
gpfs_2gl4_8mb                                  61T  8.6T   52T  15% /gpfs/gpfs_2gl4_8mb
gpfs_gl4_16mb                                 165T  126T   39T  77% /gpfs/gpfs_gl4_16mb
/dev/nvme0n1p1                                2.9T  332M  2.8T   1% /nvme3T
....

이 수퍼컴 클러스터 내의 노드들의 사양과 OS 등은 용도/그룹별로 서로 약간 다릅니다.  일부는 전통적 HPC 테스트를 위해 Redhat OS가 설치되어 있고, 일부는 deep learning을 위해 Ubuntu 16.04와 함께 IBM PowerAI toolkit이 설치되어 있습니다.  그 중 어느 쪽에 login 해야 하느냐는 고민하실 필요가 없습니다.  왜냐하면 해당 노드들에는 직접 login 하실 일이 없고, login 노드에서의 LSF job submit 형태로만 이용을 하시게 되거든요.  이제 그 과정을 찬찬히 보시겠습니다.

LSF는 job scheduler SW이고, 이를 이용하시려면 몇가지의 간단한 명령어만 익히시면 사용 가능하십니다.  특히 1대의 노드만을 이용하여 deep learning을 하시는 분들께서는 매우 간단한 명령 몇개만 아시면 됩니다.

bqueues : job을 submit할 큐의 정보를 보여줍니다
bsub : job을 큐에 submit 해줍니다
bjobs : 큐에 submit된 job의 상태를 보여줍니다
bhist : 현재 수행 중인, 혹은 이미 수행이 끝난 job의 history를 보여줍니다
bkill : submit되어 현재 수행 중인 상태의 job을 도중에 kill 시켜 줍니다
bhosts : 수퍼컴 클러스터 내의 노드들 상황을 보여줍니다.

이제 자세히 보시겠습니다.  이 수퍼컴 클러스터에서 job을 submit할 queue에 어떤 것들이 있는지 bqueues 명령을 통해 보실 수 있습니다.

b7p193aa@p10login1:~$ bqueues
QUEUE_NAME      PRIO STATUS          MAX JL/U JL/P JL/H NJOBS  PEND   RUN  SUSP
test-stream      30  Open:Inact        -    -    -    -     0     0     0     0
s822lc_p100_k80  30  Open:Active       -    -    -    -  8616  6568  2048     0
822normal        30  Open:Inact        -    -    -    -     0     0     0     0
s822lc_p100      30  Open:Active       -    -    -    -     3     0     3     0
s822lc_p100nvme  30  Open:Active       -    -    -    -   151     0   151     0
normal           30  Open:Active       -    -    -    -     0     0     0     0
s822lc_k80       30  Closed:Inact      -    -    -    -     0     0     0     0

Deep learning을 하실 고객분들은 이 중 s822lc_p100nvme 이라는 이름의 queue에 job을 submit 하셔야 합니다.   전통적 HPC를 하실 분들은 s822lc_p100 라는 queue를 이용하셔야 합니다.

수행할 job을 위한 shell script를 미리 만들어 두시는 것이 편합니다.  여기서는 PowerAI에 포함된 tensorflow를 이용하여 CIFAR-10 training 하는 shell script를 준비했습니다.  현재의 shell에서 수행되는 것이 아니라 동일 GPFS 파일시스템을 마운트하고 있는 다른 서버에서 LSF를 통해서 수행되는 것이므로, 가급적 모든 path는 절대 path로 써주시는 것이 좋습니다.

b7p193aa@p10login1:~$ cat cifar10.sh
#!/bin/bash
source /opt/DL/tensorflow/bin/tensorflow-activate
source /opt/DL/bazel/bin/bazel-activate
export FLOWERS_DIR=/gpfs/gpfs_gl4_16mb/b7p193aa/inception/models/inception
export INCEPTION_DIR=/gpfs/gpfs_gl4_16mb/b7p193aa/inception
/gpfs/gpfs_gl4_16mb/b7p193aa/inception/models/inception/bazel-bin/inception/flowers_train --train_dir=$FLOWERS_DIR/train --data_dir=$FLOWERS_DIR/data --pretrained_model_checkpoint_path=$INCEPTION_DIR/inception-v3/model.ckpt-157585 --fine_tune=True --initial_learning_rate=0.005 -input_queue_memory_factor=1 --max_steps=500 --num_gpus 4 --batch_size=64

이제 이 cifar10.sh를 LSF의 s822lc_p100nvme 이라는 이름의 queue에 submit 하겠습니다.

b7p193aa@p10login1:~$ bsub -q s822lc_p100nvme /gpfs/gpfs_gl4_16mb/home/b7p193aa/cifar10.sh
Job <113856> is submitted to queue <s822lc_p100nvme>.

Job ID 113856를 이용하여 현재 상황이 어떤지 등을 보실 수 있습니다.  먼저 job 상황을 보기 위해 bjobs 명령을 써보겠습니다.

b7p193aa@p10login1:~$ bjobs 113856
JOBID   USER    STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
113856  b7p193a RUN   s822lc_p10 p10login1    p10a106     *ifar10.sh Aug  2 00:38

현재 run 중이고, p10a106이라는 서버에서 수행 중임을 알 수 있습니다.  

bhist 명령으로 보시면 이제 막 job이 할당되어 해당 노드상에서 pid 142480로 시작된 것을 보실 수 있습니다.

b7p193aa@p10login1:~$ bhist -l 113856

Job <113856>, User <b7p193aa>, Project <default>, Command </gpfs/gpfs_gl4_16mb/
                     home/b7p193aa/cifar10.sh>
Wed Aug  2 00:38:06: Submitted from host <p10login1>, to Queue <s822lc_p100nvme
                     >, CWD <$HOME>;
Wed Aug  2 00:38:07: Dispatched 1 Task(s) on Host(s) <p10a106>, Allocated 1 Slo
                     t(s) on Host(s) <p10a106>, Effective RES_REQ <select[type
                     == local] order[r15s:pg] >;
Wed Aug  2 00:38:08: Starting (Pid 142480);

Summary of time in seconds spent in various states by  Wed Aug  2 00:38:08
  PEND     PSUSP    RUN      USUSP    SSUSP    UNKWN    TOTAL
  1        0        1        0        0        0        2

이어서 bhosts 명령으로 확인하시면, 이 p10a106 노드에서 뭔가 한창 돌아가고 있는 것을 보실 수 있습니다.

b7p193aa@p10login1:~$ bhosts p10a106
HOST_NAME          STATUS       JL/U    MAX  NJOBS    RUN  SSUSP  USUSP    RSV
p10a106           ok              -    160    150    150      0      0      0

Job이 돌아가는 모습을 보시려면 bpeek 명령을 쓰실 수 있습니다.  원래 console 상에 display 되어야 하는 message 등을 여기서 엿볼 수 있습니다.

b7p193aa@p10login1:~$ bpeek 113856
<< output from stdout >>

<< output from stderr >>
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally


시간이 지난 뒤 다시 bhist 명령을 내려보면 이제 완료된 것을 보실 수 있습니다.

b7p193aa@p10login1:~$ bhist -l 113856

Job <113856>, User <b7p193aa>, Project <default>, Command </gpfs/gpfs_gl4_16mb/
                     home/b7p193aa/cifar10.sh>
Wed Aug  2 00:38:06: Submitted from host <p10login1>, to Queue <s822lc_p100nvme
                     >, CWD <$HOME>, Error File <./err.2>;
Wed Aug  2 00:38:07: Dispatched 1 Task(s) on Host(s) <p10a106>, Allocated 1 Slo
                     t(s) on Host(s) <p10a106>, Effective RES_REQ <select[type
                     == local] order[r15s:pg] >;
Wed Aug  2 00:38:08: Starting (Pid 142480);
Wed Aug  2 00:38:14: Running with execution home </gpfs/gpfs_gl4_16mb/home/b7p1
                     93aa>, Execution CWD </gpfs/gpfs_gl4_16mb/home/b7p193aa>,
                     Execution Pid <142480>;
Wed Aug  2 02:14:55: Done successfully. The CPU time used is 692931.6 seconds;
Wed Aug  2 02:15:00: Post job process done successfully;

MEMORY USAGE:
MAX MEM: 20.7 Gbytes;  AVG MEM: 16.2 Gbytes

Summary of time in seconds spent in various states by  Wed Aug  2 02:15:00
  PEND     PSUSP    RUN      USUSP    SSUSP    UNKWN    TOTAL
  1        0        5808     0        0        0        5809

그 결과물로 나오는 model file은 미리 정해진 위치인 $INCEPTION/models/inception/train 밑에 아래와 같이 생성된 것을 확인하실 수 있습니다.

b7p193aa@p10login1:~$ ls /gpfs/gpfs_gl4_16mb/b7p193aa/inception/models/inception/train
checkpoint  model.ckpt-0.data-00000-of-00001  model.ckpt-0.index  model.ckpt-0.meta



가끔은 작성한 shell이 제대로 수행되지 않고 error가 나는 경우가 있습니다.  이때 error 메시지를 봐야 수정을 할텐데, 제가 위에 정리한 내용에는 그 부분이 없지요.  이는 bsub 명령을 내릴 때 -e 옵션을 주시면 됩니다.

아래처럼 -e 뒤에 경로를 포함한 파일명을 주시면 그 파일에 error 메시지가 쌓입니다.

b7p193aa@p10login1:~$ bsub -q s822lc_p100nvme -e ./err.1 /gpfs/gpfs_gl4_16mb/home/b7p193aa/cifar10.sh
Job <113855> is submitted to queue <s822lc_p100nvme>.

이 job은 아래와 같이 exit code 127을 내면서 시작하자마자 죽은 것을 보실 수 있습니다.

b7p193aa@p10login1:~$ bhist -l 113855

Job <113855>, User <b7p193aa>, Project <default>, Command </gpfs/gpfs_gl4_16mb/
                     home/b7p193aa/cifar10.sh>
Wed Aug  2 00:36:20: Submitted from host <p10login1>, to Queue <s822lc_p100nvme
                     >, CWD <$HOME>, Error File <./err.1>;
Wed Aug  2 00:36:21: Dispatched 1 Task(s) on Host(s) <p10a119>, Allocated 1 Slo
                     t(s) on Host(s) <p10a119>, Effective RES_REQ <select[type
                     == local] order[r15s:pg] >;
Wed Aug  2 00:36:22: Starting (Pid 96410);
Wed Aug  2 00:36:28: Running with execution home </gpfs/gpfs_gl4_16mb/home/b7p1
                     93aa>, Execution CWD </gpfs/gpfs_gl4_16mb/home/b7p193aa>,
                     Execution Pid <96410>;
Wed Aug  2 00:36:28: Exited with exit code 127. The CPU time used is 0.4 seconds;
Wed Aug  2 00:36:28: Completed <exit>;

Summary of time in seconds spent in various states by  Wed Aug  2 00:36:28
  PEND     PSUSP    RUN      USUSP    SSUSP    UNKWN    TOTAL
  1        0        7        0        0        0        8

./err.1 파일을 열어보면 아래와 같이 제가 경로명을 잘못 줬기 때문에 발생한 것임을 아실 수 있습니다.

b7p193aa@p10login1:~$ cat ./err.1
/gpfs/gpfs_gl4_16mb/home/b7p193aa/cifar10.sh: line 6: /gpfs_gl4_16mb/b7p193aa/inception/models/inception/bazel-bin/inception/flowers_train: No such file or directory