TensorFlow GPU
1. 텐서플로우 분산처리기능은 0.8부터 지원함
1.1 성능
GPU개수에 50%정도 비례하여 성능향상을 함. (*초기 PNNL발표자료)
1.2 Mechanism
서버간 통신에는 PNNL은 *MPI를 사용하고, 학습을 위한 데이터를 쪼개어 각 서버에 독립적으로 모델을 학습함.
학습된 모델의 가중치(Weight)와 바이어스(Bias)를 동기화 시킬때 알고리즘이 복잡해지고, MPI프로토콜이 충분히 빠르기에,
비동기(Asynchronous) 방식을 사용하지 않고 동기적인 방법을 채택함.
- MPI대신 맵 리듀스 스타일의 하둡이나 스파크를 선택할 수 있었지만, 높은 I/O와 고성능 네트워크 인터페이스에 대한 지원이 부족하여 제외.
서버간 통신 구글은 gRPC이용.
- (추가) 업그레이드가 아니고 텐서플로우를 처음 설치하시는 경우에는 pip 명령에서 ‘–upgrade’ 옵션을 빼셔야 합니다.
- CPUs are great for task parallelism
- GPUs are great for data parallelism
1. 환경 구성에 필요한 설치 패키지
- CUDA
- OpenMPI
- Tensorflow GPU
2. 설치 기준
- CUDA 9.0
- OpenMPI 3.0
- Tensorflow GPU 1.5.0
- prebuild Tensorflow GPU 1.5는 CUDA 9.0 지원
- CUDA 9.1을 사용하기 위해서는 Tensorflow GPU를 따로 빌드할 것
2.1 OpenMPI 설치
NPROCS=`grep -c processor /proc/cpuinfo`;
wget https://www.open-mpi.org/software/ompi/v3.0/downloads/openmpi-3.0.
0.tar.gz
tar zxf openmpi-3.0.0.tar.gz
cd openmpi-3.0.0
./configure --enable-orterun-prefix-by-default
make -j $NPROCS all # for parallel compile
make install
ldconfig
2.2 Tensorflow GPU 설치
Tensorflow-GPU 설치시 필요 모듈
- 인터넷이 연결된 경우 자동으로 다운로드 및 설치 진행
enum34 (>=1.1.6)
backports.weakref (>=1.0rc1)
mock (>=2.0.0)
wheel
tensorflow-tensorboard (<1.6.0,>=1.5.0)
protobuf (>=3.4.0)
six (>=1.10.0)
numpy (>=1.12.1)
absl-py (>=0.1.6)
- 인터넷이 안되는 경우에는 해당 모듈을 다운로드후 별도 설치
- python 패키지 다운로드 https://pypi.python.org/pypi
wget https://pypi.python.org/packages/0b/80/094c2f7b05acb1089333d
93c41323e93f3296eaa7a785d9848973e4e36bd/tensorflow_gpu-1.5.0-cp27-
cp27mu-manylinux1_x86_64.whl#md5=d519dd5669665acc286b7eb186e58f7a
pip install tensorflow_gpu-1.5.0-cp27-cp27mu-
manylinux1_x86_64.whl</code>
3. Horovod 설치
- CUDA Driver, OpenMPI가 설치되어있는 경우에만 설치 가능
- 설치시 openmpi의 binary가 존재하는 PATH를 지정
export PATH=/usr/local/bin:$PATH
pip install --no-cache-dir horovod
3.1 Horovod so 파일 위치 (python 2.7 기준)
- openmpi 라이브러리와 링크 되었는지 확인
ldd /usr/local/lib/python2.7/dist-
packages/horovod/tensorflow/mpi_lib.so | grep mpi
libmpi.so.40 => /usr/local/lib/libmpi.so.40 (0x00007f6fc001b000)</code>
CUDA base GPU computing
https://www.slideshare.net/npinto/harvard-cs264-03-introduction-to-gpu-computing-cuda-basics
Distribution Strategy
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/distribute
Current 1.12.0 (Nov, 6, 2018)
https://github.com/tensorflow/tensorflow/releases
on Release 1.11.0
- DistributionStrategy:
- Add multi-GPU DistributionStrategy support in tf.keras. Users can now use
fit
,evaluate
andpredict
to distribute their model on multiple GPUs. - Add multi-worker DistributionStrategy and standalone client support in Estimator. See [README] (https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/distribute) for more details.
Related Links
PNNL, https://plus.google.com/100922732508111452182
MPI, https://en.wikipedia.org/wiki/Message_Passing_Interface
gRPC, https://grpc.io
https://tensorflow.blog/2016/04/05/텐서플로우tensorflow의-병렬-처리-버전이-곧-나온다/
https://tensorflow.blog/2016/04/14/tensorflow-0-8-distributed/