Sunday, 4 June 2017

How to find out id of current gpu on your system in CUDA?


             GPUs in our system have ids from 0 to n-1 where n is the total number of GPUs.  
              Only one GPU is set as current GPU. Current GPU means a GPU which is ready for computation.
              We can find out id of current GPU by calling function cudaGetDevice().

e.g. 
int device_id;
cudaGetDevice(&device_id);

Note: Here, device_id gives id of current GPU after calling cudaGetDevice(&device_id) function.

No comments:

Post a comment