How To Install TensorFlow on Ubuntu 18.04

How To Install TensorFlow on Ubuntu 18.04

In this article, we demonstrate to you how to install TensorFlow on Ubuntu 18.04

Note: This article is not for building from source because 1.13 already supports the CUDA 10.0 and CuDNN 7.5. Also, here you will not find the NCCL install — accordingly, release NCCL is part of core and does not need to be installed.

Why not install 2.0 version? Tensorflow 2.0 in alpha now — stable release is planned in Q2 this year. If you want try this now, check the official guide from Tensorflow Team here.

As usually, I have added the installation process of the latest kernel which has a long term release (in this case 4.19). You can check information about the kernel here. This part is optional and requires you to sign an unsigned kernel — which can be dangerous — so feel free to skip this part.

So, let’s begin!

Step 1: Update and Upgrade Your System

sudo apt-get update 
sudo apt-get upgrade

Step 2: Verify You Have a CUDA-Capable GPU

lspci | grep -i nvidia

If you do not see any settings, update the PCI hardware database that Linux maintains by entering update-pciids (generally found in /sbin) at the command line and rerun the previous lspci command.

Step 3: Verify You Have a Supported Version of Linux

To determine which distribution and release number you’re running, type the following in the command line:

uname -m && cat /etc/*release

The x86_64 line indicates you are running on a 64-bit system which is supported by cuda 10.0.

Optional Step: Install 4.19 kernel

Download data:

cd /tmp/
wget -c
wget -c
wget -c
wget -c


sudo dpkg -i *.deb

For now you got the kernel but need it signed to use (in other cases you can boot from kernel and get a message that your version of kernel is unsigned and the system cannot be booted). For that you need to install lib-elf package:

sudo apt install libelf-dev

Then download and install libssl (if link below is outdated, please, go here and replace ubuntu4.3_amd64 with a new version):

wget -c
sudo dpkg -i *.deb

After installation, reboot your ubuntu system:

sudo reboot

Check the linux kernel version :

uname -a

You will get something like this:

This is image title

You may delete this kernel if you want to (be sure you have at least one additional kernel to keep your system bootable):

sudo dpkg --purge linux-image-unsigned-4.19.0-041900-generic linux-image-4.19.0-041900-generic

Step 4: Install NVIDIA CUDA 10.0

Remove previous cuda installation (if you installed cuda before):

sudo apt-get purge nvidia*
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /usr/local/cuda*

Add key and download:

sudo apt-key adv --fetch-keys
echo "deb /" | sudo tee /etc/apt/sources.list.d/cuda.list

Install CUDA-10.0:

sudo apt-get update 
sudo apt-get -o Dpkg::Options::="--force-overwrite" install cuda-10-0 cuda-drivers

Reboot and type:

echo 'export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc
source ~/.bashrc
sudo ldconfig

For check if install was successful: after executing next command you need to see version of your nvidia-drivers and GPU:


Output for nvidia-smi command

If you have low screen resolution, fix this with Xorg:

sudo nvidia-xconfig

If this has not helped, check one of my previous installation (I have described in detail what should help if problems remain).

Also, don’t forget to check nvidia-settings — here you can find out how much GPU is loaded (for example, if trained neuralnets using ML framework):


This is image title

This tab is the most useful, for my opinion

Step 5: Install cuDNN 7.5.0

Go here and click Download CuDNN. Log in and accept the required agreement. Click the following: “Download cuDNN v7.5.0 (Feb 21, 2019), for CUDA 10.0” and then “cuDNN Library for Linux”.

Download tgz from here

Download tgz from here

Then install:

tar -xf cudnn-10.0-linux-x64-v7.5.0.56.tgz
sudo cp -R cuda/include/* /usr/local/cuda-10.0/include
sudo cp -R cuda/lib64/* /usr/local/cuda-10.0/lib64

Step 6: Install Dependencies

Install libcupti:

sudo apt-get install libcupti-dev
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc

Python related:

sudo apt-get install python3-numpy python3-dev python3-pip python3-wheel

Step 7: Install Tensorflow-GPU

Install Tensorflow-GPU 1.13 using pip:

pip3 install --user tensorflow-gpu==1.13.1

Now you can check which tensorflow version you install:

pip3 show tensorflow-gpu

This is image title Yep! You are ready for using GPU!

As always, I suggest you go this article if you want to see GPU temperature from system tray. For installing previous installing versions of Tensorflow you can check through my profile.

Have a nice day!

tensorflow ubuntu

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How to Install Microsoft Teams on Ubuntu 20.04

In this tutorial, we will show you how to install Microsoft Teams on Ubuntu 20.04 machine. we can install teams using Debian installer file or by adding microsoft repository.

How to Install TensorFlow on Ubuntu 20.04 | 18.04

This brief tutorial shows students and new users how to install TensorFlow on Ubuntu 20.04 | 18.04. For those who don’t know, TensorFlow is an end-to-end open source platform for machine learning…

How to Install TensorFlow on Ubuntu 20.04

TensorFlow is a free and open-source platform for machine learning built by Google. This tutorial explains how to install TensorFlow in a Python virtual environment on Ubuntu 20.04.

2 Ways to Upgrade Ubuntu 18.04/18.10 To Ubuntu 19.04 (GUI & Terminal)

This tutorial is going to you 2 ways to upgrade Ubuntu 18.04 and Ubuntu 18.10 to 19.04. The first method uses the graphical update manger and the second method uses command line. Usually you use the graphical update manager to upgrade Ubuntu desktop and use command line to upgrade Ubuntu server, but the command-line method works for desktops too.

How to setup TensorFlow on Ubuntu

How to setup TensorFlow on Ubuntu - This tutorial will help you set up TensorFlow 1.12 on Ubuntu 16.04 with a GPU using Docker and nvidia-docker.