TensorFlow-GPU Installation Guide in Windows 10 (윈도우10 텐서플로우-GPU 설치법)

TensorFlow-GPU Installation Guide in Windows 10

윈도우10 텐서플로우-GPU 설치법





설치 대상 환경의 운영체제 정보 및 하드웨어 정보는 다음과 같다.

The OS information and hardware information of the installation target environment are as follows.

<Installation Environment>

  • Operating system information
    • Windows 10 Enterprise(similar to Windows 10 Pro), version 1703, OS Build 15063.413, 64bit OS 
  • Hardware information
    • CPU : Intel Core i7-7700HQ 2.80GHz 
    • GPU : GeForce GTX 1060 6GB GDDR5 

<Installation Process: 전체 설치 과정>

  1. Anaconda installation: 아나콘다 설치 
  2. CUDA installation : CUDA 라이브러리 설치 
  3. cuDNN installation : cuDNN 라이브러리 설치 
  4. TensorFlow installation : 텐서플로우 설치 
  5. TensorFlow test : 구동 테스트 

1. Anaconda installation (아나콘다 설치)

아나콘다는 파이썬으로 구성된 데이터 과학 관련 오픈소스이다. 데이터 과학 연산에 활용되는 100여개의 파이썬, R, 스칼라(Scala) 패키지들을 통합한 환경을 제공하며, 그 외에도 720여개의 연관 패키지들을 손쉽게 연동할 수 있는 환경을 제공한다.

Anaconda is an open source data science module made up of Python. This provides an integrated environment for over 100 Python, R, and Scala packages used for data science operations, and provides an environment for easy-installation about 720 related packages.
[source: https://www.continuum.io]

아나콘다는 최신 버전의 파이썬(3.5버전 이상)을 내장하고 있기 때문에, 만약 기존에 파이썬2 또는 파이썬3가 설치된 컴퓨터라면, Path 충돌을 피하기 위해 기존에 설치되었던 파이썬을 삭제할 후 아나콘다를 설치할 것을 권장한다.

Anaconda includes the latest version of Python (version 3.5 or later), so if you already installed Python 2 or Python, I recommends you remove the existing Python and install anaconda to avoid path conflicts.


2. CUDA library installation (CUDA 라이브러리 설치)

CUDA(Compute Unified Device Architecture)는 GPU의 가상 명령 집합과 병렬 연산 자원들에 직접 접근하기 위한 GPGPU(General-Purpose computing on GPU) 기술이다. 최신 텐서플로우 버전은 CUDA 8.0 이상 버전을 사용할 것을 권장하고 있다.

Compute Unified Device Architecture (CUDA) is a general-purpose computing on GPU (GPGPU) technology for direct access to GPU virtual instruction sets and parallel computing resources. The latest tensor flow version recommends using CUDA 8.0 or later. [source : https://developer.nvidia.com/computeworks, https://ko.wikipedia.org/wiki/CUDA]


3. cuDNN installation (cuDNN 라이브러리 설치)

cuDNN은 Deep Neural Network(심층신경망)를 위해 nVidia사가 제공하는 라이브러리이다. 다운로드를 위해서는 nVidia developer에 회원가입을 해야한다.

CuDNN is a library provided by nVidia for the Deep Neural Network. To download it, downloader should register with nVidia developer.
  • download link : https://developer.nvidia.com/cudnn 
  • available version (2017-04-27) : cuDNN v5.1 for CUDA 8.0/7.5 
    • latest version (2017-04-27) : cuDNN v6.0 for CUDA 8.0/7.5 

현재(2017-06-21) cuDNN v6.0 버전은 텐서플로우와 완벽히 호환되지 않는다. v6.0 버전 설치시, 텐서플로우에서 module import error가 발생한다. 따라서 텐서플로우와 정상적으로 호환되는 cuDNN v5.1 버전을 설치해야 한다. cuDNN은 압축파일 형태로 다운로드되며, CUDA 라이브러리가 설치된 폴더(예: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0)에 압축해제하여 나온 폴더들(lib, include, bin)을 덮어쓰면 된다.

Current (2017-06-21) cuDNN v6.0 version is not fully compatible with TensorFlow. When installing v6.0 version, you might see "module import error" in TensorFlow. Therefore, you need to install cuDNN v5.1 version which is compatible with TensorFlow entirely. cuDNN is downloaded as a compressed file and you just needs to overwrite them(lib, include, bin forders) into CUDA library forder (eg C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0).



4. TensorFlow installation (텐서플로우 설치)

윈도우 커맨드 창(cmd)을 관리자 권한으로 실행한 후 다음 명령어를 이용하여 텐서플로우를 설치한다.

Run the Windows command window (cmd) with administrator privileges and install the tensor flow using the following command.

pip install --upgrade pip
pip install tensorflow-gpu

5. TensorFlow test (구동 테스트)

아나콘다 설치시 함께 설치된 Anaconda Prompt를 관리자 권한으로 실행한 후, 다음 파이썬 코드를 실행한다.

Run Anaconda Prompt(with administrator) and run the following Python code.

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

정상적으로 설치된 경우, 다음과 같은 출력 결과를 확인할 수 있다.

If it is installed normally, you can see the following output.

>> Hello, Tensorflow!
아나콘다와 함께 설치된 주피터에서도 동일한 소스코드로 구동테스트를 진행할 수 있다.

You can test with Jupiter installed with anaconda.

댓글 없음:

Powered by Blogger.