Programmatically forcing the NVidia GPU over Integrated graphics

Is there a way to programmatically force the NVidia GPU to be used instead of the Integrated graphics chip (usually an Intel graphics chip) for which graphics processor is used?

You can set this mode in the NVidia Control Panel, under “3D Settings”. When you have a hybrid system with two graphics chips, the control panel will show an option called “Preferred graphics processor” where you can select which processor you want (NVidia’s GPU or the Integrated GPU).

But users can have difficulty finding this and setting the correct mode, so is there a way we can programmatically do this from our app?

I’m just going out on a limb here but the Control Panel is a GUI to an underlying data file. What the user enters there is stored somewhere on the computer. Have your app jump into that file and modify the appropriate data as required.

Try if this SDK supports what you need: [url]https://developer.nvidia.com/nvapi[/url]

http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf

Thanks cbuchner1, that link to the Optimus rendering policies looks like it is exactly what I need. I’ll give it a try. The NVAPI library that Detlef mentioned is also interesting.

I have come to the same problem.Have you solved it ?

This has always been a problem on Macbook Pro laptops as well, which has no Optimus. My hack workaround has been to create an OpenGL window which activates the discrete GPU, initialize the CUDA runtime with an API call (using the now-visible GPU), then free the OpenGL window.

@Hugo_He I just had a similar issue and managed to solve it!
Just use the example code from the pdf file attached by cbuchner1

extern "C" {
 _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
}