To install TensorFlow with GPU support, the prerequisites are Python 3.5, CUDA 9.0, cuDNN v7.0 and finally a GPU with compute power 3.5 or more. Note that the versions of softwares mentioned are very important. Any deviation may result in unsuccessful installation of TensorFlow with GPU support. In this tutorial, we have used NVIDIA GEFORCE GTX 1060 having a compute power of 6.1.
This version may not be the latest of Python, but you have to install Python 3.5 for TensorFlow to work. Link : [https://www.python.org/downloads/release/python-350/] Under Files section, choose a proper version for your OS bit version and download the executable. Run the exe, choose to add location to PATH in the first step of installation wizard. Continue with the default options. Python 3.5 should be successfully installed.
CUDA 9.0 is not the latest. So you may have to go to Legacy Releases. Link : [https://developer.nvidia.com/cuda-90-download-archive] Select your Operating System and OS Version. Select Installer type as Local. Download Base Installer and all the available Patches. First install the Base using Base Installer and then install the patches in the numeric order (In the order of Patch 1, Patch 2, Patch 3).
First you have to signup for NVIDIA Developer Account. Link : https://developer.nvidia.com/cudnn There would be quick survey. Finish it. Once the signup is successful, you can download cuDNN v7.0 for CUDA 9.0 at [https://developer.nvidia.com/rdp/cudnn-archive#a-collapse705-9]. Also open installation guide present at [https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.0.5/prod/Doc/cuDNN-Installation-Guide]. Follow the steps under Windows section. It would be mostly a copying files to the respective installation directory of NVIDIA GPU Computing Toolkit.
Install TensorFlow for GPU.
Once all the above three prerequisites are installed successfully, now the final step in the installations is to install TensorFlow itself. There are two ways to install TensorFlow for GPU. You can use either Anaconda IDE or pip (which is already with python). We shall go with pip. Open command prompt and run the following command.pip3 install --upgrade tensorflow-gpu
Verify TensorFlow Installation
The final step in setting up TensorFlow for GPU is verification. To verify if the installation is successful, open python shell and run the following python instructions one by one.import tensorflow as tfhello = tf.constant('Hello, TensorFlow!')sess = tf.Session()print(sess.run(hello))
Observe in the debug lines of creating a tensorflow session, TensorFlow device has been created which is physical GPU (GeForce GTX 1060).
In this Deep Learning Tutorial, we have gone through the steps to install all the prerequisites of and TensorFlow for GPU.