How to install TensorFlow in ubuntu 16.04

Posted on Updated on

In this post, you will install TensorFlow in Ubuntu 16.04 LTS 64 bit OS. But following steps are also worked in Ubuntu 14.04 64 bit os.

TensorFlow is an open-source software library for Machine Intelligence.

Python is already installed in Ubuntu. So no need to install again. If you want to check version of installed python, you can use following command.

$ python --version

Following steps are for installing TensorFlow using Python 2.7:

Step: 1

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

Step: 2

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

Step: 3

$ sudo pip install --upgrade $TF_BINARY_URL

installtensorflow_cpu

Test your installation

$ python
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, Parth!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
Hello, Parth!
>>> a = tf.constant(10)
>>> b = tf.constant(20)
>>> print(sess.run(a + b))
30

verify_tensorflow

Configuration of Python Editor for TensorFlow

1.  Download PyCharm editor from below link. (Download community edition)

https://www.jetbrains.com/pycharm/download/#section=linux

2.  Unpack the PyCharm Community Edition distribution archive that you downloaded to where you wish to install the program. We will refer to this destination location as your {installation home} below.

3. Open a console and cd into “{installation home}/bin” and type:

 ./pycharm.sh

to start the application.

4. Once it is installed, for reuse you can search PyCharm or you can set icon in quick launcher.

Your First TensorFlow Program in PyCharm Editor

1. Open PyCharm Editor

2. Create New Project

3. Right Click on Project, Go to new -> select ‘Python File’ -> Give file name

4. Copy below code

import tensorflow as tf
 hello = tf.constant('Hello, Parth!')
 a = tf.constant(30)
 b = tf.constant(50)
 # Start tf session
 sess = tf.Session()
 # Run the op
 print(sess.run(hello))
 print(sess.run(a+b))

5. Go to ‘Run’ -> click on ‘Run..’ -> select ‘Your given file name’

pycharm

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s