Setting up your Nvidia GPU for Deep Learning
This article aims to help anyone who wants to set up their windows machine for deep learning. Although setting up your GPU for deep learning is slightly complex the performance gain is well worth it * . The steps I have taken taken to get my RTX 2060 ready for deep learning is explained in detail. Software installation covered in this article include Cuda ,cuDNN ,Anaconda ,Visual Studio C++ and Tensorflow.
Files to download
The first step when you search for the files to download is to look at what version of Cuda Tensorflow, supports which can be checked here, at the time of writing this article it supports Cuda 10.1.To download cuDNN you will have to register as an Nvidia developer. I have provided the download links to all the software to be installed below.
- Anaconda
- Visual Studio Community Edition 2019
- Cuda(Find the version supported by Tensorflow)
- cuDNN(Download according to your Cuda version)
For this installation Anaconda 2020.07, Visual studio 16.7.6, Cuda 10.1(update 2), cuDNN 8.0.4, TensorFlow 2.3.1 were used
Anaconda
Anaconda is a free and open-source distribution of the Python and R programming languages for scientific computing, that aims to simplify package management and deployment.
- Double click the installer to launch.
2. Click Next.
3. Read the licensing terms and click “I Agree”.
4. Select an install for “Just Me” and click Next.
5. Select a destination folder to install Anaconda and click the Next button
6. Do not add Anaconda to your PATH environment variable when asked in the checkbox
7. After a successful installation you will see the “Thanks for installing Anaconda” dialog box
8. Verify your Install
Visual Studio Community Edition 2019
The core of NVIDIA TensorRT is a C++ library that facilitates high-performance inference on NVIDIA graphics processing units. This is why we must install the necessary C++ libraries using Visual Studio.
- Double click the installer to launch.
- Click continue and it will download a few files
- Scroll and select desktop environment with C++
4. Check the components shown in the image above
5.Click on Install to complete the installation
Cuda
CUDA is a parallel computing platform and application programming interface model created by Nvidia.
- Double click the installer and click on extract to extract the necessary files to a temporary location
- The System check will complete automatically
- Accept the License Agreement
- Install using the default Express option which is recommended
- The installer will finish after a while
cuDNN
cuDNN is a GPU-accelerated library for deep neural networks. cuDNN provides highly tuned implementations for standard routines such as forward and backward convolution, pooling, normalization, and activation layers.
- Extract the zip files from archive downloaded
- Copy the folders “bin”, ”include”, “lib”
- Paste the copied folders into:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1
4.Run the following commands one by one (in an elevated command prompt) to add the necessary files to Path
1) setx path “%PATH%;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin”
2) setx path “%PATH%;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\CUPTI\lib64”
3) setx path “%PATH%;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include”
4) setx path “%PATH%;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp”
TensorFlow
Tensorflow is a comprehensive set of libraries that helps in training and testing deep learning models.
Do not directly use Anaconda without specifying the version to install TensorFlow as the Anaconda installer will only install TensorFlow 1.14 and you will get a version not supported error, Instead downgrade python to python 3.7 and run the following commands to install Tensorflow 2.1.0
conda install python=3.7conda update --allconda install -c anaconda tensorflow-gpu=2.1
Verify your Installation
To test if all you have done till now works create a python file with Spyder and run this code.
That’s it your deep learning machine is ready to do what you command :)