Multiple GPUs - how to set the device?

I have 2 GPUs in SLI mode. 1st card should rendering (OpenGL), 2nd - calculating using CUDA. The main problem is - how to set correct GPU? I have two OpenMP sections: first - rendering, second - calculations.
Probably using cudaGLSetGLDevice should help but it doesn’t. Why? When I set cutilSafeCall(cudaSetDevice(0));, my program probably should draw different number of fps than when I set cutilSafeCall(cudaSetDevice(1));. Sometimes it’s true, sometimes not. Looks like in both situations, sometimes I use one GPU for two things but sometimes it works correctly. so maybe cudaGLSetGLDevice? Nope - I set different number - it doesn’t help.

cudaSetDevice() will select a device for running CUDA kernels. Open GL will run on whichever GPU your display is connected to.

Going back to your problem, if you have SLI enabled, duh! Open GL will run on both GPUs.

When I disabled SLI mode, I had the same number of fps - so does second GPU (in SLI mode) sth useless? If I disable SLI, I can’t use second GPU for CUDA. Also I checked global 3D settings in NV control panel (SLI performance mode - SLI/Single GPU) - and nothing.

Looks like now the main problem is how to use two GPUs but render on only one? But I don’t understand one thing - sometimes my program works good. Is possible when I set device 0, I use 1st physical GPU (and 1 for 2nd GPU), but when I run my application next time and set 0, it’s 2nd GPU (and 1 for 1st)? Is it “random” and using cudaSetDevice 0/1 will allow to set OTHER device when program runs (but not physical GPU)? I don’t have different graphic cards so probably I can’t check it by cutGetMaxGflopsDeviceId() etc.

cudaSetDevice() does not affect OpenGL. That depends strictly on where your display(s) is/are connected. Set SLI performance mode to force Alternate Frame Rendering, and you should see a difference in OpenGL performance.

It doesn’t change number of fps in my application but I checked FFT Ocean Simulation from SDK and here’s sth strange - without SLI, I have 300fps but when SLI is active - it’s 200fps - in sourcecode I don’t see that sth is copying between CPU and GPU but maybe I’m wrong.