본문 바로가기
my_lesson/_Python

Python Tensorflow 설치

by boolean 2018. 10. 6.
728x90


Python Tensorflow



Python Tensorflow 설치

Which command to use for checking whether python is 64bit or 32bit




First, open cmd and type in

 $ python 

Then, type in the following two lines 

 >>> import platform 

 >>> platform.architecture()



$ conda create -n tensorflow

CondaValueError: prefix already exist 라는 메세지가 뜨면 

$ conda info --envs

해서 가상환경리스트를 확인한후 동일 이름이 있을경우 새로 하거나 기존 것을 지우고 다시 만든다.

$ (source) activate tensorflow

(source) 부분은 리눅스라 맥에서 사용하며 윈도우즈에서는 빼고 사용한다.

$ conda install tensorflow

$python3


>>> import tensorflow

>>>.... 이하 코드 작성



error importing tensorflow.  Unless you are using bazel,

you should not try to import tensorflow from its source directory;

please exit the tensorflow source tree, and relaunch your python interpreter

from there.


가상환경에서 설치 하지 안았을 때 이런 메세지가 나오는데 원인을 모르겠다.

필자는 그냥 가상환경에서 하기로 했다.



print sess.run(hello)

      ^ syntaxerror invalid syntax (==> print(sess.run(hello))  괄호를 쳐주자


>>> import tensorflow as tf

>>> hello = tf.constant('Hello, TensorFlow!')

>>> sess = tf.Session()

>>> print(sess.run(hello))

Hello, TensorFlow!

>>> a = tf.constant(10)

>>> b = tf.constant(32)

>>> print(sess.run(a + b))

42




Python Tensorflow GPU설치

16 commends 

1 wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1710/x86_64/cuda-repo-ubuntu1710… 

2 sudo dpkg -i cuda-repo-ubuntu1710_9.2.88-1_amd64.deb 

3 sudo apt-get update 

4 sudo apt-get upgrade -y 

5 sudo apt-get install -y opencl-headers build-essential protobuf-compiler libprotoc-dev libboost-all-dev libleveldb-dev hdf5-tools libhdf5-serial-dev libopencv-core-dev libopencv-highgui-dev libsnappy-dev libsnappy1 libatlas-base-dev cmake libstdc++6-4.8-dbg libgoogle-glog0 libgoogle-glog-dev libgflags-dev liblmdb-dev git python-pip gfortran 

6 sudo apt-get clean 

7 sudo apt-get install -y linux-image-extra-`uname -r` linux-headers-`uname -r` linux-image-`uname -r` 

8 sudo apt-get install -y cuda 

9 nvidia-smi 

10 sudo apt-get install python-pip python-dev 

11 sudo pip install --upgrade https://storage.googleapis.com/…/tensorflow-0.8.0rc0-cp27-n… 

12 git clone https://github.com/nlintz/TensorFlow-Tutorials 

13 cd TensorFlow-Tutorials/ 

14 vi ~/.profile # add PATH, LD PATH 

15 source ~/.profile 

16 python 06_autoencoder.py

댓글