Book Image

Learn CUDA Programming

By : Jaegeun Han, Bharatkumar Sharma
Book Image

Learn CUDA Programming

By: Jaegeun Han, Bharatkumar Sharma

Overview of this book

<p>Compute Unified Device Architecture (CUDA) is NVIDIA's GPU computing platform and application programming interface. It's designed to work with programming languages such as C, C++, and Python. With CUDA, you can leverage a GPU's parallel computing power for a range of high-performance computing applications in the fields of science, healthcare, and deep learning. </p><p> </p><p>Learn CUDA Programming will help you learn GPU parallel programming and understand its modern applications. In this book, you'll discover CUDA programming approaches for modern GPU architectures. You'll not only be guided through GPU features, tools, and APIs, you'll also learn how to analyze performance with sample parallel programming algorithms. This book will help you optimize the performance of your apps by giving insights into CUDA programming platforms with various libraries, compiler directives (OpenACC), and other languages. As you progress, you'll learn how additional computing power can be generated using multiple GPUs in a box or in multiple boxes. Finally, you'll explore how CUDA accelerates deep learning algorithms, including convolutional neural networks (CNNs) and recurrent neural networks (RNNs). </p><p> </p><p>By the end of this CUDA book, you'll be equipped with the skills you need to integrate the power of GPU computing in your applications.</p>
Table of Contents (18 chapters)
Title Page
Dedication

WDDM/TCC mode in Windows

On the Windows platform, the NVIDIA GPU has two modes: WDDM and TCC. WDDM is the graphics driver for video cards so that it can render desktops and applications. If the installed GPU is only used for computing, display rendering is useless overhead. In this situation, the NVIDIA GPU can switch to a mode that only focuses on computing. This mode is known as TCC mode.

WDDM allows the NVIDIA GPU to cooperate with Windows' WDDM driver, which serves displays. Supporting WDDM mode is a requirement for Windows graphics. On the other hand, TCC mode only works toward computing. Depending on your GPU products and configuration, the GPU's mode can be changed.

Operation mode follows four NVIDIA product classes, and its default mode can vary, as follows:

  • GeForce: WDDM mode only.
  • Quadro/Titan: WDDM mode by default, but can be used in TCC mode too.
  • Tesla: Typically defaults to TCC mode.
  • Tegra: Supports Linux only. No WDDM/TCC issues.

WDDM mode supports CUDA operations and debugging CUDA applications with Nsight, while also supporting the display. As a single host machine, you can do everything that the GPU can. However, TCC mode disables graphics on the graphics driver and enables GPU as a computing accelerator. In other words, this should be used when the graphics card does not have to serve displays. 

TCC mode has some benefits over WDDM mode in CUDA processing, as follows:

  • Serves large-scale computing
  • Ignores Windows' display timeout interval (typically two seconds) to enable kernel operations that are longer than two seconds
  • Reduces CUDA's kernel launch overhead on Windows
  • Supports CUDA processing with Windows remote desktop service
  • Enables the use of NVIDIA GPUs with non-NVIDIA integrated graphics so that you can save global memory

Therefore, TCC mode brings optimal configuration for GPUs as accelerators if they do not serve displays.

Setting TCC/WDDM mode

To change TCC or WDDM mode, use the nvidia-smi utility, as follows:

$ sudo nvidia-smi -dm {0|1}

0 means WDDM mode, and 1 means TCC mode.

If you want to set TCC mode for the selected GPUs, use the -g option to specify target GPUs:

$ nvidia-smi -g {GPU_ID} -dm {0|1}

This option is useful when you want to separate the purpose of GPU use for display and compute. After you've applied these settings, you may want to reboot your machine to apply these changes.

We can identify that TCC mode is enabled by using nvidia-smi. The following screenshot shows GPU operation mode in TCC:

By looking at the right-hand side of the GPU name in the first column, we can confirm that TCC mode is enabled.