Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Events
Videos
Audiobooks
Packt Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
GPU-Accelerated Computing with Python 3 and CUDA

You're reading from   GPU-Accelerated Computing with Python 3 and CUDA From low-level kernels to real-world applications in scientific computing and machine learning

Arrow left icon
Product type Paperback
Published in Mar 2026
Publisher Packt
ISBN-13 9781803245423
Length 534 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Niels Cautaerts Niels Cautaerts
Author Profile Icon Niels Cautaerts
Niels Cautaerts
Hossein Ghorbanfekr Hossein Ghorbanfekr
Author Profile Icon Hossein Ghorbanfekr
Hossein Ghorbanfekr
Arrow right icon
View More author details
Toc

Table of Contents (24) Chapters Close

Preface 1. Part 1: Fundamentals of GPU programming with CUDA in Python 3
2. Chapter 1: Why GPU Programming with CUDA in Python 3? FREE CHAPTER 3. Chapter 2: Setting Up a GPU Programming Environment Locally and in the Cloud 4. Chapter 3: Writing and Executing CUDA Kernels with Numba-CUDA 5. Chapter 4: Profiling and Debugging CUDA Code 6. Part 2: Performance Optimization and Advanced CUDA Topics
7. Chapter 5: Optimizing the Performance of CUDA Code 8. Chapter 6: Enabling Concurrency Using CUDA Streams 9. Chapter 7: Scaling to Multiple GPUs 10. Part 3: Using High-Level Python Libraries for GPU Computation
11. Chapter 8: Bringing NumPy and SciPy to the GPU with CuPy 12. Chapter 9: Bringing pandas and scikit-learn to the GPU with Rapids 13. Chapter 10: Solving Optimization Problems on the GPU with JAX 14. Part 4: Real-World Example Applications
15. Chapter 11: Solving the Heat Equation on the GPU 16. Chapter 12: Image Processing and Computer Vision on the GPU 17. Chapter 13: Simulating Atomic Interactions on the GPU 18. Chapter 14: Implementing Your Own Transformer-Based Language Model 19. Part 5: Beyond This Book
20. Chapter 15: Expanding and Deepening Your GPU Programming Knowledge 21. Chapter 16: Unlock Your Exclusive Benefits 22. Other Books You May Enjoy 23. Index

Answers

  1. The non-parallelizable part of the code is 10% or 0.1. Therefore, according to Amdahl's law, the maximum speedup is 10×. If we want to reach 90% of that, we want to achieve a speedup of 9×. If we plug this into Amdahl's law again and solve for s, we need to speed up the parallelizable part 81×, so if we assume linear scaling, we need 81× the amount of compute resources. To reach 99% of the maximum speedup, we want to reach a speedup of 9.9×. This corresponds to s=891; in other words, we need 891× the amount of compute resources. In reality, we would need even more resources to account for imperfect scaling.
  2. Memory bottlenecks, coordination/synchronization/communication between workers, and workload imbalance between workers.
  3. No. The loop serves to sequentially update a single variable. If we distribute this over multiple threads, we will get completely non-deterministic behavior as different threads compete to try to update z.
  4. The key is that, while the Numba decorated function looks like a Python function, it no longer is a Python function. Numba compiles the function to machine code, which is similarly efficient as compiled C and Fortran.
  5. No. Because the JITed function is no longer running on the Python interpreter, it is no longer being run line by line, and line profiling becomes meaningless.
  6. GPU threads are very lightweight, and the GPU is very good at efficiently scheduling those threads and switching between them. When there is more work to be done than there are threads, we are trying to do the job of the scheduler, because we are instructing our threads to do multiple tasks that could be parallelized. CPU threads are heavyweight, and typically, there is no benefit to adding more threads than the number of cores.

Get this book's PDF version and more

Scan the QR code (or go to packtpub.com/unlock). Search for this book by name, confirm the edition, and then follow the steps on the page.

Image 7
Image 8

Note: Keep your invoice handy. Purchases made directly from Packt don't require an invoice.

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
GPU-Accelerated Computing with Python 3 and CUDA
You have been reading a chapter from
GPU-Accelerated Computing with Python 3 and CUDA
Published in: Mar 2026
Publisher: Packt
ISBN-13: 9781803245423
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.
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 $19.99/month. Cancel anytime
Modal Close icon
Modal Close icon