좋은 프로그램은 마음의 여유에서 나온다.

구글 텐서플로우(tensorflow) 설치해보기 본문

프로그래밍/기타

구글 텐서플로우(tensorflow) 설치해보기

좋은데이 2016. 5. 20. 17:46

구글이 딥러닝이나 머신러닝을 위해 오픈소스로 배포한 라이브러리.


레퍼런스는 https://www.tensorflow.org/versions/master/get_started/os_setup.html#train-your-first-tensorflow-neural-net-model



작업 환경


맥북 프로, OX X 10.11.4


i5 2.9GHZ


16G Memory




설치 요구 사항


1. 파이썬 2.7이나 3.3 이상


2. CUDA 툴킬 7.5, cuDNN 4 에 최적이며 다른 버전은 소스에서 설치할 수 있음 (Cuda toolkit >= and cuDNN 6.5(v2), 7.0(v3), v5)




dmg로 인스톨하기


next만 눌러주면됨.  sample은 필요없으면 체크 해제.












설치 방법은 무려 5가지.


1. Pip로 설치 : 파이썬 패키지 관리 툴인 pip를 이용해 설치. 이전 설치 버전을 업그레이드 할 수 있음.


2. Virtualenv설치 : 파이썬 가상 환경을 만들어서 인스톨


3. Anaconda 설치 : 파이썬 기반의 데이터 분석용 오픈 소스를 모아놓은 개발 플랫폼 같은 것인 아나콘다에 설치


4. 도커 설치 : 도커 컨테이너에 설치하여 사용


5. 소스 빌드하여 설치 : 소스 코드를 빌드하여 설치



pip로 설치해보기~


# pip 설치
$ sudo easy_install pip
Searching for pip
Best match: pip 8.0.2
Processing pip-8.0.2-py2.7.egg
pip 8.0.2 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Using /Library/Python/2.7/site-packages/pip-8.0.2-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip

# 텐서 플로우 설치
$ sudo easy_install --upgrade six
Searching for six
Reading https://pypi.python.org/simple/six/
Best match: six 1.10.0
Processing six-1.10.0-py2.7.egg
six 1.10.0 is already the active version in easy-install.pth

Using /Library/Python/2.7/site-packages/six-1.10.0-py2.7.egg
Processing dependencies for six
Finished processing dependencies for six

$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl
ory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/soundllydev/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting tensorflow==0.8.0 from https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl
  Downloading https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl (19.3MB)
    100% |████████████████████████████████| 19.3MB 12kB/s
# 에러!
# pip로 했더니 에러가 나서 pip3로 인스톨
$ sudo pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py3-none-any.whl
The directory '/Users/soundllydev/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/soundllydev/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting tensorflow==0.8.0 from https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py3-none-any.whl
  Downloading https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py3-none-any.whl (19.3MB)
    100% |████████████████████████████████| 19.3MB 30kB/s
Collecting protobuf==3.0.0b2 (from tensorflow==0.8.0)
  Downloading protobuf-3.0.0b2-py2.py3-none-any.whl (326kB)
    100% |████████████████████████████████| 327kB 597kB/s
Collecting wheel>=0.26 (from tensorflow==0.8.0)
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |████████████████████████████████| 69kB 676kB/s
Collecting six>=1.10.0 (from tensorflow==0.8.0)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting numpy>=1.10.1 (from tensorflow==0.8.0)
  Downloading numpy-1.11.0-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.8MB)
    100% |████████████████████████████████| 3.8MB 145kB/s
Collecting setuptools (from protobuf==3.0.0b2->tensorflow==0.8.0)
  Downloading setuptools-21.2.1-py2.py3-none-any.whl (509kB)
    100% |████████████████████████████████| 512kB 843kB/s
Installing collected packages: setuptools, six, protobuf, wheel, numpy, tensorflow
  Found existing installation: setuptools 18.2
    Uninstalling setuptools-18.2:
      Successfully uninstalled setuptools-18.2
Successfully installed numpy-1.11.0 protobuf-3.0.0b2 setuptools-21.2.1 six-1.10.0 tensorflow-0.8.0 wheel-0.29.0

텐서플로우 설치 확인하기
python3
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  5 2015, 21:12:44)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
b'Hello, TensorFlow!'
>>> print(sess.run(hello))
b'Hello, TensorFlow!'
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print(sess.run(a + b))
42
>>>


근데 이제 뭘해야하지...

Comments