Install
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()
print(sess.run(hello))
In the TensorFlow virtual environnement, run the previous script:
(tensorflow)$ python3 tf_test.py
It should display something like:
'Hello, TensorFlow!'
Virtual environnement
Activate
To activate the TensorFlow virtual environnement:
$ source ~/tensorflow/bin/activate
Deactivate
To deactivate the TensorFlow virtual environnement:
(tensorflow)$ deactivate
Download

TensorFlow test file 0.00 KB