Getting Started with PyCUDA

In the last chapter, we set up our programming environment. Now, with our drivers and compilers firmly in place, we will begin the actual GPU programming! We will start by learning how to use PyCUDA for some basic and fundamental operations. We will first see how to query our GPU—that is, we will start by writing a small Python program that will tell us what the characteristics of our GPU are, such as the core count, architecture, and memory. We will then spend some time getting acquainted with how to transfer memory between Python and the GPU with PyCUDA's gpuarray class and how to use this class for basic computations. The remainder of this chapter will be spent showing how to write some basic functions (which we will refer to as CUDA Kernels) that we can directly launch onto the GPU.

The learning outcomes for this chapter are as follows:

  • Determining GPU characteristics, such as memory capacity or core count, using PyCUDA
  • Understanding the difference between host (CPU) and device (GPU) memory and how to use PyCUDA's gpuarray class to transfer data between the host and device
  • How to do basic calculations using only gpuarray objects
  • How to perform basic element-wise operations on the GPU with the PyCUDA ElementwiseKernel function
  • Understanding the functional programming concept of reduce/scan operations and how to make a basic reduction or scan CUDA kernel

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.45.5