22 C
Texas
angeloma
Senior Writer and partner

How to install Tensorflow on Ubuntu 18.04?

Hi, folks. This time you will learn how to install Tensorflow on Ubuntu 18.04.

According to the project website, “Tensorflow is an end-to-end open source platform for machine learning. It has a comprehensive, flexible ecosystem of tools, libraries and community resources that lets researchers push the state-of-the-art in ML and developers easily build and deploy ML powered applications”.

Therefore, with Tensorflow you can build neural networks to decipher patterns used by humans. It is also important to say that, it is open-source and is currently used by Google, which shows us the power of it.

Tensorflow is very efficient in managing computer resources because it allows you to deploy computing to one or more CPUs or GPUs on desktops, servers, or mobile devices with a single API.

- Advertisement -

So, if you’re going to work with it, or are curious about this technology, it’s a good idea to know how to install it.

Install Tensorflow on Ubuntu 18.04

Preparing the environment

Tensorflow is built on Python and requires at least version 3.4. So first we’ll make sure it’s installed and what version the system has.

:~$ python3 -V
python 3.6.9

Therefore, we have a compatible version so the installation will happen without problems.

Then we will install some packages needed to perform the installation of Tensorflow. One of them is Pip that will serve us as a package manager to install it.

:~$ sudo apt install python3-venv python3-pip
1.- Installing the python packages
1.- Installing the python packages

Once these packages are installed, we need to create a virtual Python environment and in it install Tensorflow. This is the safest way to do the installation.

First, create a folder for it:

~$ mkdir tensorflow

Then access the folder:

:~$ cd tensorflow

Now we will create the virtual environment inside this folder with the following command:

:~$ python3 -m venv venv

And finally, we activate it with the following command:

:~$ source venv/bin/activate
2.- Enabling the python virtual environment
2.- Enabling the python virtual environment

Now we can install Tensorflow on Ubuntu 18.04.

Getting Tensorflow on Ubuntu 18.04

Once inside the virtual environment, we proceed to install Tensorflow as follows using Pip.

:~$ pip install tensorflow

This will install the current version of the package.

To verify that everything went well, use the following command:

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

If you want to update tensorflow, remember that the command is as follows:

:~$ pip install --upgrade tensorflow

After you have finished working, you can disable the virtual environment.

:~$ deactivate

And that is it. Tensorflow is installed and ready to the job.

Some issues

It is possible that some mistakes may occur. For example, displaying the version of Tensorflow might give the following error:

Illegal instruction (core dumped)

A solution could be to install Tensorflow version 1.5 with the following command:

:~$ pip install tensorflow==1.5

Another option is that the CPU or GPU does not have enough capacity to handle the package.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

1 COMMENT

  1. Great article!
    I am so happy to read this. This is the type of manual that needs to be given and not the accidental misinformation that is at the other blogs. I appreciate your sharing this best article.
    Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article