Quick and simple TensorFlow installation guide for Ubuntu 16.04 (virtualenv)


Since Python 3 is natively installed on Ubuntu 16.04, TensorFLow installation can be done quickly with the following lines:

$ sudo apt-get install python3-pip python3-dev python-virtualenv
$ virtualenv --system-site-packages -p python3 ~/tensorflow
$ source ~/tensorflow/bin/activate
(tensorflow)$ pip3 install --upgrade tensorflow

Note that TensorFlow is installed in a virtual environment isolated from other Python development.

Test your installation

Download or create the file tf_test.py containing :

# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()

In the TensorFlow virtual environnement, run the previous script:

(tensorflow)$ python3 tf_test.py 

It should display something like:

'Hello, TensorFlow!'

Virtual environnement


To activate the TensorFlow virtual environnement:

$ source ~/tensorflow/bin/activate


To deactivate the TensorFlow virtual environnement:

(tensorflow)$ deactivate


Leave a Reply

Your email address will not be published. Required fields are marked *