Determine if a monitor is connected to a device

Is there a way to determine programatically whether a monitor is connected to a particular GPU? In order to use Nsight on a dual-GPU machine, the client code needs to run on the headless GPU device, and I don’t know how to determine that in my program.

cudaDeviceProp deviceProp;

int dev;

if (cudaGetDeviceProperties(&deviceProp, dev)== cudaSuccess )

{

if( deviceProp.kernelExecTimeoutEnabled == 0 )

{

// this device is not timeout enabled( no monitor hooked up )

// so you can use it without worrying about the time out

cudaSetDevice(dev);

}

}

Not quite as intuitive as one might hope, but if that works then I am grateful. Thanks.

That works everywhere but Vista. I thought Nsight took care of this automatically by masking off the display GPU from CUDA enumeration.