This is going to be a tutorial on how to install tensorflow 1.7.0 GPU version. We will also be installing CUDA Toolkit 9.1 and cuDNN 7.1.2 along with the GPU version of tensorflow 1.7.0. At the time of writing this blog post, the latest version of tensorflow is 1.7.0.This tutorial is for building tensorflow from source. If you want to use the official pre-built pip package instead, I recommend another post, How to install Tensorflow 1.7.0 using official pip package.
Tensorflow is an open source software library developed and used by Google that is fairly common among students, researchers, and developers for deep learning applications such as neural networks. It has both the CPU as well as GPU version available and although the CPU version works quite well, realistically, if you are going for deep learning, you will need GPU. In order to use the GPU version of TensorFlow, you will need an NVIDIA GPU with a compute capability > 3.0. While it is technically possible to install tensorflow GPU version in a virtual machine, you cannot access the full power of your GPU via a virtual machine. So, I recommend doing a fresh install of Ubuntu if you don’t have Ubuntu before starting with the tutorial.
There must be 64-bit python installed tensorflow does not work on 32-bit python installation.
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
Note GPU model. eg. GeForce 840M
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.
If your graphics card is from NVIDIA then goto http://developer.nvidia.com/cuda-gpus and verify if listed in CUDA enabled gpu list.
Note down its Compute Capability. eg. GeForce 840M 5.0
Step 3: Verify You Have a Supported Version of Linux:
To determine which distribution and release number you’re running, type the following at 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 9.1
Step 4: Install Dependencies:
Required to compile from source:
sudo apt-get install build-essential sudo apt-get install cmake git unzip zip sudo apt-get install python2.7-dev python3.5-dev python3.6-dev pylint
Step 5: Install linux kernel header:
Goto terminal and type:
You can get like “4.10.0-42-generic”. Note down linux kernel version.
To install linux header supported by your linux kernel do following:
sudo apt-get install linux-headers-$(uname -r)
Step 6: Download the NVIDIA CUDA Toolkit:
Go to https://developer.nvidia.com/cuda-downloads and download Installer for Linux Ubuntu 16.04 x86_64 deb[network]. I highly recommend network installer to get updated gpu driver supported by your linux kernel.
For, direct download
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub sudo dpkg -i cuda-repo-ubuntu1604_9.1.85-1_amd64.deb sudo apt-get update sudo apt-get install cuda-9.1