Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get properties from active CUDA device?

Tags:

cuda

nvidia

The well know code for getting properties from CUDA devices (!) is enumerating over all devices, and getting properties from then. Then I see such piece, that activates given device.

I have problem in reverse -- let's say the device is already chosen, and I would like to get properties for it (the active one), not for all devices present in the system.

I hope I wrote this in correct way, because I am new to CUDA.

like image 703
greenoldman Avatar asked Feb 10 '13 16:02

greenoldman


1 Answers

Just call cudaGetDevice() to get the device number of the active context, then call cudaGetDeviceProperties to get the properties of that device. In code that would be something like:

int device;
cudaGetDevice(&device);

struct cudaDeviceProp props;
cudaGetDeviceProperties(&props, device);

[disclaimer: written in browser, never compiled or tested. Use at own risk]

like image 169
talonmies Avatar answered Sep 28 '22 01:09

talonmies