Saturday, June 25, 2016

Setting Up TensorFlow Environment for CPU Based Usages


Deep learning has done wonders work in both Natural Language Processing and Image Processing in last few years. Even though some of these algorithms has been existed for decades, recently performance have been improved and ultimately proved its capabilities by the improvements in hardware infrastructure and accumulated huge data volumes. 

This improvements has lead development and research communities to introduce frameworks consist of deep learning algorithms. Caffe, CNTK, DeepLearning4J, Torch, Theano and TensorFlow are some of the very famous deep learning libraries at the moment.

First things first, I am not a deep learning expert. Luckily I had the opportunity work very closely with some deep learning focused researches soon after I graduated. 

I have been working with Convolutional Neural Networks and Autoencoders in last few months and I was evaluating few of above mentioned libraries, but TensorFlow seemed to like the Chuck Norris of deep learning libraries. In this post I will give the instructions to setup TensorFlow for CPU base usages and run the “Hello world!”.



In here I assumes the environment is Ubuntu and have installed Python 2.7 or 3.0+.

First install the PIP package manager.

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

Set and environment variable for the Tensorflow binary release (here I have added 64bit Python 2.7 version).

$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp27-none-linux_x86_64.whl

Just install the TensorFlow now.

$ sudo pip install --upgrade $TF_BINARY_URL

To test the TensorFlow, open terminal and execute,

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

That’s it, everything should work perfectly. Note that you might have to remove any installations if you have installed TensorFlow before.

In next post I’ll introduce basic usages of TensorFlow.

For source code: https://github.com/isurusiri/tensorflowbasics


No comments:

Post a Comment