Install TensorFlow with GPU support in Machine Learning
Hello learners, today in this tutorial we will learn about installing the TensorFlow deep learning Python library with GPU support. To do so you must first have the latest version of the Visual Studio being installed on your system.
Also, make sure that you have the latest GPU drivers are installed on your PC. After you have all of this let’s get started with the main work.
Installing TensorFlow with GPU support
Note that for this particular tutorial I will be taking the example of an Nvidia graphics card.
Installing CUDA Toolkit
The very first step is to install the latest available version of CUDA on the system. As of now, the latest version out is 10.2, but if you find the more latest version of the CUDA toolkit please go ahead with installing that version. Just make sure that your GPU supports this version.
To install the CUDA version please follow the link here. Download the version according to your OS type, OS version, system specification. After the download is complete now you shall extract and install the package. The standard toolkit installation provides accelerated libraries, development tools, sample codes, and the compiler. After the successful installation of the toolkit go to the CUDA samples folder created under the NVIDIA Corporation folder inside the C Drive. Try running a sample code to verify your installation.
Installing cuDNN files
The step is to install the cuDNN files on to your system. The latest version of this is the 7.6 release. Please do make sure that you have the developer’s login. To do so go the website link given here. Now once you have the developer’s login you shall now install the cuDNN version as the CUDA version you have installed in the previous step. The link to the cuDNN Archive as per the CUDA version is given here. Download the version which suits your specifications and then extract the package. Take the extracted files from where you have extracted them and paste them into a folder named CUDA in a folder named NVIDIA GPU Computing Toolkit present in your C Drive.
The next important step is to set the path to the environment variables. To do so fo into your environment variable, scroll down under the System variables, and look for ‘PATH’. Under this paste, the complete path of the ‘bin’, ‘include’, and the ‘lib\x64’ path onto this as shown below:
The next step is to install Anaconda on your system. Download the Anaconda version as per your python version, and the OS you use. Use the link here to download Anaconda.
Complete the Anaconda installation and when the installation is successfully completed the next step is to create an Anaconda environment. This can be done by using the command prompt or the Anaconda prompt.
To create an environment.
conda create -n tensorflow python=3.8
Now you shall activate the environment created, to do so use the following command.
Installing TensorFlow GPU and Keras
Now it is time to install the TensorFlow GPU, and this can be done by the following command or anaconda prompt.
pip install --ignore-installed --upgrade tensorflow-gpu
Note that if you are not using the latest version of CUDA then install the TensorFlow GPU version accordingly, because the above command installing the latest available version.
Now we can go ahead with the installation of Keras, for this use the following command in the same prompt window.
pip install keras
I hope you all will have now installed the TensorFlow GPU on your system. I hope you will use this TensorFlow GPU well in your further machine learning models. Have a good day and happy learning.