This post is a step-by-step guide to installing Tensorflow -GPU on Ubuntu 18.04 LTS (bionic).
MY SYSTEM SPECIFICATIONS:
OS : Ubuntu 18.04 LTS, 64 bit (i7, 8th Gen processor)
GeForce GTX 1050 Ti GPU with 4GB RAM
I would like to keep the process and post as short as possible so that, the process can be followed easily by anyone and everyone!
STEPS FOR INSTALLING
- The First step in the process is to get the right Nvidia Display drivers.
I figured out that Nvidia-390 is the most stable for me, though nvidia-440 was latest driver for my system. - Purge all preinstalled nvidia drivers, use the following commands to install the drivers.
$ sudo apt-get purge nvidia*
$ sudo add-apt-repository ppa:graphics-drivers/ppa
$ sudo apt-get update
$ sudo apt-get install nvidia-driver-390 nvidia-settings
$ sudo reboot
Now check $ nvidia-smi. If this works then Nvidia Display Driver was installed correctly. - Navigate https://developer.nvidia.com/cuda-toolkit and download CUDA toolkit 9.0.
- Navigate to the folder where CUDA toolkit was downloaded and open the terminal.
Use following commands to install CUDA.
$ sudo chmod +x cuda_9.0.176_384.81_linux.run
$ ./cuda_9.0.176_384.81_linux.run – – override
‘- -overide’ is used to ignore the gcc compiler check during the installation. - say yes to installing with an unsupported configuration
no to “Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
Yes to cuda install (now complete the whole installation)
Yes to toolkit location
Yes to symbolic link
Yes to cuda samples - Next, head to https://developer.nvidia.com/cudnn to get CUDNN 7.0.5
Download “cuDNN v7.0.5 Library for Linux”.
$ tar -zxvf cudnn-9.0-linux-x64-v7.tgz
$ sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-9.0/lib64/
$ sudo cp cuda/include/cudnn*.h /usr/local/cuda-9.0/include/
$ sudo chmod a+r /usr/local/cuda-9.0/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
- Now finally we need to install LIBCUPTI.
$ sudo apt-get install libcupti-dev - Now open “bashrc” file to add path of Cuda
Add these following lines to the end of bashrc file - export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
- export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
- REBOOT the system
- Finally install Tensorflow-GPU $ pip install –upgrade tensorflow-gpu==1.12.0
this is specifically for CUDA 9.0 and cuDNN 7.0.5
You are good to go now!!
Try running any simple program!
- nvidia-smi -l 1 gives the gpu running update every 1 sec interval
Install version 6 0f gcc as CUDA requires gcc 6.
(installing gcc version 6, and making symbolic link)
$ sudo apt install nvidia-cuda-toolkit gcc-6
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda-9.2/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda-9.2/bin/g++