For testing purposes I managed to combine some of my codes with the program wrote for the chapter 9 of this https://www.amazon.com/CUDA-Application-Design-Development-Farber/dp/0123884268
The code makes some calculations and then it plots in a window using opengl and glut libraries. When combining cuda and opengl one has to specify the gpu using the cudaGLSetGLDevice(); function. When there is only one card there is nothing to do, however I have two cards in my computer and sometime people use the main card (which uses X) to make calculations. In this case I would like to do my calculations on the other card, but still make my plots.
How can I select this on a two or more gpu system? I would like to be able to do the cuda part on arbitrary gpu in the system and then plot the results.