A complete guide to installation

Dmitriy Kisil
Mar 15 · 5 min read

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 http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/linux-headers-4.19.0-041900_4.19.0-041900.201810221809_all.deb
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/linux-headers-4.19.0-041900-generic_4.19.0-041900.201810221809_amd64.deb
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/linux-image-unsigned-4.19.0-041900-generic_4.19.0-041900.201810221809_amd64.deb
wget -c http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19/linux-modules-4.19.0-041900-generic_4.19.0-041900.201810221809_amd64.deb

Install:

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 security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4.3_amd64.deb
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:

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 http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 /" | 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:

nvidia-smi
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):

nvidia-settings
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

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
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!

Links, that should help you:

Better Programming

Advice for programmers.

Dmitriy Kisil

Written by

Have some interest to Python/ML

Better Programming

Advice for programmers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade