How to install TensorFLow on Ubuntu 16.04 with virtualenv?
This guide explains how to install TensorFlow on Ubuntu 16.04 with virtualenv:
1. 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.
2. Test your installation
Create the file tf_test.py
containing the following code:
# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
In the TensorFlow virtual environnement, run the script:
(tensorflow)$ python3 tf_test.py
It should display something like:
'Hello, TensorFlow!'
3. Virtual environnement
Activate: to activate the TensorFlow virtual environnement:
$ source ~/tensorflow/bin/activate
Deactivate: to deactivate the TensorFlow virtual environnement:
(tensorflow)$ deactivate
This guide explains how to install TensorFlow on Ubuntu 16.04 with virtualenv:
1. 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.
2. Test your installation
Create the file tf_test.py
containing the following code:
# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
In the TensorFlow virtual environnement, run the script:
(tensorflow)$ python3 tf_test.py
It should display something like:
'Hello, TensorFlow!'
3. Virtual environnement
Activate: to activate the TensorFlow virtual environnement:
$ source ~/tensorflow/bin/activate
Deactivate: to deactivate the TensorFlow virtual environnement:
(tensorflow)$ deactivate
# | ID | Query | URL | Count |
---|