2020년 3월 23일 월요일

Orange3, Orange3-Associate 설치 (ppc64le, AC922 환경)

지난번 포스트에 이어, 이번에는 PyPI에 올라와 있는 Orange3-Associate, Orange3을 소스에서 빌드하여 설치하는 방법을 기록해 둡니다.

Orange3-associate 관련 페이지는 아래와 같습니다.
https://pypi.org/project/Orange3-Associate/
https://orange3-associate.readthedocs.io/

우선 Pypi 페이지에서 다운로드 받을 수 있는 whl 파일을 찾아보았는데, 소스코드만 공개되어 있습니다. ppc64le 환경에서는 소스를 빌드하여 직접 설치해서 사용해야 합니다.

[root@p607-kvm1 opt]# gzip -d Orange3-Associate-1.1.5.tar.gz
[root@p607-kvm1 opt]# tar -xvf Orange3-Associate-1.1.5.tar
[root@p607-kvm1 opt]# ls -al
total 3093748
drwxr-xr-x.  4 root root        119 Mar 10 00:41 .
dr-xr-xr-x. 20 root root       4096 Mar  8 22:33 ..
drwxr-xr-x  20 root root        308 Feb 27 03:39 anaconda3
-rw-rw-r--   1 root root 3167160320 Mar  9 02:49 anaconda3_20200227.tar
drwxr-xr-x   6 1000 1000        172 Nov 15  2017 Orange3-Associate-1.1.5
-rw-r--r--   1 root root     829440 Feb 26 12:54 Orange3-Associate-1.1.5.tar
[root@p607-kvm1 opt]# cd Orange3-Associate-1.1.5/

지난번과 동일하게 서버에 gcc 환경을 구성합니다. 제가 사용할 Python 3.6 버전은 anaconda3에 포함되어 있는데, gcc 7.3.x 버전을 이용하여 빌드된 것입니다. 따라서, 이후 Orange3-associate를 빌드할때에도 gcc 7.3.x 버전이 필요합니다. 

[root@p607-kvm1 Orange3-Associate-1.1.5]# yum install devtoolset-7-gcc-c++.ppc64le
[root@p607-kvm1 Orange3-Associate-1.1.5]# export PATH=/opt/rh/devtoolset-7/root/usr/bin:$PATH

이제 Orange3-Associate 를 빌드합니다.
[root@p607-kvm1 Orange3-Associate-1.1.5]# /opt/anaconda3/bin/python3 setup.py build
running build
running build_py
running build_ext
building 'orangecontrib.associate._fpgrowth' extension
gcc -pthread -B /opt/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstri                                        ct-prototypes -fPIC -I/opt/anaconda3/include/python3.6m -c orangecontrib/associate/_fpgrowth.cpp -o build/temp.lin                                        ux-ppc64le-3.6/orangecontrib/associate/_fpgrowth.o -std=c++11 -O3
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
g++ -pthread -shared -B /opt/anaconda3/compiler_compat -L/opt/anaconda3/lib -Wl,-rpath=/opt/anaconda3/lib -Wl,--no                                        -as-needed -Wl,--sysroot=/ build/temp.linux-ppc64le-3.6/orangecontrib/associate/_fpgrowth.o -o build/lib.linux-ppc                                        64le-3.6/orangecontrib/associate/_fpgrowth.cpython-36m-powerpc64le-linux-gnu.so
[root@p607-kvm1 Orange3-Associate-1.1.5]# /opt/anaconda3/bin/python3 setup.py install
running install
running bdist_egg
running egg_info
writing Orange3_Associate.egg-info/PKG-INFO
writing dependency_links to Orange3_Associate.egg-info/dependency_links.txt
writing entry points to Orange3_Associate.egg-info/entry_points.txt
writing namespace_packages to Orange3_Associate.egg-info/namespace_packages.txt
writing requirements to Orange3_Associate.egg-info/requires.txt
writing top-level names to Orange3_Associate.egg-info/top_level.txt
reading manifest file 'Orange3_Associate.egg-info/SOURCES.txt'
writing manifest file 'Orange3_Associate.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-ppc64le/egg
running install_lib
running build_py
running build_ext
creating build/bdist.linux-ppc64le
creating build/bdist.linux-ppc64le/egg
creating build/bdist.linux-ppc64le/egg/orangecontrib
copying build/lib.linux-ppc64le-3.6/orangecontrib/__init__.py -> build/bdist.linux-ppc64le/egg/orangecontrib
creating build/bdist.linux-ppc64le/egg/orangecontrib/associate
copying build/lib.linux-ppc64le-3.6/orangecontrib/associate/fpgrowth.py -> build/bdist.linux-ppc64le/egg/orangecon                                        trib/associate
copying build/lib.linux-ppc64le-3.6/orangecontrib/associate/__init__.py -> build/bdist.linux-ppc64le/egg/orangecon                                        trib/associate
creating build/bdist.linux-ppc64le/egg/orangecontrib/associate/widgets
copying build/lib.linux-ppc64le-3.6/orangecontrib/associate/widgets/owitemsets.py -> build/bdist.linux-ppc64le/egg                                        /orangecontrib/associate/widgets
copying build/lib.linux-ppc64le-3.6/orangecontrib/associate/widgets/__init__.py -> build/bdist.linux-ppc64le/egg/o                                        rangecontrib/associate/widgets
copying build/lib.linux-ppc64le-3.6/orangecontrib/associate/widgets/owassociate.py -> build/bdist.linux-ppc64le/eg                                        g/orangecontrib/associate/widgets
creating build/bdist.linux-ppc64le/egg/orangecontrib/associate/widgets/icons
copying build/lib.linux-ppc64le-3.6/orangecontrib/associate/widgets/icons/AssociationRules.svg -> build/bdist.linu                                        x-ppc64le/egg/orangecontrib/associate/widgets/icons
copying build/lib.linux-ppc64le-3.6/orangecontrib/associate/widgets/icons/FrequentItemsets.svg.2016_01_06_16_55_23                                        .0.svg -> build/bdist.linux-ppc64le/egg/orangecontrib/associate/widgets/icons
copying build/lib.linux-ppc64le-3.6/orangecontrib/associate/widgets/icons/FrequentItemsets.svg -> build/bdist.linu                                        x-ppc64le/egg/orangecontrib/associate/widgets/icons
copying build/lib.linux-ppc64le-3.6/orangecontrib/associate/_fpgrowth.pyx -> build/bdist.linux-ppc64le/egg/orangec                                        ontrib/associate
copying build/lib.linux-ppc64le-3.6/orangecontrib/associate/_fpgrowth.cpython-36m-powerpc64le-linux-gnu.so -> buil                                        d/bdist.linux-ppc64le/egg/orangecontrib/associate
byte-compiling build/bdist.linux-ppc64le/egg/orangecontrib/__init__.py to __init__.cpython-36.pyc
byte-compiling build/bdist.linux-ppc64le/egg/orangecontrib/associate/fpgrowth.py to fpgrowth.cpython-36.pyc
byte-compiling build/bdist.linux-ppc64le/egg/orangecontrib/associate/__init__.py to __init__.cpython-36.pyc
byte-compiling build/bdist.linux-ppc64le/egg/orangecontrib/associate/widgets/owitemsets.py to owitemsets.cpython-3                                        6.pyc
byte-compiling build/bdist.linux-ppc64le/egg/orangecontrib/associate/widgets/__init__.py to __init__.cpython-36.py                                        c
byte-compiling build/bdist.linux-ppc64le/egg/orangecontrib/associate/widgets/owassociate.py to owassociate.cpython                                        -36.pyc
creating stub loader for orangecontrib/associate/_fpgrowth.cpython-36m-powerpc64le-linux-gnu.so
byte-compiling build/bdist.linux-ppc64le/egg/orangecontrib/associate/_fpgrowth.py to _fpgrowth.cpython-36.pyc
creating build/bdist.linux-ppc64le/egg/EGG-INFO
copying Orange3_Associate.egg-info/PKG-INFO -> build/bdist.linux-ppc64le/egg/EGG-INFO
copying Orange3_Associate.egg-info/SOURCES.txt -> build/bdist.linux-ppc64le/egg/EGG-INFO
copying Orange3_Associate.egg-info/dependency_links.txt -> build/bdist.linux-ppc64le/egg/EGG-INFO
copying Orange3_Associate.egg-info/entry_points.txt -> build/bdist.linux-ppc64le/egg/EGG-INFO
copying Orange3_Associate.egg-info/namespace_packages.txt -> build/bdist.linux-ppc64le/egg/EGG-INFO
copying Orange3_Associate.egg-info/not-zip-safe -> build/bdist.linux-ppc64le/egg/EGG-INFO
copying Orange3_Associate.egg-info/requires.txt -> build/bdist.linux-ppc64le/egg/EGG-INFO
copying Orange3_Associate.egg-info/top_level.txt -> build/bdist.linux-ppc64le/egg/EGG-INFO
writing build/bdist.linux-ppc64le/egg/EGG-INFO/native_libs.txt
creating dist
creating 'dist/Orange3_Associate-1.1.5-py3.6-linux-ppc64le.egg' and adding 'build/bdist.linux-ppc64le/egg' to it
removing 'build/bdist.linux-ppc64le/egg' (and everything under it)
Processing Orange3_Associate-1.1.5-py3.6-linux-ppc64le.egg
creating /opt/anaconda3/lib/python3.6/site-packages/Orange3_Associate-1.1.5-py3.6-linux-ppc64le.egg
Extracting Orange3_Associate-1.1.5-py3.6-linux-ppc64le.egg to /opt/anaconda3/lib/python3.6/site-packages
Adding Orange3-Associate 1.1.5 to easy-install.pth file

Installed /opt/anaconda3/lib/python3.6/site-packages/Orange3_Associate-1.1.5-py3.6-linux-ppc64le.egg
Processing dependencies for Orange3-Associate==1.1.5
Searching for scipy==1.3.0
Best match: scipy 1.3.0
Adding scipy 1.3.0 to easy-install.pth file

Using /opt/anaconda3/lib/python3.6/site-packages
Searching for numpy==1.17.2
Best match: numpy 1.17.2
Adding numpy 1.17.2 to easy-install.pth file
Installing f2py script to /opt/anaconda3/bin
Installing f2py3 script to /opt/anaconda3/bin
Installing f2py3.6 script to /opt/anaconda3/bin

Using /opt/anaconda3/lib/python3.6/site-packages
Finished processing dependencies for Orange3-Associate==1.1.5

정상적으로 빌드되었고, 아래 경로를 찾아보면 Orange3-Associate 관련 패키지가 생성된 것을 볼 수 있습니다.
[root@p607-kvm1 Orange3-Associate-1.1.5]# ls -al /opt/anaconda3/lib/python3.6/site-packages
(생략)
drwxr-xr-x   4 root root     43 Mar 10 00:46 Orange3_Associate-1.1.5-py3.6-linux-ppc64le.egg
(생략)

이제 예제 스크립트를 실행해봅니다. 예제는 아래 사이트에 나와 있는 것을 수행해봅니다.

[root@p607-kvm1 ~]# /opt/anaconda3/bin/python3
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:18:58)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> T = [[1,    3, 4   ],
...      [   2, 3,    5],
...      [1, 2, 3,    5],
...      [   2,       5]]
>>> from orangecontrib.associate.fpgrowth import *
>>> itemsets = frequent_itemsets(T, 2)
>>> itemsets
<generator object frequent_itemsets at 0x7fff9c1fde08>
>>> list(itemsets)
[(frozenset({1}), 2), (frozenset({2}), 3), (frozenset({3}), 3), (frozenset({1, 3}), 2), (frozenset({2, 3}), 2), (frozenset({5}), 3), (frozenset({2, 5}), 3), (frozenset({3, 5}), 2), (frozenset({2, 3, 5}), 2)]
>>> import Orange
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Orange'
>>>

Orange 를 import 할 수 없다는 에러가 발생합니다.
아무래도 Orange3-associate 과는 별도의 Orange 패키지를 설치해야 하는 것 같습니다. 

pypi를 찾아보니, Orange3 패키지가 올라와 있습니다만 ppc64le 환경용 whl 파일은 따로 없습니다. pip 에서도 Oragne3 을 찾을 수 있습니다. 이번에는 pip install 을 수행해 보겠습니다.
[root@p639-kvm1 pytagcloud-0.3.5]# pip install orange3
Collecting orange3
  Downloading https://files.pythonhosted.org/packages/ac/87/0e1d5ff5d3644ab80c4e6c6a7861271d59277aab6db103                                                273114df82c041/Orange3-3.24.1.tar.gz (2.5MB)
     |████████████████████████████████| 2.5MB 5.6MB/s
  Installing build dependencies ... done
(생략)
  Stored in directory: /root/.cache/pip/wheels/93/a2/de/184ecdefdb91d760706d02389015dfa3b96e927eb1c42ace37
  Building wheel for openTSNE (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip                                                -install-bydkbko3/openTSNE/setup.py'"'"'; __file__='"'"'/tmp/pip-install-bydkbko3/openTSNE/setup.py'"'"';f                                                =getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.c                                                lose();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-bojfbwix --python-tag                                               

Orange3 을 pip로 설치하다보니 에러가 발생합니다. 에러가 가장 처음 발생한 부분부터 찾아서 하나씩 해결해보겠습니다.

우선 가장 처음 에러가 발생한 부분을 보니, openTSNE 를 빌드하던 중입니다. OpenTSNE를 Pypi에서 다운로드 받아서 소스에서 직접 빌드해봅니다.

[root@p639-kvm1 ~]# cd /root/openTSNE-0.3.12

현재 사용하는 플랫폼은 POWER9 cpu를 사용하는 AC922 서버이므로, setup.py 를 열어서 -march=native 를 -mcpu=power9 으로 변경해줍니다. -march=native 를 그대로 사용하면 Intel Xeon processor로 인식하여 에러가 발생합니다.

[root@p639-kvm1 openTSNE-0.3.12]# vi setup.py
#            "native": "-march=native",
            "native": "-mcpu=power9",

[root@p639-kvm1 openTSNE-0.3.12]# /opt/anaconda3/bin/python setup.py build
./tmpl9ju6hl_/fftw3.c:1:10: fatal error: fftw3.h: No such file or directory
 #include <fftw3.h>
          ^~~~~~~~~
compilation terminated.
FFTW3 header files not found. Using numpy implementation of FFT.
running build
running build_py
running build_ext
gcc -pthread -B /opt/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/anaconda3/include -I/opt/anaconda3/Library/include -c ./tmpo1ebp1ta/omp.c -o ./tmpo1ebp1ta/omp.o
./tmpo1ebp1ta/omp.c:2:5: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
 int main() {}
     ^~~~
(생략)
gcc -pthread -shared -B /opt/anaconda3/compiler_compat -L/opt/anaconda3/lib -Wl,-rpath=/opt/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-ppc64le-3.6/openTSNE/_matrix_mul/matrix_mul_numpy.o -o build/lib.linux-ppc64le-3.6/openTSNE/_matrix_mul/matrix_mul.cpython-36m-powerpc64le-linux-gnu.so -lm -O3 -mcpu=power9 -fopenmp

빌드가 완료되었으니, install 을 해봅니다.
[root@p639-kvm1 openTSNE-0.3.12]# /opt/anaconda3/bin/python setup.py install
./tmplduur_i_/fftw3.c:1:10: fatal error: fftw3.h: No such file or directory
(생략)
Using /opt/anaconda3/lib/python3.6/site-packages
Searching for setuptools==41.4.0
Best match: setuptools 41.4.0
Adding setuptools 41.4.0 to easy-install.pth file
Installing easy_install script to /opt/anaconda3/bin

Using /opt/anaconda3/lib/python3.6/site-packages
Finished processing dependencies for openTSNE==0.3.12

conda 에서 확인해보니, openTSNE 가 잘 설치되었습니다. 
[root@p639-kvm1 openTSNE-0.3.12]# conda list openTSNE
# packages in environment at /opt/anaconda3:
#
# Name                    Version                   Build  Channel
opentsne                  0.3.12                   pypi_0    pypi

다시 orange3 를 설치 시도해보니, 이번엔 scikit-learn 에서 에러가 발생합니다. 로그를 읽어보면, orange3의 prerequisites인 일부 패키지에서 scikit-learn>=0.22.0 버전 이상을 요구하는데, 이걸 설치하려다 보니 Cython>=0.28.5 버전을 요구합니다. pip로 Cython 해당 버전을 빌드하는데 에러가 발생하는 것 같습니다.

[root@p639-kvm1 pytagcloud-0.3.5]# pip install orange3
Processing /root/.cache/pip/wheels/65/8d/95/66d4803abaff62bcc5dee7df1b43734c192b9bbcc5a94aa4df/Orange3-3.24.1-cp36-cp36m-linux_ppc64le.whl
Requirement already satisfied: python-louvain>=0.13 in /opt/anaconda3/lib/python3.6/site-packages (from orange3) (0.13)
Collecting scikit-learn>=0.22.0
  Using cached https://files.pythonhosted.org/packages/e4/40/8bc77d8f536be0a892b37fff19fd81f15935e24724303480f85238ec7f22/scikit-learn-0.22.2.post1.tar.gz
Building wheels for collected packages: scikit-learn
  Building wheel for scikit-learn (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /opt/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ghyqlp20/scikit-learn/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ghyqlp20/scikit-learn/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-lyzjovl0 --python-tag cp36
       cwd: /tmp/pip-install-ghyqlp20/scikit-learn/
  ValueError: Please install Cython with a version >= 0.28.5 in order to build a scikit-learn from source. The current version of Cython is 0.28.1 installed in ['/opt/anaconda3/lib/python3.6/site-packages/Cython'].
  ----------------------------------------
  ERROR: Failed building wheel for scikit-learn

현재 Conda 에 설치된 Cython 버전과, 
[root@p639-kvm1 ~]# conda list Cython
# packages in environment at /opt/anaconda3:
#
# Name                    Version                   Build  Channel
cython                    0.28.1           py36h14c3975_0    https://repo.anaconda.com/pkgs/main

[root@p639-kvm1 ~]# conda install Cython==0.28.5
The following NEW packages will be INSTALLED:

  pandas             repos/powerai/1.6.1/conda/pkgs/main/linux-ppc64le::pandas-0.24.2-py36he6710b0_0

The following packages will be UPDATED:

  cython             pkgs/main::cython-0.28.1-py36h14c3975~ --> repos/powerai/1.6.1/conda/pkgs/main::cython-0.28.5-py36hf484d3e_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
cython-0.28.5        | 3.0 MB    | ############################################################################################################### | 100%
pandas-0.24.2        | 10.3 MB   | ############################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

다시 pip install orange3 시도합니다.
[root@p639-kvm1 ~]# pip install orange3
Processing ./.cache/pip/wheels/65/8d/95/66d4803abaff62bcc5dee7df1b43734c192b9bbcc5a94aa4df/Orange3-3.24.1-cp36-cp36m-linux_ppc64le.whl
Collecting scikit-learn>=0.22.0
  Using cached https://files.pythonhosted.org/packages/e4/40/8bc77d8f536be0a892b37fff19fd81f15935e24724303480f85238ec7f22/scikit-learn-0.22.2.post1.tar.gz
Requirement already satisfied: xlsxwriter in /opt/anaconda3/lib/python3.6/site-packages (from orange3) (1.0.4)
Requirement already satisfied: matplotlib>=2.0.0 in /opt/anaconda3/lib/python3.6/site-packages (from orange3) (3.0.0)
Requirement already satisfied: numpy>=1.16.0 in /opt/anaconda3/lib/python3.6/site-packages (from orange3) (1.17.2)
Requirement already satisfied: scipy>=0.16.1 in /opt/anaconda3/lib/python3.6/site-packages (from orange3) (1.3.0)
Requirement already satisfied: openpyxl in /opt/anaconda3/lib/python3.6/site-packages (from orange3) (2.5.3)
Requirement already satisfied: setuptools>=36.3 in /opt/anaconda3/lib/python3.6/site-packages (from orange3) (41.4.0)
Requirement already satisfied: keyrings.alt in /opt/anaconda3/lib/python3.6/site-packages (from orange3) (3.4.0)
(생략)
  Building wheel for scikit-learn (setup.py): still running...
  Building wheel for scikit-learn (setup.py): finished with status 'done'
  Created wheel for scikit-learn: filename=scikit_learn-0.22.2.post1-cp36-cp36m-linux_ppc64le.whl size=18232672 sha256=86081cde15b4fb435825e06b301fa4a2c8fbf8f97dae66fe34e4b6691bb15f3c
  Stored in directory: /root/.cache/pip/wheels/9c/ab/08/f3ae672cb3582e5f5a1d366531f6b96115017c66d6f4f2f5f3
Successfully built scikit-learn
Installing collected packages: scikit-learn, orange-widget-base, orange3
  Found existing installation: scikit-learn 0.21.3
    Uninstalling scikit-learn-0.21.3:
      Successfully uninstalled scikit-learn-0.21.3
Successfully installed orange-widget-base-4.5.0 orange3-3.24.1 scikit-learn-0.22.2.post1

잘 완료되었고, conda list 로 확인해보면 orange3이 설치되어 있습니다.
[root@p639-kvm1 ~]# conda list orange3
# packages in environment at /opt/anaconda3:
#
# Name                    Version                   Build  Channel
orange3                   3.24.1                   pypi_0    pypi

다시 python을 실행하여 import Orange 가 잘 실행되는지 확인합니다.

** 위 테스트 시, 최신 버전인 Orange3 3.24.1 을 설치하면서 Pandas 도 1.0.3 으로 설치되었습니다. 어떤 이유에서인지 Pandas 1.0.3 은 import pandas 시 에러가 발생하여, pip uninstall pandas, pip uninstall Orange3 을 다시 삭제하고, Orange3 3.24.0 버전으로 낮추어 재설치했습니다.

** pip install Orange3==3.24.0 설치 결과
Successfully built Orange3
Installing collected packages: Orange3
Successfully installed Orange3-3.24.0

** pip uninstall pandas 후, 원래 설치되어있던 이전 버전의 pandas 정보 (0.24.2)
[root@p639-kvm1 ~]# conda list pandas
# packages in environment at /opt/anaconda3:
#
# Name                    Version                   Build  Channel
pandas                    0.24.2           py36he6710b0_0
[root@p639-kvm1 ~]# python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:18:58)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>> import Orange

AC922 에서 nvidia-container-toolkit 설치하기 (PowerPC, ppc64le 환경, nvidia-docker)

IBM AC922 서버에서 최신(2020/03 기준) nvidia-container-toolkit 을 구성하는 방법입니다. (예전 이름 nvidia-docker2)

이미 2019/04에 포스팅된 아래 글을 보시면, PowerPC 에서도 nvidia-docker2를 활용할 수 있도록 nvidia-container-runtime 을 구성하는 방법을 소개하고 있습니다.
** ppc64le Redhat 7 환경에서의 nvidia-docker2 대신 nvidia-container-runtime 사용
http://hwengineer.blogspot.com/2019/04/ppc64le-redhat-7-nvidia-docker2-nvidia.html

근래에 위 포스트 대로 실행해보니, nvidia-docker2가 deprecated 되어 구성 방식도 조금 바뀐것 같습니다. 위 포스팅 방식대로 하면 에러가 발생하거나, docker run 시에 --runtime=nvidia 로 설정해도 적용되지 않는 경우가 있어서 아래 다시 최신 적용 방법을 기록해둡니다.

기본 내용은 결국 아래 Github 을 따르시면 됩니다.

[root@p639-kvm1 ~]# distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
[root@p639-kvm1 ~]# curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo
[libnvidia-container]
name=libnvidia-container
baseurl=https://nvidia.github.io/libnvidia-container/centos7/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://nvidia.github.io/libnvidia-container/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

[nvidia-container-runtime]
name=nvidia-container-runtime
baseurl=https://nvidia.github.io/nvidia-container-runtime/centos7/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://nvidia.github.io/nvidia-container-runtime/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

[nvidia-docker]
name=nvidia-docker
baseurl=https://nvidia.github.io/nvidia-docker/centos7/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://nvidia.github.io/nvidia-docker/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

아래 경로에 가보면, nvidia-docker.repo 이 위 내용 대로 생성된 것을 확인하실 수 있습니다. 해당 파일을 열어서, repo_gpgcheck=1 을 0 으로 변경해줍니다.
[root@p639-kvm1 ~]# vi /etc/yum.repos.d/nvidia-docker.repo
(여기서 변경) repo_gpgcheck=0

[root@p639-kvm1 ~]# yum repolist
Loaded plugins: nvidia, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
#### NVIDIA ####
repo id                            repo name                                                                      status
cuda-10-1-local-10.1.243-418.87.00 cuda-10-1-local-10.1.243-418.87.00                                                101
libnvidia-container/ppc64le        libnvidia-container                                                                15
local-rhn-server-epel              Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server EPEL RP 13,831
local-rhn-server-extras            Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server Extras     127
local-rhn-server-iso-media         Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server ISO RPM  3,751
local-rhn-server-optional          Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server Optiona  3,786
local-rhn-server-os                Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server Base RP  3,775
local-rhn-server-rhscl             Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server RHSCL R  2,091
local-rhn-server-supplementary     Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server Supplem     13
nvidia-container-runtime/ppc64le   nvidia-container-runtime                                                            6
nvidia-docker/ppc64le              nvidia-docker                                                                       1
powerai-epel                       Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server EPEL RP 13,726
powerai-extras                     Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server Extras     127
powerai-optional                   Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server Optiona  3,786
powerai-os                         Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server RPMs     3,775
powerai-rhscl                      Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server RHSCL R  2,091
powerai-supplementary              Poughkeepsie Client Center Local RHN - RHEL 7Server_alt ppc64le Server Supplem     13
repolist: 51,015

nvidia-docker, nvidia-container-runtime 이 올라왔는지 확인합니다. 

Github 에서는 nvidia-container-toolkit 혹은 nvidia-container-hook 으로 설치하면 된다고 하는데, 해당 패키지로는 설치가 되질 않습니다. 따라서, 아래의 명령어로 해당 패키지들을 설치해줍니다.
 
[root@p639-kvm1 ~]# yum install -y libnvidia-container-devel nvidia-container-runtime
[root@p639-kvm1 ~]# systemctl restart docker

명령어도 예전 옵션을 사용해야 합니다. 새로운 nvidia-container-toolkit 에서는 --gpus 옵션을 사용하지만, 여기서는 이전처럼 -e를 사용합니다. nvidia-docker2 에서 사용하던 --runtime 도 적용되질 않습니다.

[root@p639-kvm1 ~]# docker run -e NVIDIA_VISIBLE_DEVICES=all nvidia/cuda-ppc64le:10.1-base nvidia-smi
Mon Mar 23 07:27:08 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.87.00    Driver Version: 418.87.00    CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla V100-SXM2...  On   | 00000001:00:01.0 Off |                    0 |
| N/A   34C    P0    39W / 300W |      0MiB / 32480MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

컨테이너 실행 시, NVIDIA_VISIBLE_DEVICES=none 으로 GPU를 할당하지 않고 실행해봅니다.

[root@p639-kvm1 ~]# docker run -e NVIDIA_VISIBLE_DEVICES=none nvidia/cuda-ppc64le:10.1-base nvidia-smi
No devices were found

2020년 2월 27일 목요일

Konlpy 설치하기 (ppc64le 환경, AC922 서버)

한국어 분석용 KoNLPy(코엔엘파이) 패키지를 ppc64le 에 설치하기 위한 방법입니다.
http://konlpy.org/ko/latest/

해당 패키지는 아직 ppc64le용 Anaconda 채널에 포함되어 있지 않습니다. 따라서 pypi 사이트(https://pypi.org/)에서 제공하고 있는 whl 파일을 이용하여 설치해야 하는데, 설치 자체는 pip 명령어로 간단하게 수행할 수 있습니다.
다만, 이 패키지를 설치할때, JPype1 패키지도 필수로 필요한데, JPype1 패키지는 ppc64le용 whl도 제공되지 않고, 기본 Anaconda 채널에 포함되어 있지 않기 때문에 직접 소스코드를 빌드하고 설치하는 작업을 선행 후, KoNLPy 패키지를 설치해보겠습니다. (기타 요구 패키지는 Anaconda3 에서 conda install 명령어로 설치 가능하며, 구성 시 자동 설치됩니다.)

Konlpy whl 파일 다운로드 링크 https://files.pythonhosted.org/packages/85/0e/f385566fec837c0b83f216b2da65db9997b35dd675e107752005b7d392b1/konlpy-0.5.2-py2.py3-none-any.whl

JPype1 소스코드 다운로드 링크
https://files.pythonhosted.org/packages/d7/62/0f312d578e0165e9b5e8fcae0291f7ee83783b3805f59071006b21229d55/JPype1-0.7.1.tar.gz


아래 환경에서는 Python 3.6 사용자 기준으로 패키지를 빌드합니다.
먼저 Jpype1 패키지의 소스코드를 다운로드 받아서 서버에 올려둡니다.

[root@p625-kvm1 cecuser]# tar -xvf JPype1-0.7.1.tar.gz
[root@p625-kvm1 cecuser]# cd JPype1-0.7.1/

현재 사용하는 Python은 Anaconda3에 포함된 Python 3.6.9 버전이고, GCC 7.3.0 으로 빌드되어 있습니다. 따라서, JPype1 을 빌드할때도 gcc 7.3.0 버전 이상을 사용해주어야 합니다.

[root@p625-kvm1 JPype1-0.7.1]# /opt/anaconda3/bin/python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:18:58)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

제가 작업한 서버의 기본 환경은 gcc 버전이 4.8.5 입니다.
[root@p625-kvm1 cecuser]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc 7.3.x 버전을 설치하기 위해서, 아래의 devtoolset을 설치합니다. 이후, 기본 PATH를 잠시 변경하여 gcc 7.3.x 버전이 먼저 사용되도록 합니다.
[root@p625-kvm1 JPype1-0.7.1]# yum install devtoolset-7-gcc-c++.ppc64le
[root@p625-kvm1 JPype1-0.7.1]# export PATH=/opt/rh/devtoolset-7/root/usr/bin:$PATH

[root@p625-kvm1 cecuser]# gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

이제 Anaconda에 포함된 Python3으로 JPype1을 빌드합니다.
[root@p625-kvm1 JPype1-0.7.1]# /opt/anaconda3/bin/python setup.py build
/opt/anaconda3/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'use_scm_version'
  warnings.warn(msg)
running build

g++ -pthread -shared -B /opt/anaconda3/compiler_compat -L/opt/anaconda3/lib -Wl,-rpath=/opt/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-ppc64le-3.6/build/src/jp_thunk.o build/temp.linux-ppc64le-3.6/native/common/jp_array.o build/temp.linux-ppc64le-3.6/native/common/jp_arrayclass.o build/temp.linux-ppc64le-3.6/native/common/jp_baseclasses.o build/temp.linux-ppc64le-3.6/native/common/jp_booleantype.o build/temp.linux-ppc64le-3.6/native/common/jp_boxedclasses.o build/temp.linux-ppc64le-3.6/native/common/jp_bytetype.o build/temp.linux-ppc64le-3.6/native/common/jp_chartype.o build/temp.linux-ppc64le-3.6/native/common/jp_class.o build/temp.linux-ppc64le-3.6/native/common/jp_classloader.o build/temp.linux-ppc64le-3.6/native/common/jp_doubletype.o build/temp.linux-ppc64le-3.6/native/common/jp_encoding.o build/temp.linux-ppc64le-3.6/native/common/jp_env.o build/temp.linux-ppc64le-3.6/native/common/jp_exception.o build/temp.linux-ppc64le-3.6/native/common/jp_field.o build/temp.linux-ppc64le-3.6/native/common/jp_floattype.o build/temp.linux-ppc64le-3.6/native/common/jp_inttype.o build/temp.linux-ppc64le-3.6/native/common/jp_jniutil.o build/temp.linux-ppc64le-3.6/native/common/jp_longtype.o build/temp.linux-ppc64le-3.6/native/common/jp_method.o build/temp.linux-ppc64le-3.6/native/common/jp_methodoverload.o build/temp.linux-ppc64le-3.6/native/common/jp_monitor.o build/temp.linux-ppc64le-3.6/native/common/jp_primitivetype.o build/temp.linux-ppc64le-3.6/native/common/jp_proxy.o build/temp.linux-ppc64le-3.6/native/common/jp_reference_queue.o build/temp.linux-ppc64le-3.6/native/common/jp_shorttype.o build/temp.linux-ppc64le-3.6/native/common/jp_stringclass.o build/temp.linux-ppc64le-3.6/native/common/jp_tracer.o build/temp.linux-ppc64le-3.6/native/common/jp_typemanager.o build/temp.linux-ppc64le-3.6/native/common/jp_value.o build/temp.linux-ppc64le-3.6/native/common/jp_voidtype.o build/temp.linux-ppc64le-3.6/native/python/jp_pythonenv.o build/temp.linux-ppc64le-3.6/native/python/jp_pythontypes.o build/temp.linux-ppc64le-3.6/native/python/jpype_memory_view.o build/temp.linux-ppc64le-3.6/native/python/pyjp_array.o build/temp.linux-ppc64le-3.6/native/python/pyjp_class.o build/temp.linux-ppc64le-3.6/native/python/pyjp_field.o build/temp.linux-ppc64le-3.6/native/python/pyjp_method.o build/temp.linux-ppc64le-3.6/native/python/pyjp_module.o build/temp.linux-ppc64le-3.6/native/python/pyjp_monitor.o build/temp.linux-ppc64le-3.6/native/python/pyjp_proxy.o build/temp.linux-ppc64le-3.6/native/python/pyjp_value.o -ldl -o build/lib.linux-ppc64le-3.6/_jpype.cpython-36m-powerpc64le-linux-gnu.so

위 메시지를 끝으로 빌드 완료됩니다. 빌드가 완료되었으니 설치를 해봅니다.

[root@p625-kvm1 JPype1-0.7.1]# /opt/anaconda3/bin/python setup.py install
creating dist
creating 'dist/JPype1-0.7.1-py3.6-linux-ppc64le.egg' and adding 'build/bdist.linux-ppc64le/egg' to it
removing 'build/bdist.linux-ppc64le/egg' (and everything under it)
Processing JPype1-0.7.1-py3.6-linux-ppc64le.egg
creating /opt/anaconda3/lib/python3.6/site-packages/JPype1-0.7.1-py3.6-linux-ppc64le.egg
Extracting JPype1-0.7.1-py3.6-linux-ppc64le.egg to /opt/anaconda3/lib/python3.6/site-packages
Adding JPype1 0.7.1 to easy-install.pth file

Installed /opt/anaconda3/lib/python3.6/site-packages/JPype1-0.7.1-py3.6-linux-ppc64le.egg
Processing dependencies for JPype1==0.7.1
Finished processing dependencies for JPype1==0.7.1

위와 같이 종료되면 현재 경로의 /opt/anaconda3 에 JPype1 이 잘 설치된 것입니다.
이제 konlpy를 whl파일로 설치합니다.

[root@p625-kvm1 cecuser]# pip install konlpy-0.5.2-py2.py3-none-any.whl
Processing ./konlpy-0.5.2-py2.py3-none-any.whl
Requirement already satisfied: JPype1>=0.7.0 in /opt/anaconda3/lib/python3.6/site-packages/JPype1-0.7.1-py3.6-linux-ppc64le.egg (from konlpy==0.5.2) (0.7.1)
Requirement already satisfied: colorama in /opt/anaconda3/lib/python3.6/site-packages (from konlpy==0.5.2) (0.3.9)
Requirement already satisfied: lxml>=4.1.0 in /opt/anaconda3/lib/python3.6/site-packages (from konlpy==0.5.2) (4.2.1)
Requirement already satisfied: beautifulsoup4==4.6.0 in /opt/anaconda3/lib/python3.6/site-packages (from konlpy==0.5.2) (4.6.0)
Requirement already satisfied: tweepy>=3.7.0 in /opt/anaconda3/lib/python3.6/site-packages (from konlpy==0.5.2) (3.8.0)
Requirement already satisfied: numpy>=1.6 in /opt/anaconda3/lib/python3.6/site-packages (from konlpy==0.5.2) (1.17.2)
Requirement already satisfied: requests-oauthlib>=0.7.0 in /opt/anaconda3/lib/python3.6/site-packages (from tweepy>=3.7.0->konlpy==0.5.2) (1.3.0)
Requirement already satisfied: PySocks>=1.5.7 in /opt/anaconda3/lib/python3.6/site-packages (from tweepy>=3.7.0->konlpy==0.5.2) (1.6.7)
Requirement already satisfied: requests>=2.11.1 in /opt/anaconda3/lib/python3.6/site-packages (from tweepy>=3.7.0->konlpy==0.5.2) (2.22.0)
Requirement already satisfied: six>=1.10.0 in /opt/anaconda3/lib/python3.6/site-packages (from tweepy>=3.7.0->konlpy==0.5.2) (1.12.0)
Requirement already satisfied: oauthlib>=3.0.0 in /opt/anaconda3/lib/python3.6/site-packages (from requests-oauthlib>=0.7.0->tweepy>=3.7.0->konlpy==0.5.2) (3.1.0)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/anaconda3/lib/python3.6/site-packages (from requests>=2.11.1->tweepy>=3.7.0->konlpy==0.5.2) (1.24.2)
Requirement already satisfied: certifi>=2017.4.17 in /opt/anaconda3/lib/python3.6/site-packages (from requests>=2.11.1->tweepy>=3.7.0->konlpy==0.5.2) (2019.9.11)
Requirement already satisfied: idna<2.9,>=2.5 in /opt/anaconda3/lib/python3.6/site-packages (from requests>=2.11.1->tweepy>=3.7.0->konlpy==0.5.2) (2.6)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /opt/anaconda3/lib/python3.6/site-packages (from requests>=2.11.1->tweepy>=3.7.0->konlpy==0.5.2) (3.0.4)
Installing collected packages: konlpy
Successfully installed konlpy-0.5.2

conda 명령어로 확인해보면, konlpy 가 설치되어 있음을 보실수 있습니다.
[root@p625-kvm1 cecuser]# conda list | grep konlpy
konlpy                    0.5.2                    pypi_0    pypi

konlpy 를 제대로 실행하기 위해, 우선 java-1.8.0-openjdk 가 설치되어있는지 확인해야 합니다. 만약 설치되어 있지 않으면, 아래 명령어로 설치합니다.

[root@p625-kvm1 ~]# yum install java-1.8.0-openjdk-devel.ppc64le
==============================================================================================
 Package                     Arch    Version                 Repository                  Size
==============================================================================================
Installing:
 java-1.8.0-openjdk-devel    ppc64le 1:1.8.0.222.b10-0.el7_6 local-rhn-server-os        7.9 M
Installing for dependencies:
 giflib                      ppc64le 4.1.6-9.el7             local-rhn-server-iso-media  41 k
 java-1.8.0-openjdk          ppc64le 1:1.8.0.222.b10-0.el7_6 local-rhn-server-os        266 k
 java-1.8.0-openjdk-headless ppc64le 1:1.8.0.222.b10-0.el7_6 local-rhn-server-os         31 M
 libICE                      ppc64le 1.0.9-9.el7             local-rhn-server-iso-media  67 k
 libSM                       ppc64le 1.2.2-2.el7             local-rhn-server-iso-media  39 k
 libfontenc                  ppc64le 1.1.3-3.el7             local-rhn-server-iso-media  32 k
 lksctp-tools                ppc64le 1.0.17-2.el7            local-rhn-server-iso-media  89 k
 pcsc-lite-libs              ppc64le 1.8.8-8.el7             local-rhn-server-iso-media  36 k
 ttmkfdir                    ppc64le 3.0.9-42.el7            local-rhn-server-iso-media  49 k
 tzdata-java                 noarch  2019b-1.el7             local-rhn-server-os        187 k
 xorg-x11-font-utils         ppc64le 1:7.5-21.el7            local-rhn-server-iso-media 108 k
 xorg-x11-fonts-Type1        noarch  7.5-9.el7               local-rhn-server-iso-media 521 k

(위 파일들이 설치됨)

[root@p625-kvm1 ~]# java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

이제 Python을 실행하여 konlpy 를 이용해봅니다.
[root@p625-kvm1 ~]# /opt/anaconda3/bin/python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:18:58)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from konlpy.tag import Kkma
>>> from konlpy.utils import pprint
>>> kkma=Kkma()
>>> pprint(kkma.sentences(u'네, 안녕하세요. 반갑습니다.'))
['네, 안녕하세요.', '반갑습니다.']
>>> pprint(kkma.nouns(u'질문이나 건의사항은 깃헙 이슈 트래커에 남겨주세요.'))
['질문', '건의', '건의사항', '사항', '깃헙', '이슈', '트래커']

이제 Konlpy를 사용하기 위한 준비가 되었습니다. 자세한 가이드는 Konlpy를 참조하여 사용하시면 됩니다. http://konlpy.org/ko/latest/

2020년 2월 9일 일요일

LSF-Kubernetes Integration 테스트하기 (Option #2)

최근 IBM Spectrum LSF의 서비스팩 9 버전이 나왔습니다. 이 버전에는 이전부터 Github를 통해 Technical Preview 형태로 테스트하고 있었던, LSF-Kubernetes Integration을 위한 기능이 공식적으로 포함되어 있습니다.

LSF-Kubernetes를 어떻게 함께 쓸 수 있는 지에 대해서, 아래의 Github을 살펴보시면 두가지 배포 형태로 정의하여 설명하고 있습니다.
https://github.com/IBMSpectrumComputing/lsf-kubernetes/

Option #1. LSF as a scheduler for ICP/Kubernetes

기존에 Kubernetes를 사용하던 환경에서, Kubernetes의 스케쥴링 기능을 강화시키는 목적으로 LSF의 스케쥴링 기능을 차용하는 형태의 Integration 방안입니다. IBM Cloud Private과 같은 Kubernetes distribution을 사용하는 경우나, 기타 다른 K8S 기반 오케스트레이터(ex. Openshift)에서도 사용하실 수 있습니다. 
위 Github에서는 기본적으로 Openshift를 사용하도록 권고하고 있습니다. Spectrum Computing Cloud PAK 을 함께 설치하여, 클러스터내에서 포함하고 있는 LSF agent를 활성화시키는 방법을 소개합니다.
* 2020/02/10 현재까지 Technical Preview 버전으로 제공중입니다.

Option #2. Kubernetes add-on for LSF

다음 방법은 기존 IBM Spectrum LSF 기반의 On-premise Cluster 환경을 사용하는 고객이 LSF Native 환경을 그대로 사용하면서, 클러스터 내의 일부 영역을 K8S로 운영하고자 하는 경우, 이를 지원하는 방법입니다. 사용자는 LSF 명령어(bsub) 혹은 K8S에서의 Job 제출(YAML)을 모두 수행할 수 있으며, 수행된 작업은 관리자에 의하여 LSF/K8S 양측에서 모두 모니터링됩니다.
* LSF 10.1.0.9 버전부터 LSF connector for Kubernetes를 공식 지원하고 있습니다.

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

아래에서는 Deployment Option #2 를 구축하는 방법을 소개합니다.

저는 테스트 환경을 구성할 예정이므로, all-in-one 으로 GPU가 장착된 Baremetal 서버 1대로 구성합니다. 우선 아래의 환경이 기본으로 설정되어 있어야 합니다.

- 기본 NVIDIA driver 설정 및 Docker Engine 설치
- Kubernetes distribution 설치 (아래 테스트 에서는 IBM Cloud Private(ICP) 3.2.1 버전을 설치해서 사용) 및 kubectl 명령어 사용 가능 환경
- LSF Standard edition 설치 (Suite 버전도 K8S integration 지원)


* 위 각각을 수행하는 방법은 별도 포스팅으로 링크를 걸어두겠습니다.
* 테스트 환경 (IBM Power AC922 서버, V100 GPU 4개, Redhat 7.6, CUDA 10.0)

LSF connector for kubernetes 수행 방법은 아래 링크를 보시면, IBM Knowledge center에 나와있습니다.

LSF가 구성된 환경을 확인합니다. 서버에는 LSF-K8S integration 이 지원되는 10.1.0.9 버전이 이미 설치되어 있습니다.

[root@p613-met1 ~]# lsid
IBM Spectrum LSF Standard 10.1.0.9, Oct 16 2019
Copyright International Business Machines Corp. 1992, 2016.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedul

My cluster name is cluster1
My master name is p613-met1
[root@p613-met1 ~]# lshosts
HOST_NAME      type    model  cpuf ncpus maxmem maxswp server RESOURCES
p613-met1   LINUXPP   POWER9  25.0    40 637.1G   3.9G    Yes (mg)
[root@p613-met1 ~]# bhosts
HOST_NAME          STATUS       JL/U    MAX  NJOBS    RUN  SSUSP  USUSP    RSV
p613-met1          ok              -     40      0      0      0      0      0

LSF가 설치되면, $LSF_BINDIR/../../misc/kubernetes 경로에 병렬 작업을 위한 CRD(Custom Resource Definition) 템플릿 파일이 미리 정의되어 있습니다. 이를 이용하여 관련 내용을 구성합니다. (parallelJob-v1alpha1.yaml)

[root@p613-met1 ~]# echo $LSF_BINDIR
/usr/share/lsf/10.1/linux3.10-glibc2.17-ppc64le/bin
[root@p613-met1 ~]# kubectl create -f $LSF_BINDIR/../../misc/kubernetes/parallelJob-v1alpha1.yaml
customresourcedefinition.apiextensions.k8s.io/paralleljobs.ibm.com created

이후, LSF의 각 설정 파일을 수정하여 GPU 및 Kubernetes를 인식하게끔 합니다.
lsf.conf 파일에 아래 내용을 새로 추가해줍니다.
[root@p613-met1 ~]# vi /usr/share/lsf/conf/lsf.conf
# kubernetes
LSB_KUBE_ENABLE=Y
LSF_ENABLE_EXTSCHEDULER=Y
LSB_KUBE_CONFIG=/usr/share/lsf/conf/kubernetes.config
LSB_MAX_PACK_JOBS=500
LSB_GPU_NEW_SYNTAX=extend
LSF_GPU_AUTOCONFIG=Y

lsb.modules에서 kubernetes 항목을 활성화 시킵니다.
[root@p613-met1 ~]# vi /usr/share/lsf/conf/lsbatch/cluster1/configdir/lsb.modules
schmod_kubernetes              ()                              ()

lsb.resources에서 gpu를 task별 할당 가능한 리소스 항목으로 추가합니다.
[root@p613-met1 ~]# vi /usr/share/lsf/conf/lsbatch/cluster1/configdir/lsb.resources
Begin ReservationUsage
RESOURCE             METHOD        RESERVE
ngpus_physical       PER_TASK      N
End ReservationUsage
END
lsb.params에서 아래 항목을 설정(없으면 추가)합니다.
[root@p613-met1 ~]# vi /usr/share/lsf/conf/lsbatch/cluster1/configdir/lsb.params
RELAX_JOB_DISPATCH_ORDER = N # enable relaxed job dispatch order in the cluster
MAX_USER_PRIORITY=1000

/etc/lsf.sudoers 파일에 lsfadmin을 LSB_IMPERSONATION_USERS로 추가합니다.
[root@p613-met1 ~]# echo 'LSB_IMPERSONATION_USERS="lsfadmin"' > /etc/lsf.sudoers
[root@p613-met1 ~]# chown root /etc/lsf.sudoers
[root@p613-met1 ~]# chmod 500 /etc/lsf.sudoers

lsf.shared 파일의 kubernetes 항목을 활성화 시킵니다.
[root@p613-met1 ~]# vi /usr/share/lsf/conf/lsf.shared
  kubernetes    Boolean    ()       ()       (Kubernetes node)

lsf.cluster.cluster이름 파일에서, 마스터 서버(mg)를 kubernetes mg 로 설정합니다.
[root@p613-met1 ~]# vi /usr/share/lsf/conf/lsf.cluster.cluster1
p613-met1   !   !   1   (kubernetes mg)

LSF 패키지 설치 시 기본으로 내장되어 있는 예제 템플릿 파일을 /usr/share/lsf/conf/lsbatch/cluster1/configdir/kube-template.yaml 경로에 copy합니다.
kube-template.yaml 파일은 추후 사용자가 Pod을 생성 시, 기본 적용되는 metadata, namespace, container image 등의 정보가 적용되어 있는 템플릿으로 사용됩니다. 따라서, 이후 내부의 내용을 적합하게 변경해주어야 합니다.

[root@p613-met1 ~]# cp $LSF_BINDIR/../../misc/kubernetes/example-template.yaml /usr/share/lsf/conf/lsbatch/cluster1/configdir/kube-template.yaml

lsb.applications 를 수정하여, 새로운 Application "kube"를 정의합니다. bsub으로 job 제출 시, -app 옵션으로 사용할 수 있는 어플리케이션이 정의됩니다. (-app kube)
CONTAINER는 위에서 복사한 kube-template.yaml 파일 경로를 지정하여, 해당 텡ㅁ플릿 내에 포함된 기본 컨테이너 이미지가 사용되도록 합니다. 사용자가 다양한 컨테이너 이미지 사용을 요구하는 경우, app 을 여러개 정의하여 각기 다른 템플릿 파일을 mapping 시킬 수 있습니다.
[root@p613-met1 lsf]# vi /usr/share/lsf/conf/lsbatch/cluster1/configdir/lsb.applications
Begin Application
NAME = kube
DESCRIPTION = K8S job container
CONTAINER = kubernetes[template(/usr/share/lsf/conf/lsbatch/cluster1/configdir/kube-template.yaml)]
End Application
[root@p613-met1 configdir]# chown lsfadmin /usr/share/lsf/conf/lsbatch/cluster1/configdir/kube-template.yaml

LSF의 구성 관련 내용을 모두 변경하였으므로, LSF modules을 재구성/재시작합니다.
[root@p613-met1 lsf]# lsadmin reconfig
[root@p613-met1 lsf]# badmin reconfig
[root@p613-met1 lsf]# badmin mbdrestart

(LSF가 down되어 있었던 경우)
[root@p613-met1 lsf]# lsadmin limstartup
Starting up LIM on <p613-met1> ...... done
[root@p613-met1 lsf]# lsadmin resstartup
Starting up RES on <p613-met1> ...... done
[root@p613-met1 lsf]# badmin hstartup
Starting up slave batch daemon on <p613-met1> ...... done

여기까지 구성이 되면, 아래와 같이 LSF cluster에서 GPU 리소스를 자동으로 감지할 수 있습니다.

p613-met1 서버에 장착된 4개의 V100 GPU 정보가 자동 감지됩니다.
[root@p613-met1 conf]# bhosts -gpu
HOST_NAME              ID           MODEL     MUSED      MRSV  NJOBS    RUN   SUSP    RSV
p613-met1               0 TeslaV100_SXM2_       61M        0M      0      0      0      0
                        1 TeslaV100_SXM2_       32M        0M      0      0      0      0
                        2 TeslaV100_SXM2_       33M        0M      0      0      0      0
                        3 TeslaV100_SXM2_       32M        0M      0      0      0      0

또한 p613-met1 서버는 kubernetes 동작 가능한 서버로 확인됩니다.
[root@p613-met1 conf]# lshosts
HOST_NAME      type    model  cpuf ncpus maxmem maxswp server RESOURCES
p613-met1   LINUXPP   POWER9  25.0    40 637.1G   3.9G    Yes (mg kubernetes)

-bash-4.2$ bhosts -R kubernetes
HOST_NAME          STATUS       JL/U    MAX  NJOBS    RUN  SSUSP  USUSP    RSV
p613-met1          ok              -     40      0      0      0      0      0

새로 정의한 kube라는 이름의 application 도 확인됩니다.
[root@p613-met1 conf]# bapp -l kube

APPLICATION NAME: kube
-- K8S job container

STATISTICS:
   NJOBS     PEND      RUN    SSUSP    USUSP      RSV
       0        0        0        0        0        0

PARAMETERS:

CONTAINER: kubernetes[template(/usr/share/lsf/conf/lsbatch/cluster1/configdir/kube-template.yaml)]


이제 Kubernetes에서 LSF가 사용할 Namespace, Service account 등을 자동 스크립트를 이용하여 생성해줍니다. 설치된 LSF 내부에 이미 create-lsf-k8s-config.sh 이 포함되어 있습니다. 이 shell은 "./create-lsf-k8s-config.sh create <custom namespace> <custom serviceaccount>" 로 실행시킬 수 있으며, 새로 생성할 namespace, service account를 정해주지 않으면 기본으로 mylsfns, mylsfsa가 생성됩니다. (또한 위의 kube-template.yaml 파일도 namespace, service account 등이 기본 mylsfns, mylsfsa로 이미 정의되어 있으므로, 다른 이름으로 임의 생성시에는 템플릿의 내용도 동일하게 변경해주어야 합니다.)

[root@p613-met1 lsf]# cd /usr/share/lsf/10.1/misc/kubernetes
[root@p613-met1 kubernetes]# ./create-lsf-k8s-config.sh create mylsfns mylsfsa

User "mylsfsa" set.
Running: kubectl config --kubeconfig=kubernetes.config set-context forlsf --cluster=kubernetes --namespace=mylsfns --user=mylsfsa
Context "forlsf" created.
Running: kubectl config --kubeconfig=kubernetes.config use-context forlsf
Switched to context "forlsf".
The Kubernetes configuration file has been generated and named kubernetes.config
Copy this file to the LSF conf directory, typically $LSF_ENVDIR
Change the file permissions to 400, and owned by the LSF administrator, typically lsfadmin.

*********************************************************************
NOTE: THIS FILE MUST BE PROTECTED.  IT PROVIDES ACCESS TO
      KUBERNETES RESOURCES MOST USERS SHOULD NOT HAVE!
*********************************************************************

----------------------------------------------------------------------------------------
간혹, create-lsf-k8s-config.sh로 create 구성을 했음에도, 추후 pod 생성 등에서 제대로 동작이 안되는 경우가 있습니다.(이미 동일한 SA, NS가 있는 경우 등)
Service account(SA), Namespace(NS) 생성 및 이들간의 config map 등이 제대로 생성되지 않아서 그런 경우가 있는데, 이럴 때에는 아래의 명령어로 기존 생성한 SA, NS를 삭제하고 재생성 합니다. 

[root@p613-met1 kubernetes]# ./create-lsf-k8s-config.sh delete
---- Delete Clusterrolebindings and ClusterRole ----
clusterrole.rbac.authorization.k8s.io "ibm-lsf-cr" deleted
clusterrolebinding.rbac.authorization.k8s.io "ibm-lsf-crb" deleted
clusterrolebinding.rbac.authorization.k8s.io "ibm-lsf-kubesched-crb" deleted
---- Deleting Service account "mylsfsa" in namespace "mylsfns" ----
serviceaccount "mylsfsa" deleted
---- Deleting namespace "mylsfns" ----
namespace "mylsfns" deleted
-----------------------------------------------------------------------------------------

create-lsf-k8s-config.sh 로 관련 설정을 생성하고 나면, /usr/share/lsf.10.1/misc/kubernetes 경로에 kubernetes.config 파일이 생성됩니다. 이 파일을 /usr/share/lsf/conf 로 copy하고, lsfadmin 이 사용할 수 있도록 권한을 변경합니다. 해당 파일은 lsf 와 kubernetes 간의 구성정보를 포함하고 있습니다.

[root@p613-met1 lsf]# ls -al /usr/share/lsf/10.1/misc/kubernetes/kubernetes.config
-rw-------. 1 root root 1510 Feb  5 05:40 /usr/share/lsf/10.1/misc/kubernetes/kubernetes.config
[root@p613-met1 lsf]# cp /usr/share/lsf/10.1/misc/kubernetes/kubernetes.config /usr/share/lsf/conf
[root@p613-met1 lsf]# chown lsfadmin /usr/share/lsf/conf/kubernetes.config
[root@p613-met1 lsf]# chmod 400 /usr/share/lsf/conf/kubernetes.config

변경내용을 lsf에 적용합니다.
[root@p613-met1 conf]# lsadmin reconfig
[root@p613-met1 conf]# badmin reconfig
[root@p613-met1 conf]# badmin mbdrestart

문제가 발생할 경우, 관련된 로그들은 아래의 경로에서 확인합니다.
[root@p613-met1 conf]# ls -al /usr/share/lsf/log/
total 40
drwxr-xr-x. 2 lsfadmin root         4096 Feb  5 05:58 .
drwxr-xr-x. 8 root     root         4096 Feb  4 20:37 ..
-rw-r--r--. 1 lsfadmin domain users 3600 Feb  5 06:24 batch-driver.log
-rw-r--r--. 1 lsfadmin root         2505 Feb  5 06:23 lim.log.p613-met1
-rw-r--r--. 1 lsfadmin root         8533 Feb  5 06:25 mbatchd.log.p613-met1
-rw-r--r--. 1 lsfadmin domain users 1818 Feb  5 06:24 mbschd.log.p613-met1
-rw-r--r--. 1 lsfadmin root            0 Feb  4 20:41 pim.log.p613-met1
-rw-rw-rw-. 1 lsfadmin root          956 Feb  5 06:02 res.log.p613-met1
-rw-r--r--. 1 lsfadmin root         1117 Feb  5 06:02 sbatchd.log.p613-met1


실제 gpu를 사용하는 작업의 동작 테스트를 해보기 전, 아래의 내용을 추가로 수정해줍니다.
  1. ICP 콘솔 메뉴 상에서 리소스 보안 -> 이미지 정책 -> 이미지 정책 작성으로 lsf namespace에서 사용할수 있는 정책을 만들어줍니다. 테스트 용으로 사용할 docker image가 public docker hub에 위치한다면, 아래의 이미지 정책 작성 시 해당 docker registry 정보를 추가해주어야 합니다.
     예) 이름 : mylsfimgpol, 네임스페이스 : mylsfns, 범위 : 네임스페이스, 레지스트리 정책(레지스트리 추가 : docker.io/*)
    * 만약 ICP를 사용하는 것이 아니라, 기타 K8S distribution를 사용하는 경우, Image policy 를 각 distribution에서 제공하는 방법으로 작성해주어야 합니다.
  2. 이미 생성된 /usr/share/lsf/conf/lsbatch/cluster1/configdir/kube-template.yaml 파일을 열어서, Namespace 및 image 관련 내용을 수정해줍니다. 별도의 Custom namespace를 지정해준 경우 해당 이름으로 변경하고, image는 bsub 제출 시, 기본으로 불러올 컨테이너 image 이름 및 태그를 설정합니다. 아래 예제에서는 Public docker hub(docker.io)에서 제공하는 nvidia/cuda-ppc64le:10.1-base-centos7 이미지를 사용합니다.
      namespace: mylsfns
        image: nvidia/cuda-ppc64le:10.1-base-centos7



이제 실제로 gpu를 사용하는 작업을 LSF에 제출할때, 서버에 장착된 GPU 서버 수량 이상으로 요구되는 작업이 어떻게 처리되는지, 관련하여 Pod이 생성되는 지 등을 테스트합니다.

현재의 테스트 서버는 별도 사용자를 생성해두지 않았으므로, lsfadmin 계정으로 변경하여 bsub을 수행합니다. 간단한 sleep 30 명령어를 실행하되, 각 Job은 GPU 2개를 exclusive process mode로 요구합니다. 아래의 테스트는 GPU가 4개 있는 서버 1대에서, GPU를 2개씩 요구하는 sleep job을 3개 제출한 후, 1개 job이 대기하는지 확인합니다. 

[root@p613-met1 conf]# su lsfadmin
bash-4.2$ bsub -gpu "num=2:mode=exclusive_process" sleep 30
bash-4.2$ bsub -gpu "num=2:mode=exclusive_process" sleep 30
bash-4.2$ bsub -gpu "num=2:mode=exclusive_process" sleep 30

2개의 작업은 GPU를 할당받을 수 있으므로 RUN 상태로 수행되고, 나머지 1개 작업은 PEND 상태로 대기합니다.
bash-4.2$ bjobs
JOBID   USER    STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
102     lsfadmi RUN   normal     p613-met1   p613-met1   sleep 30   Feb  5 06:34
103     lsfadmi RUN   normal     p613-met1   p613-met1   sleep 30   Feb  5 06:34
104     lsfadmi PEND  normal     p613-met1               sleep 30   Feb  5 06:34

이제  ICP를 통해 테스트 해보기 위해, 간단한 docker 이미지 하나를 pull 합니다. (위의 kube-template.yaml 파일에서 미리 정의했던 Container image입니다.)
[root@p613-met1 conf]# docker pull nvidia/cuda-ppc64le:10.1-base-centos7
Status: Downloaded newer image for nvidia/cuda-ppc64le:10.1-base-centos7

작업 제출 시, -app 옵션으로 kube을 설정하면, 앞서 설정해둔 kube-template.yaml 파일에 정의된 컨테이너 환경을 호출하여 Pod을 생성, 요청한 작업을 실행하게 됩니다. sleep 1 을 실행하여, 실제 컨테이너가 동작하는지를 확인합니다.

-bash-4.2$ bsub -app kube sleep 1
-bash-4.2$ bjobs -l 222
Job <222>, User <lsfadmin>, Project <default>, Application <kube>, Status <DONE
                     >, Queue <normal>, Job Priority <500>, Command <sleep 1>,
                     Share group charged </lsfadmin>
Wed Feb  5 08:39:06: Submitted from host <p613-met1>, CWD </usr/share/lsf/10.1/
                     misc/kubernetes>;
Wed Feb  5 08:39:10: Dispatched 1 Task(s) on Host(s) <p613-met1>, Allocated 1 S
                     lot(s) on Host(s) <p613-met1>, Execution Home <VirtualHome
                     >, Execution CWD </usr/share/lsf/10.1/misc/kubernetes>;
Wed Feb  5 08:39:24: Done successfully. The CPU time used is 0.0 seconds.
 SCHEDULING PARAMETERS:
           r15s   r1m  r15m   ut      pg    io   ls    it    tmp    swp    mem
 loadSched   -     -     -     -       -     -    -     -     -      -      -
 loadStop    -     -     -     -       -     -    -     -     -      -      -
 EXTERNAL MESSAGES:
 MSG_ID FROM       POST_TIME      MESSAGE                             ATTACHMENT
 132    _system_   Feb  5 08:39   Pods names set for job                  N
 133    _system_   Feb  5 08:39   Pod manifests generated                 Y
 134    _system_   Feb  5 08:39   Pod allocation ready for binding        N
 135    _system_   Feb  5 08:39   Pod status                              N
 RESOURCE REQUIREMENT DETAILS:
 Combined: select[type == local] order[r15s:pg]
 Effective: select[type == local] order[r15s:pg]
 KUBERNETES:
 NAMESPACE  POD                     PHASE      NODE       GPU
 mylsfns    lsf-cluster1-222-0-0-0  Succeeded  p613-met1  -

위의 작업 정보를 확인해보면, -app kube로 제출한 작업이므로, 미리 정의한 mylsfns 라는 Namespace에 lsf-cluster1-222-0-0-0 이름으로 Pod이 생성되고 실행되는 것을 볼 수 있습니다.

이번에는 kubernetes로 작업을 제출하되, GPU 할당이 되는지 테스트해봅니다.
각 작업은 sleep 5 명령어를 수행하되, -app kube 옵션을 설정하고 -gpu 로 2개씩 gpu를 할당하도록 합니다. 이러한 작업을 동시에 5개 제출하여, 3개 Job이 대기하는지 확인합니다.
-bash-4.2$ bsub -app kube -gpu "num=2:mode=exclusive_process" sleep 5
-bash-4.2$ bsub -app kube -gpu "num=2:mode=exclusive_process" sleep 5
-bash-4.2$ bsub -app kube -gpu "num=2:mode=exclusive_process" sleep 5
-bash-4.2$ bsub -app kube -gpu "num=2:mode=exclusive_process" sleep 5
-bash-4.2$ bsub -app kube -gpu "num=2:mode=exclusive_process" sleep 5

2개의 작업은 GPU를 할당받을 수 있으므로 즉각 배치되고, 나머지는 PEND 됩니다.
-bash-4.2$ bjobs
JOBID   USER    STAT  QUEUE      FROM_HOST   EXEC_HOST   JOB_NAME   SUBMIT_TIME
224     lsfadmi RUN   normal     p613-met1   p613-met1   sleep 5    Feb  5 08:48
225     lsfadmi RUN   normal     p613-met1   p613-met1   sleep 5    Feb  5 08:48
226     lsfadmi PEND  normal     p613-met1               sleep 5    Feb  5 08:48
227     lsfadmi PEND  normal     p613-met1               sleep 5    Feb  5 08:48
228     lsfadmi PEND  normal     p613-met1               sleep 5    Feb  5 08:48

아래 RUN으로 실행중인 작업의 정보를 확인해봅니다. 기본 정의된 Queue, Job Priority 에 따라서 작업이 배치되었습니다. 이러한 상세 배치 조건들은 kube-template.yaml에 미리 정의하여 변경할 수 있습니다. 
-bash-4.2$ bjobs -l 226
Job <226>, User <lsfadmin>, Project <default>, Application <kube>, Status <RUN>
                     , Queue <normal>, Job Priority <500>, Command <sleep 5>, S
                     hare group charged </lsfadmin>
Wed Feb  5 08:48:32: Submitted from host <p613-met1>, CWD </usr/share/lsf/10.1/
                     misc/kubernetes>, Requested GPU <num=2:mode=exclusive_proc
                     ess>;
Wed Feb  5 08:48:58: Dispatched 1 Task(s) on Host(s) <p613-met1>, Allocated 1 S
                     lot(s) on Host(s) <p613-met1>, Execution Home <VirtualHome
                     >, Execution CWD </usr/share/lsf/10.1/misc/kubernetes>;
 SCHEDULING PARAMETERS:
           r15s   r1m  r15m   ut      pg    io   ls    it    tmp    swp    mem
 loadSched   -     -     -     -       -     -    -     -     -      -      -
 loadStop    -     -     -     -       -     -    -     -     -      -      -
 EXTERNAL MESSAGES:
 MSG_ID FROM       POST_TIME      MESSAGE                             ATTACHMENT
 0      lsfadmin   Feb  5 08:48   p613-met1:gpus=1,2;                     N
 132    _system_   Feb  5 08:48   Pods names set for job                  N
 133    _system_   Feb  5 08:48   Pod manifests generated                 Y
 134    _system_   Feb  5 08:48   Pod allocation ready for binding        N
 135    _system_   Feb  5 08:49   Pod status                              N
 RESOURCE REQUIREMENT DETAILS:
 Combined: select[(ngpus>0) && (type == local)] order[gpu_maxfactor] rusage[ngp
                     us_physical=2.00]
 Effective: select[((ngpus>0)) && (type == local)] order[gpu_maxfactor] rusage[
                     ngpus_physical=2.00]
 GPU REQUIREMENT DETAILS:
 Combined: num=2:mode=exclusive_process:mps=no:j_exclusive=yes
 Effective: num=2:mode=exclusive_process:mps=no:j_exclusive=yes
 KUBERNETES:
 NAMESPACE  POD                     PHASE    NODE       GPU
 mylsfns    lsf-cluster1-226-0-0-0  Running  p613-met1  1 2



위의 테스트에서는 LSF 명령어를 통하여 작업을 K8S로 제출하였고, LSF의 batch driver가 K8S의 API server를 호출하여 정책에 따른 Pod이 생성되게끔 하는 것을 확인하였습니다. 더불어 GPU를 리소스로 인지하고, 가용한 GPU 양에 따라 스케쥴링 정책을 적용합니다.

이렇게 생성된 Job은 LSF 명령어 혹은 kubectl 명령어(ICP 웹콘솔)를 통해, 양측에서 모두 확인이 가능하고 모니터링 됩니다.

마찬가지로, K8S(ICP) 상에서 YAML 파일을 정의하여 제출되는 작업/Pod의 경우에도, lsf에서 정의한 namespace를 사용하고, schedulerName을 lsf로 지정하면, LSF 명령어를 통해서도 해당 Pod을 모니터링 할 수 있습니다. 

YAML 파일에 scheduler 로서 lsf를 적용 시, 사용할 수 있는 Pod spec field 정보는 아래의 링크에서 확인할 수 있습니다.

2019년 4월 23일 화요일

nvidia-docker 로 도커 컨테이너 실행 시, Docker 이미지의 driver mismatch 문제


GPU를 사용하기 위한 Docker 이미지를 생성하실 때, 보통 이미지 내에 cuda 를 설치하게 됩니다. 이때, nvidia-driver 까지 설치되어 있으면 nvidia-docker 로 Docker 컨테이너를 수행하더라도 driver version mismatch 문제가 발생합니다.

해당 이미지는 apt-get remove nvidia-driver-xxx 로 드라이버를 지운 후(Ubuntu 기준), apt autoremove 로 관련 항목을 삭제한 후 docker commit으로 이미지 재 생성하면 정상적으로 사용 가능합니다. 아래는 그 과정을 담았습니다.

[root@powerlinux ~]# docker images
REPOSITORY                                                TAG                 IMAGE ID            CREATED             SIZE
test                                                      v0.2                10ac6caf42fa        5 minutes ago       18.1GB
test                                                      v0.1                83c8bb389baa        11 minutes ago      18.1GB
bsyu/ubuntu18.04_cuda10-0_python368_tf1.12_ppc64le        v0.2                2b036cf22b81        20 hours ago        16.8GB
bsyu/ubuntu18.04_cuda10-0_python368_pytorch1.01_ppc64le   v0.2                abbd4b2ae7b4        20 hours ago        9.39GB
bsyu/ubuntu18.04_cuda10-0_python352_pytorch1.01_ppc64le   v0.3                80e339ebaa70        20 hours ago        9.18GB
bsyu/ubuntu18.04_cuda10-0_python352_pytorch1.01_ppc64le   v0.4                2a568a91c905        20 hours ago        9.18GB
bsyu/ubuntu18.04_cuda10-0_python368_tf1.12_ppc64le        v0.1                93044ddff649        5 days ago          16.8GB
bsyu/ubuntu18.04_cuda10-0_python368_pytorch1.01_ppc64le   v0.1                da0a0d186b11        5 days ago          9.39GB
bsyu/ubuntu18.04_cuda9-2_python352_pytorch1.01_ppc64le    v0.1                2344d1c2e1db        5 days ago          8.92GB
bsyu/ubuntu18.04_cuda9-2_python352_tf1.12_ppc64le         v0.1                c651ab05d934        5 days ago          17.4GB
bsyu/ubuntu18.04_cuda10-0_python352_pytorch1.01_ppc64le   v0.2                45fe1b559906        6 days ago          9.17GB
bsyu/ubuntu18.04_cuda9-2_python368_tf1.12_ppc64le         v0.1                4b7c25ac1922        6 days ago          18.5GB
bsyu/ubuntu18.04_cuda10-0_python352_tf1.12_ppc64le        v0.2                bb8a068050a7        6 days ago          18.1GB
nvidia/cuda-ppc64le                                       latest              07e3c70d64ff        6 months ago        2.24GB
[root@powerlinux ~]# docker run --runtime=nvidia --rm -ti bsyu/ubuntu18.04_cuda10-0_python352_tf1.12_ppc64le:v0.1
Unable to find image 'bsyu/ubuntu18.04_cuda10-0_python352_tf1.12_ppc64le:v0.1' locally
v0.1: Pulling from bsyu/ubuntu18.04_cuda10-0_python352_tf1.12_ppc64le
3bc68f2d2d19: Already exists
e0b8fe3eb9f1: Already exists
42fd213a0950: Already exists
eb8002c958b1: Already exists
96de9d1c2a16: Already exists
75d6d0885764: Already exists
e9aa4a68112e: Already exists
55db9dfc542a: Already exists
63e390dd1af8: Already exists
e25f36d860fe: Already exists
1e0f7888dfc5: Already exists
f6b91b686571: Already exists
370524eb9fd3: Already exists
3d83f613aa65: Already exists
cde5b7631e7f: Already exists
f180629981ca: Already exists
7b0ffa6553bc: Already exists
4097bfc39c0a: Already exists
c394c77e3800: Already exists
410f9af8eb56: Already exists
6f3aba555bb6: Already exists
5bb471683588: Already exists
e35585fcd4e2: Already exists
40d3a36277cb: Already exists
Digest: sha256:5ecd6d3777dde6f56ecf68f6ec3a90c9ca4ee769bc087a4b8ff636e7c9e642b7
Status: Downloaded newer image for bsyu/ubuntu18.04_cuda10-0_python352_tf1.12_ppc64le:v0.1
root@7b3af9f91c0f:/# nvidia-smi
Failed to initialize NVML: Driver/library version mismatch
root@7b3af9f91c0f:/# dpkg -l | grep nvidia-driver
ii  nvidia-driver-418               418.40.04-0ubuntu1                ppc64el      NVIDIA driver metapackage
root@7b3af9f91c0f:/# dpkg -l | grep nvidia
ii  libnvidia-cfg1-418:ppc64el      418.40.04-0ubuntu1                ppc64el      NVIDIA binary OpenGL/GLX configuration library
ii  libnvidia-common-418            418.40.04-0ubuntu1                all          Shared files used by the NVIDIA libraries
ii  libnvidia-compute-418:ppc64el   418.40.04-0ubuntu1                ppc64el      NVIDIA libcompute package
ii  libnvidia-decode-418:ppc64el    418.40.04-0ubuntu1                ppc64el      NVIDIA Video Decoding runtime libraries
ii  libnvidia-encode-418:ppc64el    418.40.04-0ubuntu1                ppc64el      NVENC Video Encoding runtime library
ii  libnvidia-fbc1-418:ppc64el      418.40.04-0ubuntu1                ppc64el      NVIDIA OpenGL-based Framebuffer Capture runtime library
ii  libnvidia-gl-418:ppc64el        418.40.04-0ubuntu1                ppc64el      NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD
ii  libnvidia-ifr1-418:ppc64el      418.40.04-0ubuntu1                ppc64el      NVIDIA OpenGL-based Inband Frame Readback runtime library
ii  nvidia-compute-utils-418        418.40.04-0ubuntu1                ppc64el      NVIDIA compute utilities
ii  nvidia-dkms-418                 418.40.04-0ubuntu1                ppc64el      NVIDIA DKMS package
ii  nvidia-driver-418               418.40.04-0ubuntu1                ppc64el      NVIDIA driver metapackage
ii  nvidia-kernel-common-418        418.40.04-0ubuntu1                ppc64el      Shared files used with the kernel module
ii  nvidia-kernel-source-418        418.40.04-0ubuntu1                ppc64el      NVIDIA kernel source package
ii  nvidia-modprobe                 418.40.04-0ubuntu1                ppc64el      Load the NVIDIA kernel driver and create device files
ii  nvidia-prime                    0.8.8.2                           all          Tools to enable NVIDIA's Prime
ii  nvidia-settings                 418.40.04-0ubuntu1                ppc64el      Tool for configuring the NVIDIA graphics driver
ii  nvidia-utils-418                418.40.04-0ubuntu1                ppc64el      NVIDIA driver support binaries
ii  xserver-xorg-video-nvidia-418   418.40.04-0ubuntu1                ppc64el      NVIDIA binary Xorg driver
root@7b3af9f91c0f:/# dpkg -l | grep cuda
ii  cuda-10-0                       10.0.130-1                        ppc64el      CUDA 10.0 meta-package
ii  cuda-command-line-tools-10-0    10.0.130-1                        ppc64el      CUDA command-line tools
ii  cuda-compat-10-0                410.104-1                         ppc64el      CUDA Compatibility Platform
ii  cuda-compiler-10-0              10.0.130-1                        ppc64el      CUDA compiler
ii  cuda-core-10-0                  10.0.130-1                        ppc64el      CUDA core tools
ii  cuda-cublas-10-0                10.0.130-1                        ppc64el      CUBLAS native runtime libraries
ii  cuda-cublas-dev-10-0            10.0.130-1                        ppc64el      CUBLAS native dev links, headers
ii  cuda-cudart-10-0                10.0.130-1                        ppc64el      CUDA Runtime native Libraries
ii  cuda-cudart-dev-10-0            10.0.130-1                        ppc64el      CUDA Runtime native dev links, headers
ii  cuda-cufft-10-0                 10.0.130-1                        ppc64el      CUFFT native runtime libraries
ii  cuda-cufft-dev-10-0             10.0.130-1                        ppc64el      CUFFT native dev links, headers
ii  cuda-cuobjdump-10-0             10.0.130-1                        ppc64el      CUDA cuobjdump
ii  cuda-cupti-10-0                 10.0.130-1                        ppc64el      CUDA profiling tools interface.
ii  cuda-curand-10-0                10.0.130-1                        ppc64el      CURAND native runtime libraries
ii  cuda-curand-dev-10-0            10.0.130-1                        ppc64el      CURAND native dev links, headers
ii  cuda-cusolver-10-0              10.0.130-1                        ppc64el      CUDA solver native runtime libraries
ii  cuda-cusolver-dev-10-0          10.0.130-1                        ppc64el      CUDA solver native dev links, headers
ii  cuda-cusparse-10-0              10.0.130-1                        ppc64el      CUSPARSE native runtime libraries
ii  cuda-cusparse-dev-10-0          10.0.130-1                        ppc64el      CUSPARSE native dev links, headers
ii  cuda-documentation-10-0         10.0.130-1                        ppc64el      CUDA documentation
ii  cuda-driver-dev-10-0            10.0.130-1                        ppc64el      CUDA Driver native dev stub library
ii  cuda-drivers                    418.40.04-1                       ppc64el      CUDA Driver meta-package


root@7b3af9f91c0f:/# apt-get remove nvidia-driver-418
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  dkms keyboard-configuration kmod libegl-mesa0 libegl1 libgbm1 libgles2 libjansson4 libnvidia-cfg1-418 libnvidia-common-418 libnvidia-compute-418
  libnvidia-decode-418 libnvidia-encode-418 libnvidia-fbc1-418 libnvidia-gl-418 libnvidia-ifr1-418 libopengl0 libpciaccess0 libpolkit-agent-1-0
  libpolkit-backend-1-0 libpolkit-gobject-1-0 libunwind8 libvdpau1 libwayland-server0 libxcb-xfixes0 libxfont2 libxkbfile1 libxnvctrl0
  linux-headers-4.15.0-47 linux-headers-4.15.0-47-generic linux-headers-generic mesa-vdpau-drivers nvidia-compute-utils-418 nvidia-dkms-418
  nvidia-kernel-common-418 nvidia-kernel-source-418 nvidia-modprobe nvidia-prime nvidia-settings nvidia-utils-418 pkg-config policykit-1 policykit-1-gnome
  python3-xkit screen-resolution-extra sudo udev vdpau-driver-all x11-xkb-utils xfonts-base xfonts-encodings xfonts-utils xserver-common
  xserver-xorg-core-hwe-18.04 xserver-xorg-video-nvidia-418
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  cuda-10-0 cuda-drivers cuda-runtime-10-0 nvidia-driver-418
0 upgraded, 0 newly installed, 4 to remove and 5 not upgraded.
After this operation, 1141 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 80881 files and directories currently installed.)
Removing cuda-10-0 (10.0.130-1) ...
Removing cuda-runtime-10-0 (10.0.130-1) ...
Removing cuda-drivers (418.40.04-1) ...
Removing nvidia-driver-418 (418.40.04-0ubuntu1) ...

root@7b3af9f91c0f:/# apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  dkms keyboard-configuration kmod libegl-mesa0 libegl1 libgbm1 libgles2 libjansson4 libnvidia-cfg1-418 libnvidia-common-418 libnvidia-compute-418
  libnvidia-decode-418 libnvidia-encode-418 libnvidia-fbc1-418 libnvidia-gl-418 libnvidia-ifr1-418 libopengl0 libpciaccess0 libpolkit-agent-1-0
  libpolkit-backend-1-0 libpolkit-gobject-1-0 libunwind8 libvdpau1 libwayland-server0 libxcb-xfixes0 libxfont2 libxkbfile1 libxnvctrl0
  linux-headers-4.15.0-47 linux-headers-4.15.0-47-generic linux-headers-generic mesa-vdpau-drivers nvidia-compute-utils-418 nvidia-dkms-418
  nvidia-kernel-common-418 nvidia-kernel-source-418 nvidia-modprobe nvidia-prime nvidia-settings nvidia-utils-418 pkg-config policykit-1 policykit-1-gnome
  python3-xkit screen-resolution-extra sudo udev vdpau-driver-all x11-xkb-utils xfonts-base xfonts-encodings xfonts-utils xserver-common
  xserver-xorg-core-hwe-18.04 xserver-xorg-video-nvidia-418
0 upgraded, 0 newly installed, 55 to remove and 5 not upgraded.
After this operation, 351 MB disk space will be freed.
Do you want to continue? [Y/n] Y
If you would prefer to access the root account with su(1)
or by logging in directly,
you must set a root password with "sudo passwd".

If you have arranged other means to access the root account,
and you are sure this is what you want,
you may bypass this check by setting an environment variable
(export SUDO_FORCE_REMOVE=yes).

Refusing to remove sudo.
dpkg: error processing package sudo (--remove):
installed sudo package pre-removal script subprocess returned error exit status 1
Removing udev (237-3ubuntu10.19) ...
invoke-rc.d: could not determine current runlevel
invoke-rc.d: policy-rc.d denied execution of stop.
Removing xfonts-base (1:1.0.4+nmu1) ...
Removing xfonts-utils (1:7.7+6) ...
Removing xfonts-encodings (1:1.0.4-2) ...
Removing libegl1:ppc64el (1.0.0-2ubuntu2.2) ...
Removing libegl-mesa0:ppc64el (18.2.8-0ubuntu0~18.04.2) ...
Removing libgbm1:ppc64el (18.2.8-0ubuntu0~18.04.2) ...
Removing libnvidia-compute-418:ppc64el (418.40.04-0ubuntu1) ...
Removing libwayland-server0:ppc64el (1.16.0-1ubuntu1.1~18.04.1) ...
Removing libxcb-xfixes0:ppc64el (1.13-2~ubuntu18.04) ...
Errors were encountered while processing:
nvidia-utils-418
nvidia-compute-utils-418
sudo
E: Sub-process /usr/bin/dpkg returned an error code (1)

다른창에서

[root@powerlinux ~]# docker commit 7b3af9f91c0f test:v0.5
sha256:1f77da5befa581a867371a0ffd5c7e75e09ac04249fdb0e5b09aa014037d0583
[root@powerlinux ~]# docker run --runtime=nvidia --rm -ti test:v0.5
root@07a93a6f8fa6:/# nvidia-smi
Wed Apr 24 03:33:53 2019
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.39       Driver Version: 418.39       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla V100-SXM2...  On   | 00000004:04:00.0 Off |                    0 |
| N/A   39C    P0    39W / 300W |      0MiB / 16130MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  Tesla V100-SXM2...  On   | 00000004:05:00.0 Off |                    0 |
| N/A   40C    P0    38W / 300W |      0MiB / 16130MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   2  Tesla V100-SXM2...  On   | 00000035:03:00.0 Off |                    0 |
| N/A   39C    P0    38W / 300W |      0MiB / 16130MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   3  Tesla V100-SXM2...  On   | 00000035:04:00.0 Off |                    0 |
| N/A   42C    P0    37W / 300W |      0MiB / 16130MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

root@07a93a6f8fa6:/# python
Python 3.5.6 |Anaconda custom (64-bit)| (default, Aug 26 2018, 22:03:11)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> sess=tf.Session()
2019-04-24 03:34:40.080740: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with properties:
name: Tesla V100-SXM2-16GB major: 7 minor: 0 memoryClockRate(GHz): 1.53
pciBusID: 0004:04:00.0
totalMemory: 15.75GiB freeMemory: 15.44GiB
2019-04-24 03:34:40.190470: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 1 with properties:
name: Tesla V100-SXM2-16GB major: 7 minor: 0 memoryClockRate(GHz): 1.53
pciBusID: 0004:05:00.0
totalMemory: 15.75GiB freeMemory: 15.44GiB
2019-04-24 03:34:40.305558: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 2 with properties:
name: Tesla V100-SXM2-16GB major: 7 minor: 0 memoryClockRate(GHz): 1.53
pciBusID: 0035:03:00.0
totalMemory: 15.75GiB freeMemory: 15.44GiB
2019-04-24 03:34:40.426210: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 3 with properties:
name: Tesla V100-SXM2-16GB major: 7 minor: 0 memoryClockRate(GHz): 1.53
pciBusID: 0035:04:00.0
totalMemory: 15.75GiB freeMemory: 15.44GiB
2019-04-24 03:34:40.426315: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0, 1, 2, 3
2019-04-24 03:34:42.072754: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-04-24 03:34:42.072804: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988]      0 1 2 3
2019-04-24 03:34:42.072820: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0:   N Y Y Y
2019-04-24 03:34:42.072832: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 1:   Y N Y Y
2019-04-24 03:34:42.072844: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 2:   Y Y N Y
2019-04-24 03:34:42.072856: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 3:   Y Y Y N
2019-04-24 03:34:42.077306: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 14941 MB memory) -> physical GPU (device: 0, name: Tesla V100-SXM2-16GB, pci bus id: 0004:04:00.0, compute capability: 7.0)
2019-04-24 03:34:42.078146: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:1 with 14941 MB memory) -> physical GPU (device: 1, name: Tesla V100-SXM2-16GB, pci bus id: 0004:05:00.0, compute capability: 7.0)
2019-04-24 03:34:42.078729: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:2 with 14941 MB memory) -> physical GPU (device: 2, name: Tesla V100-SXM2-16GB, pci bus id: 0035:03:00.0, compute capability: 7.0)
2019-04-24 03:34:42.079688: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:3 with 14945 MB memory) -> physical GPU (device: 3, name: Tesla V100-SXM2-16GB, pci bus id: 0035:04:00.0, compute capability: 7.0)
>>>


2018년 8월 10일 금요일

AC922 에서 cuda를 사용하는Docker image 만들기 (RHEL 7.5, CUDA 9.2 runtime)

Docker hub 에 가보면, NVIDIA 에서 각각의 플랫폼 별로 사용할 수 있도록 cuda 환경의 Docker image를 미리 만들어서 올려두었습니다.

아래 경로로 가보시면 Minsky, AC922 서버에서 사용 가능하도록 미리 cuda를 버전별로 설치해놓은 ppc64le용 Docker 이미지들이 보입니다.
https://hub.docker.com/r/nvidia/cuda-ppc64le/

다만 위 링크에서는 Ubuntu와 CentOS에 대해서만 Docker Image를 제공하므로, Redhat 7.5 Base 에서 CUDA 9.2 버전의 base, runtime 관련 패키지를 설치하여 새로운 Docker image 를 만들었습니다. 아래는 Dockerfile 입니다. 미리 RHEL 7.5 base 를 Docker image 형태로 만들어두었으며, Host 서버에서는 RHEL subscription이 등록되어 있어야 합니다. (RHEL에서 제공하는 각 rpms 패키지들을 repository로 미리 등록해두고 사용하기 위해서입니다.)

# vi Dockerfile

#FROM registry.access.redhat.com/rhel7.5:latest
FROM brlee/rhel7.5_base_ppc64le:latest

RUN wget -P /docker http://developer.download.nvidia.com/compute/cuda/repos/rhel7/ppc64le/cuda-repo-rhel7-9.2.148-1.ppc64le.rpm
RUN rpm -i /docker/cuda-repo-rhel7-9.2.148-1.ppc64le.rpm
RUN yum repolist

# Update image
# 'local' means rhel local repository
# To use these repos below in building process, you must set up the RHEL subscription and enable these repos on your host system first.
RUN yum-config-manager --enable local
RUN yum-config-manager --enable rhel-7-for-power-9-rpms
RUN yum-config-manager --enable rhel-7-for-power-9-optional-rpms
RUN yum-config-manager --enable rhel-7-for-power-9-extras-rpms

ENV CUDA_VERSION 9.2.148
ENV CUDA_PKG_VERSION $CUDA_VERSION-1
ENV CUDA_PKG_INSTALL_VERSION 9-2

RUN yum install -y \
        cuda-cudart-$CUDA_PKG_INSTALL_VERSION && \
    ln -s cuda-9.2 /usr/local/cuda

RUN yum install -y \
        cuda-libraries-$CUDA_PKG_INSTALL_VERSION \
        cuda-nvtx-$CUDA_PKG_INSTALL_VERSION

#RUN yum install -y \
#        cuda-libraries-dev-$CUDA_PKG_INSTALL_VERSION \
#        cuda-nvml-dev-$CUDA_PKG_INSTALL_VERSION \
#        cuda-minimal-build-$CUDA_PKG_INSTALL_VERSION \
#        cuda-command-line-tools-$CUDA_PKG_INSTALL_VERSION && \
#    rm -rf /var/cache/yum/*

# nvidia-docker 1.0
LABEL com.nvidia.volumes.needed="nvidia_driver"
LABEL com.nvidia.cuda.version="${CUDA_VERSION}"

RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
    echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf

ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda/lib64/stubs

# nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ENV NVIDIA_REQUIRE_CUDA "cuda>=9.2"

RUN yum clean all &&  rm -rf /var/cache/yum/*