Install TensorFlow-GPU + CUDA in Windows 10, with easy to follow instructions.

Nitin
Analytics Vidhya
Published in
5 min readAug 8, 2020

Installing CUDA and TensorFlow-GPU can be a very challenging task, in this article I will show to install it in a few simple steps.

Before getting started with this installation we need to make sure that your graphics card is CUDA enabled. If it is not then using GOOGLE COLLAB can be a great alternative.Check if your Graphics card is CUDA enabled(link), scroll down and click on CUDA enabled Ge-force and Titan Products. Search for your graphics card from the list.

If you don’t know your graphics card specs:

  1. Go to Desktop
  2. Right Click and Select NVIDIA Control Panel
  3. Click Help and Select System Information from the drop down
  4. Under Items you can view your graphics card version.

Check the latest version of CUDA supported by TensorFlow. Click on this link. Scroll down to Software Requirements to check for the latest supported build.

Here CUDA 10.1 and cuDNN SDK 7.6 are the latest supported version by TensorFlow, you can ignore the rest of the things for now.

Okay now that we know what we have to install we first need to clean our system of any NVIDIA programs. That means removing all installation of NVIDIA from our system.

  1. Go to My Computer/C Drive/Program Files and remove all files having the name NVIDIA.

2. Again Go to My Computer/C Drive/Program Files(x86) and do the same thing remove all files having the name NVIDIA.

After removing all the files from your System perform a reboot.

Now Lets Download all the required software

  1. The First thing we need to download is Visual Studio, as it is a prerequisite for CUDA installation and without this our installation will fail. Go to this link and download the latest Visual Studio Community Edition. Just follow the default installation settings until you reach Step 4(Choosing Workloads) don’t select any workload and just click on Install.
  2. Next we need to download CUDA Toolkit(link). Recall the CUDA Toolkit Version from the TensorFlow Software Requirements(the latest supported build during the time of writing this article is 10.1, but if any new supported build is mentioned on the TensorFlow website go ahead and select it).

Select your Operating System( I have selected mine as Windows)

Select the latest version(I have selected 10)

Select the Installer type exe(local)

My download file is ready and its a single file of 2.4 GB. I want take time to mention that if there are patches available for your spec in the future, download all the patches and install them in a consecutive manner after the installation of the main toolkit.

3. Install The CUDA Toolkit and select all the default options during installation.

4. Now we have to download cuDNN zip file from NVIDIA(link). Click on cuDNN download.

5. You will have to register and login with NVIDIA and also complete a small survey before being able to download the zip file.

6. At the end you will land up at this page. Our CUDA toolkit version is 10.1 so we will download the SDK version for CUDA 10.1(You have to download the same version as your CUDA toolkit).

7. Unzip the zip file and you will see three folders inside it bin, include and lib\x64

8. Go to your CUDA toolkit installation directory located at My Computer\C Drive\Program Files\Nvidia GPU Computing Toolkit\CUDA\v 10.1

9. You will find bin, include and lib\x64 in this directory. All we have to do is copy the dll files from the zip file directory to the CUDA installation directory.

10. Copy the cudnn64_7.dll from Zip file to the CUDA installation directory bin file.

11. Copy the cudnn.h from the zip file to the CUDA installation directory bin file.

12. Copy the cudnn.lib from the zip file(lib\x64) to the CUDA installation directory (lib\x64).

13. Open Control Panel — -> System — -> Advance System Settings — ->Environment Variables

If you see these two paths in the environment System Variables then CUDA has been successfully installed in your system.

  1. Install Python(link)
  2. Install Pip(link)

— — -Click on get-pip.py

— — -Right Click and Select Save as

— — -Save the file on your desktop(Move it to any preferred location)

3.Install Anaconda Community Package(link)

Now that we have installed CUDA, Python, Pip and Anaconda. Our final step is to download and install tensorflow-gpu. It is always advised to install TensorFlow in a different environment from the base environment.

  1. Open Anaconda Navigator and create a new environment with Python 3.6

2. After creating a new environment, open Anaconda prompt and change from the base environment to the new environment using conda activate any_Name

3. Install TensorFlow GPU using pip command, pip install --upgrade tensorflow-gpu

4. Check if TensorFlow GPU has been installed successfully on your system.

# importing the tensorflow package
import tensorflow as tf
tf.test.is_built_with_cuda()tf.test.is_gpu_available(cuda_only=False, min_cuda_compute_capability=None)

Following all these steps we have successfully installed tensorflow-gpu and CUDA on Windows 10 System. I have been using TensorFlow GPU for my projects and have noticed a significant decrease in time as compared to CPU. However in terms of results there are some scenarios where CPU perform better than GPU, I will be writing more about this in my future stories. I have tried to keep this article simple so that you can follow along easily while performing the installation.

--

--