05-04 14:17
Notice
Recent Posts
Recent Comments
관리 메뉴

Scientific Computing & Data Science

[Artificial Intelligence / TensorFlow] Windows Anaconda Python 환경에서 GPU 지원 TensorFlow 설치방법 본문

Artificial Intelligence/TensorFlow

[Artificial Intelligence / TensorFlow] Windows Anaconda Python 환경에서 GPU 지원 TensorFlow 설치방법

cinema4dr12 2017. 8. 30. 11:32

Written by Geol Choi |  Aug


최근 Continuum Anaconda가 4.4.0으로 강제(?) 업그레이드 되면서 그 동안 잘 돌아가던 GPU Support TensorFlow가 동작하지 않는 현상이 발생하였습니다 (물론 Anaconda 환경에서 CPU 기반 TensorFlow는 잘 동작하고 있습니다).


Ananconda 4.4.0으로 업그레이드 후 기존에 해왔던대로, TensorFlow 공식 블로그의 "Installing TensorFlow on Windows"를 참고하여 Anaconda Prompt에서 다음 절차대로 GPU 지원 TensorFlow를 설치해 보았습니다.




Installing with Anaconda

The Anaconda installation is community supported, not officially supported.

Take the following steps to install TensorFlow in an Anaconda environment:

  1. Follow the instructions on the Anaconda download site to download and install Anaconda.

  2. Create a conda environment named tensorflow by invoking the following command:

    C:> conda create -n tensorflow python=3.5

  3. Activate the conda environment by issuing the following command:

    C:> activate tensorflow (tensorflow)C:> # Your prompt should change

  4. Issue the appropriate command to install TensorFlow inside your conda environment. To install the CPU-only version of TensorFlow, enter the following command:

    (tensorflow)C:> pip install --ignore-installed --upgrade tensorflow

    To install the GPU version of TensorFlow, enter the following command (on a single line):

    (tensorflow)C:> pip install --ignore-installed --upgrade tensorflow-gpu


그리고나서, "tensorflow-gpu" Python 환경에서 tensorflow module을 불러오기를 시도했습니다.



그랬더니... 다음과 같이 에러 메시지가 쭈~욱 나오면서 라이브러리가 없다고 투덜투덜 대고 있습니다.



Command Line Tool에 언급된 내용으로 구글링하면서 문제 해결을 시도해 보았으나, 딱히 시원한 답변을 찾기는 어려웠습니다.


그래서, 설치가 잘못된건가 의심해서 여러번 재설치해보기도 하고 Anaconda를 지웠다 깔았다하면서 삽질을 여러번 해보기도 하고 CUDA 라이브러리(cuDnn 등)를 다운로드받아 여러번 다시 시도를 해보았으나, 제대로 동작하지 않았습니다.


그러다가 ANACONDA CLOUD 페이지에서 tensorflow-gpu 패키지 설치에 대한 안내를 발견하였고, 역시 Anaconda Prompt에서 "conda install명령을 통해 GPU 기반 tensorflow module을 설치해 보았습니다:


> conda install -c anaconda tensorflow-gpu 



설치가 완료된 후, "tensorflow-gpu" Python 환경에서 python prompt로 들어가 다음과 같이 tensorflow module을 임포트 했더니, 아무런 에러 메시지 없이 잘 동작함을 확인하였습니다.


>>> import tensorflow as tf



Anaconda 자체에서 TensorFlow 설치를 지원해 주면서, GPU를 지원하는 TensorFlow 라이브러리 설치가 너무너무 간편해 졌습니다.


혹시라도, 저와 똑같이 Anaconda를 강제 업데이트 한 후, GPU 지원 TensorFlow를 설치하는데 애를 먹고 계신 분들에게 도움이 되셨으면 좋겠습니다.

Comments