Tensorflow on Windows 10 with GPU support – Part 2

This is the second part of a three part series on installing and configuring Tensorflow on Windows 10 with GPU.

If you have not done so, take a look at part 1 and double check that you have the required components. Part 1

Install NVIDIA CUDA Toolkit

Now you are ready to install the CUDA toolkit. Go to the NVIDIA website and download the CUDA toolkit.

Select the your OS and download the toolkit.

Next, navigate to the download location and double click on the .exe file. You should see the installer window leave the default Temp folder, this will be deleted when the installer is done.

NVIDIA Installer

Click Ok. And you should see the progress bar window.

Extraction Progress Bar

When the CUDA setup is complete, you will get the installer wizard. Read the EULA and click on Agree and Continue.

License Agreement

Next, we select the express installation option. Express and Click Next.

Installation Option

Remember in Part 1 that we needed to install Visual Studio 2019? If you missed that step, here’s the error message that you will see.

Error Code

The next window “Preparing for Installation”.

Preparing Installation

NSight installation summary.

NSight Installation

Installation is complete….

Installation Summary

I chose not to run the examples, but if you have time I recommend running a couple. On our next post, we will install cuDNN.

Tensorflow on Windows 10 with GPU Support – Part 1

This is the first part of a three part series on installing and configuring Tensorflow with Keras on Windows 10. We will also enable GPU support.

First, we need to install the Microsoft Visual Studio Toolkit. Then, we install the NVIDIA CUDA Toolkit. Finally, we install the NVIDIA cuDNN. Also, we need python 3.x installed and your favorite python IDE (PyCharm). Let’s jump right in and get started.

Installing Microsoft Visual Studio CE

Click on the link below to download Visual studio. Then follow the instructions on installing the software.

Download Visual Studio 2019 for Windows & Mac (microsoft.com)

Navigate to the directory containing the .exe file and double click to get the installer window.

The initial installation window asks you to select which components to install.  Select the C++ option and any others that interests you.  I use Visual Studio Code for everything except Python, so my install was light weight.

The installer progress bar…

Once the installation is complete, you will get a window to login to Microsoft.

Sign in, select the theme that you like and click on the Start visual studio button.

Congratulations, you have completed the first of three posts.

Q&A

Why do I have install Visual Studio 2019? NVIDIA CUDA Toolkit requires Visual Studio. If you have another version of Visual Studio the CUDA installer should not throw an error.

Ubuntu 17.10 & NVIDIA Driver Support

Good news everyone!  Ubuntu 17.10 provides support for the NVIDIA Drivers out of the box.  I was not able to get the latest driver, 390.25 with CUDA Toolkit version 9.1 to work properly on my Notebook (Lenovo W541).  However, I was able to get a previous version of the  NVIDIA driver version 384.111 with Cuda 9.0 on Ubuntu 17.10 working!

Install the NVIDIA Driver

My PC –  Lenovo W541, 32 GB RAM, CORE i7 processor and NVIDIA Quadro K1100M.  The trick is to get the driver and cuda toolkit versions to work together.  This blog provides insight into what the setup constitutes.

  1. Determine the type of NVIDIA Graphics cards that your notebook/pc has.
    • execute the following command: > lspci | grep VGA.  You should see your NVIDIA Graphics card model. lspci_vga.png
  2. Start the Ubuntu “Software and Updates” application.  Then, click on the “Additional Drivers Tab”.  Give it a several seconds to load.Software_Updates.png
  3. Select the NVIDIA binary driver – version 384.11 (proprietary).  This, step will take sometime.
  4. Once the install is complete, reboot your machine.
  5. Check that the driver was installed by running the following command.
    • :>nvidia-smi nvidia-smi.png

On the top of the image you can see the version of the NVIDIA Driver, 384.111.  Also, you can see the processes that are using the NVIDIA driver.

Installing the CUDA Toolkit 9.0

CUDA 9.0 toolkit needs GCC version 6.  By default Ubuntu 17.10 comes with GCC version 7.  Not to worry, update-alternatives comes in to save the day.

Install GCC version 6 and update alternatives.

  1. sudo apt install gcc-6
  2. sudo apt install g++-6
  3. sudo update-alternatives –install /usr/bin/gcc gcc /usr/bin/gcc-6 10
  4. sudo update-alternatives –install /usr/bin/g++ g++ /usr/bin/g++-6 10

Download the CUDA toolkit from the NVIDIA site.

:>wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run

Make the download executable and run it as sudo.

:>chmod +x cuda_9.0.176_384.81_linux-run

:>sudo ./cuda_9.0.176_384.81_linux-run –override

The installer will complain about an unsupported installation.  It’s ok – follow these steps.

CUDA Installer Q&A

You are attempting to install on an unsupported configuration. Do you wish to continue?
y
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 387.xx?
n
Install the CUDA 9.0 Toolkit?
y
Enter Toolkit Location
[default location]
Do you want to install a symbolic link at /usr/local/cuda?
y
Install the CUDA 9.0 Samples?
y
Enter CUDA Samples Location
[default location]

Check your installation by running the following command:>nvcc -V

nvcc.png

If you see the CUDA compiler driver, you did it!

Congratulations! You have installed the CUDA Toolkit.  Now let’s move on to the CUDA Configuration section of this blog.

CUDA Configuration

The CUDA toolkit provides plenty of samples to build and test the NVIDIA GPU.  Now that you install the driver, make sure to set the PATH with the cuda binaries.

open your ~/.bashrc file and add the following line at the end of the file:

export PATH=$PATH:/usr/local/cuda-9.0/bin

Next, you need to add the CUDA libraries to your environment.  This step saves you time when compiling CUDA samples or code. You don’t have to set the LD_LIBRARY_PATH.

  1. sudo vi /etc/ld.so.conf.d/cuda.conf
  2. add the following to the top of the file:/usr/local/cuda-9.0/lib64
  3. save the file and quit vi
  4. sudo ldconfig

In theory, you are ready to run the CUDA samples.  However, I found that in order to run the Simulations, that you need to install the following dependencies.

sudo apt install libeigen3-dev libopencv-dev libceres-dev libcgal-dev libboost-dev freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev libglfw3-dev libgles2-mesa-dev

Now you are ready to run the samples!

Running CUDA Samples

Before running the samples, you need to pass the Gencode arguments to the compiler.  Here’s a great blog to help you figure out which Gencode arguments to pass to the compiler.

Navigate to the ~/NVIDIA_CUDA-9.0_Samples directory.  There are 8 directories that contain NVIDIA CUDA Samples (0-7).

Go into the following directory:> cd ./CUDALibraries/cuSolverDn_LinearSolver 

Open the Makefile.

Search for “SM”.  You should see the following.

gencode.png

You don’t need all the codes, just the one that applies to your NVIDIA Graphics card.  In my case, I don’t see the Quadro K series, so I used gencodes 50 & 52.

Once you are done with the Gencode Arguments, save the file and exit the editor.

From the command line:

  1. make TARGET_ARCH=x86_64
  2. run the program: $ ./cuSolverDn_LinearSolver

final.png

Try running the smoke particles example in the directory 5_Simulations.