Reader small image

You're reading from  Hands-On GPU Computing with Python

Product typeBook
Published inMay 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781789341072
Edition1st Edition
Languages
Right arrow
Author (1)
Avimanyu Bandyopadhyay
Avimanyu Bandyopadhyay
author image
Avimanyu Bandyopadhyay

Avimanyu Bandyopadhyay is currently pursuing a PhD degree in Bioinformatics based on applied GPU computing in Computational Biology at Heritage Institute of Technology, Kolkata, India. Since 2014, he developed a keen interest in GPU computing, and used CUDA for his master's thesis. He has experience as a systems administrator as well, particularly on the Linux platform. Avimanyu is also a scientific writer, technology communicator, and a passionate gamer. He has published technical writing on open source computing and has actively participated in NVIDIA's GPU computing conferences since 2016. A big-time Linux fan, he strongly believes in the significance of Linux and an open source approach in scientific research. Deep learning with GPUs is his new passion!
Read more about Avimanyu Bandyopadhyay

Right arrow

Preface

This book aims to be your guide to getting started with GPU computing. It will start by introducing GPU computing and explaining the architecture and programming models for GPUs. You will also be briefed about the minimum system requirements to get ready for some hands-on experience with GPU computing.

You will learn to how to set up an IDE and learn GPU programming with Python, along with its integrations, including PyCUDA, PyOpenCL, and Anaconda, for performing machine learning for data mining tasks. You will also learn how to port NVIDIA CUDA code to AMD ROCm HIP code that has been tested on the all-new AMD Radeon VII GPU with Linux!

Going further, the book will explain GPU workflows, management, and deployment. You will learn how to use the Anaconda platform to conveniently enhance your existing CPU-based applications with GPU code through CuPy and Numba. Steps to set up container platforms, such as Docker and Kubernetes, have been included. You will also learn to deploy your GPU code on Google Colaboratory (featuring a free-to-use AI inference accelerator – the NVIDIA Tesla T4!) and introduce AI principles to your normal GPU workflow.

During the course of the book, you will learn the principles behind GPU-supported machine learning platforms, such as TensorFlow and PyTorch, to help you bring efficiency and performance to your AI applications.

Toward the end of the book, you will learn about efficiently deploying GPU-supported deep learning libraries by setting up and using the Python-based DeepChem scientific library as a hands-on example in medicinal drug design. To enable easier understanding, a comprehensive illustration of various scientific concepts for DeepChem has been included.

Who this book is for

This book is aimed at data scientists, machine learning enthusiasts and professionals, application scientists, and computer science students who want to get started with GPU computation and perform complex tasks with low latency. Intermediate knowledge of Python and basic knowledge of C/C++ programming is assumed.

What this book covers

Chapter 1, Introduction to GPU Computing, covers the diverse impact of GPUs beyond the gaming industry. Conventional CPU models and accelerated GPU models are compared. A brief history and some fundamental concepts are discussed.

Chapter 2, Designing a GPU Computing Strategy, focuses on computer hardware-related discussions. You will gain knowledge on how to get started with GPU computing-friendly hardware. The impact on GPU performance will also be discussed, with a comparison of air and liquid cooling.

Chapter 3, Setting Up a GPU Computing Platform with NVIDIA and AMD, focuses on leading GPU manufacturers NVIDIA and AMD, with a comparison of their readily available programmable models. The differences in computing on both platforms will be highlighted.

Chapter 4, Fundamentals of GPU Programming, introduces GPU programming and three different platforms, namely CUDA, ROCm, and Anaconda. NVIDIA and AMD GPUs will be revisited here to explore the practical usage of GPUs with a selection of computer hardware platforms.

Chapter 5, Setting Up Your Environment for GPU Programming, offers a brief guide on choosing the most suitable IDE for GPU computing with Python. PyCharm will be discussed in detail, and its effectiveness as a GPU-programmable platform will also be illustrated.

Chapter 6, Working with CUDA and PyCUDA, teaches you how to install and configure the PyCharm IDE with PyCUDA. You will be able to develop your own code through Python after learning about how to make use of NVIDIA's CUDA API within Python code.

Chapter 7, Working with ROCm and PyOpenCL, introduces you to the open source world of GPU computing! You will learn about ROCm, and a CUDA converter called HIPify, to easily port GPU code for both NVIDIA and AMD GPUs. With PyOpenCL, you will be able to develop your own code through Python, after learning about how to make use of the OpenCL API within Python code.

Chapter 8, Working with Anaconda, CuPy, and Numba for GPUs, teaches you how to use Anaconda specifically with GPUs. This chapter will introduce you to writing pure Python code with CuPy, a GPU implementation such as NumPy, and another library called Numba for CUDA and ROCm.

Chapter 9, Containerization on GPU-Enabled Platforms, introduces you to the concept of containerization and shows you how open and closed environments work as local or cloud containers. You will learn about Virtualenv and Google Colab with hands-on exercises.

Chapter 10, Accelerated Machine Learning on GPUs, is a hands-on guide to installing, configuring, and testing your first GPU-accelerated machine learning program. Besides Tensorflow and PyTorch, we will explore nueral networks to get understand GPU-enabled deep learning better.

Chapter 11, GPU Acceleration for Scientific Applications Using DeepChem, is where a Python-based and GPU-enabled deep learning library known as DeepChem will be discussed in detail, with a comprehensive but simple introduction to the various scientific concepts behind it.

Appendix A, discusses various use cases wherein machine learning and Python work in tandem to enhance the data processing and analysis procedures.

To get the most out of this book

While I have tried my best to be as simple as possible in explaining the concepts in this book, knowledge of the basics of programming paradigms will be a big help to you.

This book uses the Ubuntu 18.04 LTS Linux operating system for the hands-on examples. Running the code on an Ubuntu system would, thus, be an ideal choice.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-GPU-Computing-with-Python. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

Code in Action

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "All the elements of the p and q arrays are set to 24 and 12 respectively"

A block of code is set as follows:

  // Run function on 500 Million elements on the CPU
begin = clock();
multiply(N, p, q);
end = clock();
cpu_time_used = ((double) (end - begin)) / CLOCKS_PER_SEC;

Any command-line input or output is written as follows:

$ g++ cpu_multiply.cpp -o cpu_multiply
$ ./cpu_multiply

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Choose New Project from the PyCharm main menu."

Warnings or important notes appear like this.
Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at customercare@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On GPU Computing with Python
Published in: May 2019Publisher: PacktISBN-13: 9781789341072
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Avimanyu Bandyopadhyay

Avimanyu Bandyopadhyay is currently pursuing a PhD degree in Bioinformatics based on applied GPU computing in Computational Biology at Heritage Institute of Technology, Kolkata, India. Since 2014, he developed a keen interest in GPU computing, and used CUDA for his master's thesis. He has experience as a systems administrator as well, particularly on the Linux platform. Avimanyu is also a scientific writer, technology communicator, and a passionate gamer. He has published technical writing on open source computing and has actively participated in NVIDIA's GPU computing conferences since 2016. A big-time Linux fan, he strongly believes in the significance of Linux and an open source approach in scientific research. Deep learning with GPUs is his new passion!
Read more about Avimanyu Bandyopadhyay