liveBook · Manning

CUDA

As explained in Fast Python: High performance techniques for large datasets

CUDA is NVIDIA’s parallel computing platform and programming model for performing general-purpose computations on NVIDIA GPUs.

CUDA is NVIDIA’s platform and programming model for general-purpose GPU computing. Its APIs underpin GPU data-analysis libraries including CuPy, cuDF, cuML, and BlazingSQL; the treatment uses NVIDIA APIs while noting that concepts can transfer to AMD and vendor-agnostic tools. section 9.1.2

A CUDA kernel commonly handles one array element per thread. A launch configuration distributes work across blocks and threads; bounds checks protect elements when the total thread count exceeds the array size. GPU code also has to account for data transfers between separate CPU and GPU memory spaces. section 9.2.2 section 9.1.2

Doubling an array

A Numba CUDA kernel uses cuda.grid to find each thread’s position and doubles that array element. Launching it with 50 blocks of 20 threads processes a 1,000-element array; an assertion checks the result. section 9.2.2

Figure 9.1 The CPU and GPU have separate memory spaces. We need to transfer our data to the memory associated with the GPU for computation and then get our results back into the CPU-associated memory, which can cost a substantial amount of time.

The diagram highlights separate CPU and GPU memory spaces and the transfer cost to consider when moving data for computation. section 9.1.2

How Fast Python: High performance techniques for large datasets covers it

How deep it goes
Builds kernels and launch configurations with bounds checks, but defers advanced shared-state algorithms and detailed C instruction.
Examples
Demonstrates doubling one- and two-dimensional arrays and generating a Mandelbrot set with CUDA C.
What you can do after
Build GPU array kernels with Numba or CUDA C, configure their thread launches, and compare measured execution times.
How it connects
Connects CUDA with GPU computing, Numba, CuPy, CUDA C, NumPy, and CPU–GPU memory transfers.

Also explained in

Compare how 4 books explain CUDA →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fast Python: High performance techniques for large datasets. The section links point to the parts of the book it draws on.