Machine learning library provided by Google @ shuhei_f's What is TensorFlow is easy to understand.
Prepare Ubuntu with Build Ubuntu environment with Vagrant + VirtualBox.
Ubuntu 15.04 / Python 2.7.9
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=15.04
DISTRIB_CODENAME=vivid
DISTRIB_DESCRIPTION="Ubuntu 15.04"
$ python --version
Python 2.7.9
$ export http_proxy="$USERNAME:$PASSWORD@$HOST:$PORT"
$ export https_proxy="$USERNAME:$PASSWORD@$HOST:$PORT"
$ curl -kL https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python
$ sudo pip install virtualenv
$ mkdir ~/tensorflow
$ virtualenv --system-site-packages ~/tensorflow
$ cd ~/tensorflow
$ source bin/activate
(tensorflow)$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.5.0-cp27-none-linux_x86_64.whl
If you get the following error, it means that "python-dev" is not included.
Install with sudo apt-get install python-dev
.
(Omitted)
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-ZZhjh_/numpy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-UmWBtU-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-ZZhjh_/numpy
hello-tf.py
import tensorflow as tf
import multiprocessing as mp
core_num = mp.cpu_count()
config = tf.ConfigProto(
inter_op_parallelism_threads=core_num,
intra_op_parallelism_threads=core_num )
sess = tf.Session(config=config)
hello = tf.constant('hello, tensorflow!')
print sess.run(hello)
a = tf.constant(10)
b = tf.constant(32)
print sess.run(a+b)
(tensorflow)$ python hello-tf.py
I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 2
I tensorflow/core/common_runtime/local_session.cc:45] Local session inter op parallelism threads: 2
hello, tensorflow!
42
Vagrantfile
config.vm.network :forwarded_port, host: 6006, guest: 6006
$ vagrant reload
$ tensorboard --logdir=[log_dir]
Starting TensorBoard on port 6006
(You can navigate to http://localhost:6006)
Pip installation became easier before I knew it I tried running Hello World with TensorFlow & its explanation
Recommended Posts