Using PyCUDA's gpuarray class

Much like how NumPy's array class is the cornerstone of numerical programming within the NumPy environment, PyCUDA's gpuarray class plays an analogously prominent role within GPU programming in Python. This has all of the features you know and love from NumPy—multidimensional vector/matrix/tensor shape structuring, array-slicing, array unraveling, and overloaded operators for point-wise computations (for example, +, -, *, /, and **).

gpuarray is really an indispensable tool for any budding GPU programmer. We will spend this section going over this particular data structure and gaining a strong grasp of it before we move on.

Get Hands-On GPU Programming with Python and CUDA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.