Hands-On GPU Computing with Python
eBook - ePub

Hands-On GPU Computing with Python

Explore the capabilities of GPUs for solving high performance computational problems

Avimanyu Bandyopadhyay

Share book
  1. 452 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Hands-On GPU Computing with Python

Explore the capabilities of GPUs for solving high performance computational problems

Avimanyu Bandyopadhyay

Book details
Book preview
Table of contents
Citations

About This Book

Explore GPU-enabled programmable environment for machine learning, scientific applications, and gaming using PuCUDA, PyOpenGL, and Anaconda Accelerate

Key Features

  • Understand effective synchronization strategies for faster processing using GPUs
  • Write parallel processing scripts with PyCuda and PyOpenCL
  • Learn to use the CUDA libraries like CuDNN for deep learning on GPUs

Book Description

GPUs are proving to be excellent general purpose-parallel computing solutions for high performance tasks such as deep learning and scientific computing.

This book will be your guide to getting started with GPU computing. It will start with introducing GPU computing and explain the architecture and programming models for GPUs. You will learn, by example, how to perform GPU programming with Python, and you'll look at using integrations such as PyCUDA, PyOpenCL, CuPy and Numba with Anaconda for various tasks such as machine learning and data mining. Going further, you will get to grips with GPU work flows, management, and deployment using modern containerization solutions. Toward the end of the book, you will get familiar with the principles of distributed computing for training machine learning models and enhancing efficiency and performance.

By the end of this book, you will be able to set up a GPU ecosystem for running complex applications and data models that demand great processing capabilities, and be able to efficiently manage memory to compute your application effectively and quickly.

What you will learn

  • Utilize Python libraries and frameworks for GPU acceleration
  • Set up a GPU-enabled programmable machine learning environment on your system with Anaconda
  • Deploy your machine learning system on cloud containers with illustrated examples
  • Explore PyCUDA and PyOpenCL and compare them with platforms such as CUDA, OpenCL and ROCm.
  • Perform data mining tasks with machine learning models on GPUs
  • Extend your knowledge of GPU computing in scientific applications

Who this book is for

Data Scientist, Machine Learning enthusiasts and professionals who wants to get started with GPU computation and perform the complex tasks with low-latency. Intermediate knowledge of Python programming is assumed.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Hands-On GPU Computing with Python an online PDF/ePUB?
Yes, you can access Hands-On GPU Computing with Python by Avimanyu Bandyopadhyay in PDF and/or ePUB format, as well as other popular books in Computer Science & Desktop Applications. We have over one million books available in our catalogue for you to explore.

Information

Year
2019
ISBN
9781789342406
Edition
1

Section 1: Computing with GPUs Introduction, Fundamental Concepts, and Hardware

In this section, you will be introduced to the world of GPUs by looking at the subject from a scientific, an industrial, and also a social perspective.
The following chapters are included in this section:
  • Chapter 1, Introducing GPU Computing
  • Chapter 2, Designing a GPU Computing Strategy
  • Chapter 3, Setting Up a GPU Computing Platform with NVIDIA and AMD

Introducing GPU Computing

Many years ago, I used to think that a graphics processing unit (GPU), more commonly known as a graphics card, was just a device dedicated to playing video games on a computer at their maximum potential. But, one day, while going through a textbook (Advanced Computer Architecture by Kai Hwang), I realized that I was unaware of a world that goes way beyond PC gaming.
Without a doubt, most consumer GPUs are manufactured to achieve those amazing graphics and visuals to enable some spell-binding gameplay. But there's a world that explores its application a whole lot further, and that is the world of GPU computing.
In this chapter, we are going to learn the basic ideas behind GPU computing, a historical recap on computing, and the rise of GPU computing. We will also read about the simplicity of Python and the power of GPUs, and learn about the scope of applying GPUs in science and AI. Summarized research work by scientists working in different fields through GPUs will help you in following the same.
In the final part of this chapter, we will be able to understand the social impact of GPUs by learning about more research work in fields beyond science. By the end of this chapter, you will have developed a general idea about implementing your own GPU-enabled applications, regardless of your field of study.
This chapter is divided into the following sections to facilitate the learning process:
  • The world of GPU computing beyond PC gaming
  • Conventional CPU computing – before the advent of GPUs
  • How the gaming industry made GPU computing affordable for individuals
  • The emergence of full-fledged GPU computing
  • The simplicity of Python code and the power of GPUs – a dual advantage
  • How GPUs empower science and AI in current times
  • The social impact of GPUs

The world of GPU computing beyond PC gaming

If you are a PC gamer, you must be very familiar with the world of graphics cards. Depending on their specifications, you might also be familiar with how each of them would affect your gaming experience. Let's explore extensively what lies beyond that domain through the subsequent sections in this chapter.

What is a GPU?

A GPU, as the initialism suggests, is an electronic circuit that serves as a processor for handling graphical information to output on a display. The scope of this book is to go beyond just handling graphical information and stepping into the general purpose computing with GPUs (GPGPU) arena. GPGPU is all about the use of what is typically performed with central processing units (CPUs), which we are going to discuss in detail in the next section. The terms GPU and graphics card are used interchangeably very frequently. But both are in fact quite different. The graphics card is a platform that serves as an interface to the GPU. Just like a CPU is seated over a motherboard socket, a GPU is seated over a socket on the graphics card (comparably to a motherboard, we may think of it as a mini-motherboard but only to facilitate the GPU and its cooling).
What about computing? The word computing is most obviously derived from the word compute. To compute is simply to harness your own hardware to deploy applications with the help of your own programmable processes. Programmable processes are a set of rules defined by you that are always ready to operate at your disposal. They are, of course, based on your own algorithms, which allow you to address your own specific requirements, depending on the application at hand.
If you look at computing on a universal scale, you'd find that the specific requirement that we speak of in the previous paragraph isn't just limited to computer science. Computing can be inferred as a technique to calculate any measurable entity that can belong to any field, be it the field of science or even art. Now that we have described the terms GPU and computing individually, let's go ahead with an introduction to our primary topic: GPU computing.
As we can comprehend by now, GPU computing is all about the use of a GPGPU with program code that executes on GPUs. When a GPU programmer writes a GPU program, the primary motive is to handover a certain workload that is computationally much more intensive for a CPU to handle.
Within the code, the CPU is instructed to hand over those particular operations to the GPU, which are then computed by the GPU. When these computations are done, the GPU sends back all of this information to the CPU and shows that output to you. Since the results are computed many times faster, such work can also be called GPU-accelerated computing.

Conventional CPU computing – before the advent of GPUs

Before GPUs arrived, general-purpose computing, as we know it, was only possible with CPUs, which were the first mainstream processors manufactured for both consumers as well as advanced computing enthusiasts.
Both computational and graphical processing were handled only by them. This meant that both the tasks of processing and handling computation of input and showing its corresponding computed output on a display were all handled by a CPU.
The history of general-purpose computing goes way back to the 1950s, before GPUs arrived and revolutionized the concept. The 1970s witnessed the rise of a new era, when the first commercial CPU, the Intel 4004, was released by Intel in 1971. The first AMD CPU was also launched in the 70s with the launch of AM2900 in 1975. There was no looking back, and a new cycle of CPU manufacturing came into effect, bringing up a new range of microprocessors for every generation.
Though Intel and AMD are the popular competitors in the CPU sector, there are other manufacturers as well, such as Motorola, IBM, and many others. Qualcomm and MediaTek, in particular, dominate the mobile industry.
Since this book is going to be about GPU computing with Python, let's briefly look back at how CPU computing evolved, before Python had any GPU implementations developed. If we want to learn about the computing power of CPUs, we have to look into how modern CPUs evolved before GPU computing wasn't heard of or deployed.
Since the inception of the third generation of Integrated Circuits (ICs) and microprocessors, the thinking has always been about how much power you can put into a single chip to get the maximum performance out of it. In the early 60s, a chip used to contain just tens of transistors, but that number rose to tens of thousands during the 70s. In the 80s, it became hundreds of thousands, while today's chips contain billions. So, how much power can you put into a single chip to get the maximum performance out of it?
This is why CPUs are evolving continuously. During this time, both Intel and AMD invented new technologies to improve CPU design. Being in the same field, they entered into a 10-year agreement in 1981 to enable mutual technology exchange. Dual core, Core 2 Duo, and many other technologies became popular.
But, eventually, a time arrived when the need for a device to accelerate general-purpose CPU computing was acknowledged. That's when GPGPUs entered the arena and the processing power of general CPUs increased tenfold.

How the gaming industry made GPU computing affordable for individuals

Gaming is over a $100 billion USD industry. But way back in the 1950s, video games were purely made for academic purposes. Video games were a medium to demonstrate the capabilities of a newly invented technology. They were also a good application to test AI applications through tic-tac-toe or chess. But access to such platforms was still limited to computer lab environments.
Spacewar became the first purpose-built computer game in 1962.
By the 1970s, the area of gaming started to change. Arcade gaming became very popular. The PC gaming landscape took proper shape in the 80s with programmable computers in almost every household equipped with popular games such as Super Mario Bros, Donkey Kong, Prince of Persia, and more.
The 90s saw the emergence of legendary games such as Doom and Quake, which radically changed the PC gaming scenario. Many PC enthusiasts and gamers developed an immense interest in understanding the benefit of PC hardware customization. Such options to customize PC hardware grabbed the attention of many to enable smooth gameplay and the best possible visuals at that time.
During this time, the console market also started to hit the roof, which continued through the 00s, with branded hardware shipped as a single unit. Later, many became curious about the specifications of these devices to learn about their full potential, and even today when a new console arrives on the market, it is a very common to debate about the GPU that lies inside the new console.
By 2016, there were over 2 billion gamers, and half of them lived in the Asia-Pacific region. As we can see, the rise of the gaming industry is known to many, and ...

Table of contents