Can MATLAB tell me which gpu device is the one connected to the display?
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
For example, with a GTX590, I have two gpu devices to choose from. Now my theory is that for CUDA kernel performance it might be best to select the device that is not also busy controlling the display. So I guess I am really asking two questions:
1) Is there in fact a performance hit when running a CUDA kernel on a device that is also connected to the main display and rendering my desktop?
2) If so, how can I tell which gpuDevice is which? Thanks, -nuun
0 comentarios
Respuestas (4)
Konrad Malkowski
el 25 de Mzo. de 2012
1. Yes there will be limitations on what can run on GPU that is used for rendering. In particular the CUDA kernels cannot run for more than 2 to 5 seconds on such a card. So if you have a computation that takes longer, you will need to break it down into smaller chunks. As computing each smaller chunk will involve an individual kernel launch, there will be a performance degradation.
2. I think you might be able to determine if a device is powering a screen by checking the KernelExecutionTimeout property of the object returned by the call to gpuDevice.
2 comentarios
Jason Ross
el 26 de Mzo. de 2012
See if you can set the one for compute to TCC mode, this may change this property value. You can do this with nvidia-smi
Jason Ross
el 26 de Mzo. de 2012
Ways I could think of to determine which device is connected to a monitor. Some of this is a bit of wild conjecture on my part, so take it with a bit of salt:
- The output of gpuDevice gives the total memory and free memory on the device. In the case of a system that has a card connected and one reserved for compute, the compute resource will have no memory consumed, and the display one will have some memory consumed. This isn't a bullet-proof strategy, though.
- If you have access to the nvidia-smi utility (I'm not sure if it works for the GTX series of cards -- it says it's only supported on Tesla and some Quadro cards), you can check the driver mode of each GPU. You can get all the syntax from "nvidia-smi -h", but the main command to use is likely "nvidia-smi --query". A card reserved solely for compute will be in "TCC" mode, and one for graphics rendering will be in "WDDM" and can be used for compute and compute. You could parse this output to find out the "best" one to use. This is valid for Windows only -- WDDM mode does not apply on Linux or Mac
- If you can't use nvidia-smi, in the CUDA SDK there is an example called "deviceQuery" that gets information about the device. It would be possible to look through these fields and build a small executable that returns the "best" one. There might also be something available at this level that tells you if the monitor is connected -- since it has to know to prevent you from turning off WDDM on a card with a monitor connected!
Geoff
el 26 de Mzo. de 2012
If you are running Windows, you could write a little MEX script that returns a list of devices and their status from the API call EnumDisplayDevices:
3 comentarios
Geoff
el 27 de Mzo. de 2012
Are you talking about one card with two display outputs, or two cards? In the case of two cards, I would have thought that the DISPLAY_DEVICE structure returned from EnumDisplayDevices would contain enough information (device name, device context, state flags). I usually use EnumDisplayMonitors, but for a different purpose (positioning windows on available monitors), so I haven't tried EnumDisplayDevices. Tempted to try it now =)
Geoff
el 27 de Mzo. de 2012
Well, I couldn't help myself. I had to try it. Here's the result of running an EnumDisplayDevices test on my machine:
Device: 0
Name = \\.\DISPLAY1
String = NVIDIA GeForce 9800 GT
Flags = active pruned primary
Device: 1
Name = \\.\DISPLAY2
String = NVIDIA GeForce 9800 GT
Flags = active pruned
Device: 2
Name = \\.\DISPLAY3
String = NVIDIA GeForce 9400 GT
Flags =
Device: 3
Name = \\.\DISPLAYV1
String = RDPDD Chained DD
Flags = mirror
Device: 4
Name = \\.\DISPLAYV2
String = RDP Encoder Mirror Driver
Flags = mirror
My machine has one graphics card (the 9800GT) with two outputs (both of which are attached to monitors), and presumably the 9400GT is the on-board graphics.
The code:
/* Output available display devices */
DISPLAY_DEVICEA dd;
dd.cb = sizeof(dd);
DWORD iDevNum = 0;
while( EnumDisplayDevicesA(NULL, iDevNum, &dd, 0) )
{
printf( "Device: %d\n", iDevNum );
printf( " Name = %s\n", dd.DeviceName );
printf( " String = %s\n", dd.DeviceString );
printf( " Flags =" );
if( dd.StateFlags & DISPLAY_DEVICE_ACTIVE ) printf(" active");
if( dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER ) printf(" mirror");
if( dd.StateFlags & DISPLAY_DEVICE_MODESPRUNED ) printf(" pruned");
if( dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE ) printf(" primary");
if( dd.StateFlags & DISPLAY_DEVICE_REMOVABLE ) printf(" removable");
if( dd.StateFlags & DISPLAY_DEVICE_VGA_COMPATIBLE ) printf(" vga");
printf( "\n\n" );
iDevNum++;
}
I presume you are looking for the devices that are not mirrored or active.
6 comentarios
Walter Roberson
el 3 de Mayo de 2012
The mortal editors cannot "unaccept", but the matlabcentral team can.
Ver también
Categorías
Más información sobre GPU Computing en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!