Skip to content

[Deep Learning] Build The Tensorflow, CUDA And cuDNN Environment on Windows

Last Updated on 2021-08-30 by Clay

Building a deep learning environment is not an easy task, especially the combination of Nvidia GPU and Tensorflow. The version problems and the driver, CUDA and cuDNN that need to be installed are enough to cause headaches. Moreover, the mainstream operating system is Linux instead of Windows, and it can be found that there are obvious tutorial article.

Because of the chance, I have the need to build a deep learning environment on Windows. Since I used to install on Linux, I am relatively unfamiliar with Windows. In fact, follow the step by step and I have the Linux experience of installing Linux in the past, it actually succeeded very smoothly in one go.

The steps to build a deep learning environment are as follows, and this article is also recorded accordingly:

  • Install Python 3.6.8 (or any version you want)
  • Install Python virtualenv package (optional)
  • Install tensorflow 1.13.1
  • Install CUDA 10.0
  • Install cuDNN 7.6.4

Among them, for the compatibility between Python, Tensorflow, CUDA, cuDNN and other versions, you can refer to a classic table provided by someone on stackoverflow:

If there are installation requirements for different versions, you can refer to it.


Install Python 3.6.8

Installation of Python is easy, you just need to search it on the Internet, and the first result will be the download source of official website:


Scroll down until you find Window x86-64 executable installer, download and execution.


Here is a small detail: it is best to check Add Python 3.6 to PATH and then select Install Now.


After installation, open Windows Terminal or CMD, keyin:

python


And you will see the following screen:

If you can see the interactive command line of Python 3.6.8, the installation is successful.


(Optional) Install Python virtualenv package

You can choose to install virtualenv package or not. This virtualenv package can help us to build the virtual project environment, the packages installed in there that is outside by real system.

In short, it is recommended to install it, but if you have a good idea about the package you manage, then there will probably be no problem.

pip install virtualenv


After installation, suppose we want to turn the test folder into a virtual environment, we can use the following command (used in the terminal):

virtualenv.exe test
cd test\Scripts\
.\activate.bat


If in the terminal, (test) appears at the very beginning, it means that you are already in the virtual environment of Python. You can use the following command to check:

pip list

There should be only three packages, pip, setuptools, and wheel, in this environment.


Install CUDA 10.0

If you want to use tensorflow, CUDA is a library you must to install. Simply put, CUDA is a framework dedicated to parallel computing by Nvidia, and cuDNN (CUDA Deep Neural Network Library), which will be mentioned later, is its deep learning library.

The download location of CUDA can be found here: https://developer.nvidia.com/cuda-toolkit


If the version you need is different with me, you can search the CUDA and the version directly.

Go to the download page, select the configuration according to your machine’s requirements, then download, and follow the command to complete the next steps.


In here, the steps of Windows are very simple, just execute the downloaded executable file directly.

Select address to install
Start to install
Agree and Continous
The first option and NEXT
AGREEN & NEXT
NEXT
you can uncheck them

Then we need to install cuDNN.


Install cuDNN 7.6.4

The following is divided into two parts:

  • Install cuDNN and configurate to CUDA folder
  • Configurate Environment Variable (bin folder)


Install cuDNN and configurate to CUDA folder

If you want to install cuDNN and go to the following website: https://developer.nvidia.com/cudnn


Then, you have to join Nvidia’s developer program to continue. Register here! It may be used frequently in the future, at least if you want to download a different version, you must always use it!


Then, I found the version I needed. Here I directly chose cuDNN Library for Windows 10.

After the download is over, unzip and copy the cudnn64_7 file under cuda\bin\ to the bin folder in the CUDA installation path. My personal path is C:\Program Files\NVIDA GPU Computing Toolkit\CUDA\v10.0.

This step is very important. It is an important step in whether the GPU can use the cuDNN library. Next, in order for the program to run smoothly, environment variables need to be set in the bin folder in CUDA.

It’s not the cuda folder that cuDNN unzipped, but the copy of the file in the past C:\Program Files\NVIDA GPU Computing Toolkit\CUDA\v10.0\bin.


Configurate Environment Variable

First, search “environment variable”.


Go to “Advanced“, Select “Environment Variable(N)“.


Edit “User Variables“.


Select add and fill in the path of C:\Program Files\NVIDA GPU Computing Toolkit\CUDA\v10.0\bin.

Your path may be different from mine, so remember to fill in your own path.

In this way, the configuration is basically complete.


Install Tensorflow 1.13.1

Open Terminal, let’s test whether tensorflow can use GPU.

Use the following command to install version:

pip install tensorflow-gpu==1.13.1


Then enter the Python command line.

python


Enter the following command:

>>> import tensorflow as tf
>>> tf.test.is_gpu_available()

If the returned result is True, it means that the environment has been successfully configured. Congratulations! Of course, it is better if you have a testable program at hand.


References


Read More

Leave a ReplyCancel reply

Exit mobile version