Question #5604   Submitted by Answiki on 12/23/2021 at 06:37:00 PM UTC

How to install TensorFLow on Ubuntu 16.04 with virtualenv?

Answer   Submitted by Answiki on 12/23/2021 at 06:41:55 PM UTC

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









2 events in history
Answer by Answiki on 12/23/2021 at 06:41:55 PM

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









Question by Answiki 12/23/2021 at 06:37:00 PM
How to install TensorFLow on Ubuntu 16.04 with virtualenv?
# ID Query URL Count

Icons proudly provided by Friconix.