Install Tensorflow 1.13 on Ubuntu 18.04 with GPU support

A complete guide to installation

Dmitriy Kisil
Mar 15 · 5 min read

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

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

Optional Step: Install 4.19 kernel

Download data:

cd /tmp/
wget -c
wget -c
wget -c
wget -c
sudo dpkg -i *.deb
sudo apt install libelf-dev
wget -c
sudo dpkg -i *.deb
sudo reboot
uname -a
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*
sudo apt-key adv --fetch-keys
echo "deb /" | sudo tee /etc/apt/sources.list.d/cuda.list
sudo apt-get update 
sudo apt-get -o Dpkg::Options::="--force-overwrite" install cuda-10-0 cuda-drivers
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
Output for nvidia-smi command
sudo nvidia-xconfig
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
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
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
pip3 show tensorflow-gpu
Yep! You are ready for using GPU!

Better Programming

Advice for programmers.

Dmitriy Kisil

Written by

Have some interest to Python/ML

Better Programming

Advice for programmers.