0PricingLogin
CUDA Academy · Lesson

Enumerating and Selecting Devices

cudaSetDevice and per-GPU contexts.

More Than One GPU

A single machine can hold several GPUs. To use them all, your program first needs to discover how many devices are present before it sends any work.

Counting the Devices

One call tells you how many GPUs the runtime can see. cudaGetDeviceCount writes that number into an int you hand it.

int count;
cudaGetDeviceCount(&count);

All lessons in this course

  1. Enumerating and Selecting Devices
  2. Partitioning Work Across GPUs
  3. Peer-to-Peer Memory Access
  4. Multi-GPU with NCCL
← Back to CUDA Academy