There are many different versions of TensorFlow, and many different ways to install it. For this tutorial we will be installing TensorFlow with CPU Support on Ubuntu 16.04, using Pip. This installation method ensures that every user on the server has access to TensorFlow.
Other installation options:
For more information on different installation methods for TensorFlow on Ubuntu, see the official documentation.
- A server with Ubuntu 16.04, and either:
- Python 2.7 and Pip 8.1+, or
- Python 3.4+ and Pip 3
To check the Python version, use the command:
To install Pip with Python 2.7:
sudo apt install python-pip python-dev
To install Pip3 with Python 3.4+:
sudo apt install python3-pip python3-dev
Install Tensorflow with the following command:
pip install tensorflow
pip3 install tensorflow
TensorFlow will be downloaded and installed.
Validate the Installation
Google has included a TensorFlow test script which you can use to verify that TensorFlow was installed correctly.
Enter the Python client with the command:
Paste in the following program, then hit Enter:
# Python import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello))
If TensorFlow is installed correctly, the system will reply with: