Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does NVAPI device IDs relate to CUDA device IDs?

Tags:

c

cuda

I'm working on getting a CUDA application to also monitor the GPU's core temp. That information is accessible via NVAPI.

A problem is that I want to make sure I'm monitoring the same GPU as I'm running my code on.

However, there seems to be information suggesting that the device IDs I get from NvAPI_EnumPhysicalGPUs does not correspond to the ones used with SetDeviceId.

Could anyone clarify?

like image 753
biozinc Avatar asked Jan 29 '10 07:01

biozinc


People also ask

How do I choose a CUDA device?

The canonical way to select a device in the runtime API is using cudaSetDevice . That will configure the runtime to perform lazy context establishment on the nominated device. Prior to CUDA 4.0, this call didn't actually establish a context, it just told the runtime which GPU to try and use.

Where do I find Cuda device ID?

or CUDA Driver API cuDeviceGetByPCIBusId cuDeviceGetPCIBusId . But IMO the most reliable way to know which device is which would be to use NVML or nvidia-smi to get each device's unique identifier (UUID) using nvmlDeviceGetUUID and then match it do CUDA device with pciBusId using nvmlDeviceGetPciInfo .


2 Answers

I saw an interesting discussion about it here.

As far as I can tell, these numbers don't have a direct correlation.

like image 180
karlphillip Avatar answered Oct 07 '22 21:10

karlphillip


I test it in my computer with two NVIDIA GPUs GTX 550 ti.
The result is, there all information is the same, except for Bus ID.
So, in nvapi, use NvAPI_GPU_GetBusId, this will get an integer, like 1, 2,...
then, in cuda API, use cudaDeviceGetPCIBusId, this will get a string, like 0000:01:00.0.
compare the busID integer with the BusID String's second part,
you can get their relationship.

like image 26
Anders Avatar answered Oct 07 '22 22:10

Anders