YouTube Icon

Code Playground.

How to Install TensorFlow on Ubuntu 18.04


How to Install TensorFlow on Ubuntu 18.04

TensorFlow is a free and open-source stage for AI worked by Google. It is utilized by various associations including Twitter, PayPal, Intel, Lenovo, and Airbus. 

TensorFlow can be introduced framework wide, in a Python virtual climate, as a Docker compartment or with Anaconda . For learning purposes, it is ideal to introduce TensorFlow in a Python virtual climate. This way you can have various distinctive segregated Python conditions on a solitary PC and introduce a particular adaptation of a module on a for every venture premise without stressing that it will influence your different Projects. 

This instructional exercise portrays how to introduce TensorFlow on Ubuntu 18.04. 

Installing TensorFlow on Ubuntu 18.04

The accompanying areas give a bit by bit guidelines about how to introduce TensorFlow in a Python virtual climate on Ubuntu 18.04. 

1. Installing Python 3 and venv

Ubuntu 18.04 boats with Python 3.6 naturally. You can confirm that Python 3 is introduced on your framework by composing: 

python3 -V

The yield should resemble this: 

Python 3.6.6

In the event that you need to utilize Python 3.8 all things considered, check these guide. 

Beginning from Python 3.6, the prescribed method to establish a virtual climate is to utilize the venv module. To introduce the python3-venv bundle that gives the venv module run the accompanying order: 

sudo apt install python3-venv

When the module is introduced we are prepared to establish a virtual climate for our TensorFlow task. 

2. Creating a Virtual Environment

Start by exploring to the registry where you might want to store your Python 3 virtual conditions. It very well may be your home catalog or whatever other index where your client has peruse and compose consents. 

Make another index for the TensorFlow undertaking and compact disc into it: 

mkdir my_tensorflow
cd my_tensorflow

Once inside the index, run the accompanying order to establish the virtual climate: 

python3 -m venv venv

The order above makes an index named venv, which contains a duplicate of the Python paired, the Pip bundle chief , the standard Python library and other supporting records. You can utilize any name you need for the virtual climate. 

To begin utilizing this virtual climate, you have to enact it by running the initiate content: 

source venv/bin/activate

When actuated, the virtual climate's receptacle registry will be added toward the start of the $PATH variable . Likewise your shell's brief will change and it will show the name of the virtual climate you're at present utilizing. For this situation that is venv. 

TensorFlow establishment requires pip rendition 19 or higher. Run the accompanying order to update pip to the most recent variant: 

pip install --upgrade pip

3. Installing TensorFlow

Since the virtual climate is enacted, it's an ideal opportunity to introduce the TensorFlow bundle. 

pip install --upgrade tensorflow

In the event that you have a committed NVIDIA GPU and need to exploit its preparing power, rather than tensorflow introduce the tensorflow-gpu bundle which incorporates GPU uphold. 

Inside the virtual climate, you can utilize the order pip rather than pip3 and python rather than python3. 

To confirm the establishment utilize the accompanying order which will print the TensorFlow adaptation: 

python -c 'import tensorflow as tf; print(tf.__version__)'

At the hour of composing this article, the most recent stable variant of TensorFlow is 2.0.0 


Your TensorFlow adaptation may contrast from the variant appeared here. 

On the off chance that you are new to TensorFlow, visit the Get Started with TensorFlow page and figure out how to assemble your first ML application. You can likewise clone the TensorFlow Models or TensorFlow-Examples storehouses from Github and investigate and test the TensorFlow models. 

Whenever you are finished with your work, deactivate the climate, by composing deactivate and you will re-visitation of your ordinary shell. 



In this instructional exercise, we have told you the best way to introduce TensorFlow on Ubuntu 18.04. 

In the event that you hit an issue or have input, leave a remark underneath.