필자가 설치한 환경은 운영체제 우분투 14.04 LTS Server 버전이고 GPU는 1080TI를 사용한다.


1. CUDA 설치


https://developer.nvidia.com/cuda-downloads


linux -> x86_64 -> Ubuntu -> 16.04 -> deb(network)

출처: http://goodtogreate.tistory.com/entry/TensorFlow-GPU-버전-우분투-1604에-설치-하기 [GOOD to GREAT]
linux -> x86_64 -> Ubuntu -> 16.04 -> deb(network)

출처: http://goodtogreate.tistory.com/entry/TensorFlow-GPU-버전-우분투-1604에-설치-하기 [GOOD to GREAT]
linux -> x86_64 -> Ubuntu -> 16.04 -> deb(network)

출처: http://goodtogreate.tistory.com/entry/TensorFlow-GPU-버전-우분투-1604에-설치-하기 [GOOD to GREAT]

이렇게 선택후 아래 나오는 대로 한다. (deb파일 다운로드후 입력하라는 커맨드 입력하면 설치됨)


  1. `sudo dpkg -i cuda-repo-ubuntu1404_8.0.61-1_amd64.deb`
  2. `sudo apt-get update`
  3. `sudo apt-get install cuda`


2. cuDNN설치


https://developer.nvidia.com/rdp/cudnn-download


해당 링크에서 로그인이 필요하다. 로그인 후에,,


Download cuDNN v7.0 (August 3, 2017), for CUDA 8.0 <= 이거 설치


이 때, CUDA 버전에 맞는 cuDNN을 설치하여야 한다. 저는 CUDA 8.0 이므로 위 링크 cuDNN을 설치.

* wget 으로 해당링크 다운받으려하니 404 forbidden 오류가 뜬다.

* FTP로 그냥 압축파일을 서버로 옮겼다.



tar xvzf cudnn-8.0-linux-x64-v7.tgz

sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include

sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64

sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*


sudo apt-get install libcupti-dev



또한 ~/.bashrc에 cuda, cudnn 라이브러리 경로를 적어두어야한다.


vi ~/.bashrc


로 파일을 열어서 맨 밑에 아래 텍스트 추가.



export PATH="/home/jyahn/anaconda2/bin:$PATH"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda

tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz
sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*


출처: http://goodtogreate.tistory.com/entry/TensorFlow-GPU-버전-우분투-1604에-설치-하기 [GOOD to GREAT]
tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz
sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*


출처: http://goodtogreate.tistory.com/entry/TensorFlow-GPU-버전-우분투-1604에-설치-하기 [GOOD to GREAT]
tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz
sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*


출처: http://goodtogreate.tistory.com/entry/TensorFlow-GPU-버전-우분투-1604에-설치-하기 [GOOD to GREAT]



tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz
sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

추가적인 dependencies도 설치한다.

$ sudo apt-get install libcupti-dev


출처: http://goodtogreate.tistory.com/entry/TensorFlow-GPU-버전-우분투-1604에-설치-하기 [GOOD to GREAT]

3. tensorflow GPU 설치


아래 링크에 따라 virtual env를 구성한다.

https://github.com/Dataweekends/zero_to_deep_learning_udemy



이후,



source activate ztdl

conda install tensorflow-gpu



4. 설치되었나 확인


bash에서


python


>> import tensorflow as tf

>> sess = tf.Session()



아래와 같이 GPU 이름이 나오면 성공.


name: GeForce GTX 1080 Ti
major: 6 minor: 1 memoryClockRate (GHz) 1.582
pciBusID 0000:02:00.0
Total memory: 10.91GiB
Free memory: 10.75GiB
2017-08-30 17:41:13.373074: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x2d63250 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that.
2017-08-30 17:41:13.374815: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 1 with properties:
name: GeForce GTX 1080 Ti
major: 6 minor: 1 memoryClockRate (GHz) 1.582
pciBusID 0000:03:00.0
Total memory: 10.91GiB
Free memory: 10.75GiB
2017-08-30 17:41:13.695077: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x2d67600 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that.
2017-08-30 17:41:13.696140: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 2 with properties:
name: GeForce GTX 1080 Ti
major: 6 minor: 1 memoryClockRate (GHz) 1.582
pciBusID 0000:82:00.0
Total memory: 10.91GiB
Free memory: 10.75GiB
2017-08-30 17:41:14.016589: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x2d6b9b0 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that.
2017-08-30 17:41:14.017710: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 3 with properties:
name: GeForce GTX 1080 Ti
major: 6 minor: 1 memoryClockRate (GHz) 1.582
pciBusID 0000:83:00.0
Total memory: 10.91GiB
Free memory: 10.75GiB



참고


http://goodtogreate.tistory.com/entry/TensorFlow-GPU-%EB%B2%84%EC%A0%84-%EC%9A%B0%EB%B6%84%ED%88%AC-1604%EC%97%90-%EC%84%A4%EC%B9%98-%ED%95%98%EA%B8%B0