Installing TensorFlow on Windows 10

It has been quite a while since I last wrote about machine learning. During the first week after spring break, I finally got a chance to take a closer look at TensorFlow, a software library designed for machine learning applications by Google. It was originally used by the Google Brain team and was later made open-source to the public. In this week’s blog post, I will discuss the installation of TensorFlow on PCs.

Why Windows?
If you have been an avid reader of my blog, you’d know that I am a hardcore Apple fan. So, why Windows? I recently gained access to a PC that is equipped with Nvidia’s GTX 1050 Ti Graphics Processing Unit (GPU). Machine learning, especially deep neural networks, can be accelerated with GPUs because these processing units specialize in matrix computations. TensorFlow supports CUDA, Nvidia’s parallel computing platform that leverages the computing power of its GPUs. Compared to the Nvidia GT 750M that shipped with my 2014 MacBook Pro, the 1050 Ti is at least 3x faster. Therefore, I made the decision to go with the Windows machine, which has proven to be painfully hard to configure.

Step 1: Install Python
TensorFlow is written in the Python programming language. Therefore, it is natural for Python to be a dependency of TensorFlow. Installing the Python environment on Windows turns out to be quite simple if you are using the graphical installer. For our purpose, make sure you install verison 3.5.2 through this link: https://www.python.org/downloads/release/python-352/. Click on the “Windows x86-64 executable installer” as seen in the following screenshot to download the GUI installer:

Untitled.png

Double click on the file you downloaded. Before clicking on “Install Now”, check the checkbox with the description “Add Python 3.5 to PATH” to save you the trouble of doing this after installation.

win_installer[2].png

It is important to note that the latest TensorFlow, API r1.7, only supports Python 3.5.x and 3.6.x. In addition, I discovered that TensorFlow is not compatible with the 32-bit machines as the library only supports 64-bit systems. So, be sure to choose the 64-bit (x86-64) version of Python.

Step 2: GPU Acceleration & CUDA (optional)

The second step is completely optional if you’d use a CPU rather than a GPU to perform machine learning training. Though, if you do have a GPU in your system that is also listed on NVIDIA’s CUDA-enabled GPU list, you should consider doing this step as GPU acceleration can give you a significant performance boost in training your model.

Before installing the GPU Acclerated version of TensorFlow, there are two things you need to do. After you’ve confirmed that your GPU supports CUDA, go to Nvidia’s website and download the CUDA Tookit 9.0. At the time of writing the latest CUDA Toolkit is version 9.1. However, you will have to download the 9.0 anyway because TensorFlow does not yet support the latest CUDA Toolkit. Install the toolkit once you have finished downloading.

Untitled2.png

Secondly, install the cuDNN (CUDA Deep Neural Network) library. To install, simply download the zipped library from Nvidia’s developer website. The library is completely free, but you will need to sign up for an Nvidia developer account to download it if you do not already have one. Notice that there are different versions of the cuDNN library available. It is important to have the library match the version number of the CUDA you just installed. For our purpose, select cuDNN v7.0.5 for CUDA 9.0.

Untitled3.png

The tricky part is the actual installation of cuDNN because documentation is rather confusing. Go to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0 and you will see a couple of folders and files. Unzip the cuDNN package you downloaded. You will realize that a few of the folders you saw under the CUDA directory are also present in the cuDNN directory. Essentially, copy all the files from the folders under cuDNN directory to the folders in the CUDA directory with the same name. For example, copy “cudnn64_7.dll” under “bin” in cuDNN to the “bin” folder under CUDA. Once you are done with copying, you have completed the installation of cuDNN.

Thanks for reading! In next week’s blog post, I will continue this tutorial with the actual installation of TensorFlow and touch on the two different methods of installing the library.

Works Cited

Installing TensorFlow on Windows  Contents. Google, 9 Mar. 2018, http://www.tensorflow.org/install/install_windows. Accessed 1 Apr. 2018.

NVIDIA. “CUDA Installation Guide for Microsoft Windows.” Nvidia Developer Zone, Nvidia, 5 Mar. 2018, docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/. Accessed 1 Apr. 2018.

—. “cuDNN Download.” Nvidia, 21 Mar. 2018, developer.nvidia.com/rdp/cudnn-download. Accessed 1 Apr. 2018.

Python Software Foundation. “Python 3.5.4.” Python, Python Software Foundation, 8 Aug. 2017, http://www.python.org/downloads/release/python-354/. Accessed 1 Apr. 2018.

TensorFlow. TensorFlow. Wikimedia Commons, en.wikipedia.org/wiki/TensorFlow#/media/File:TensorFlowLogo.svg. Accessed 1 Apr. 2018.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.