# Programmatically forcing the NVidia GPU over Integrated graphics

**URL:** <https://forums.developer.nvidia.com/t/programmatically-forcing-the-nvidia-gpu-over-integrated-graphics/36533>\
**Category:** CUDA Programming and Performance\
**Created:** [January 27, 2015, 3:55pm UTC](https://forums.developer.nvidia.com/t/programmatically-forcing-the-nvidia-gpu-over-integrated-graphics/36533 "2015-01-27T15:55:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deancooper](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/deancooper/32/71264_2.png) [@Deancooper](https://forums.developer.nvidia.com/u/Deancooper)\
**Post date:** [January 27, 2015, 3:55pm UTC](https://forums.developer.nvidia.com/t/programmatically-forcing-the-nvidia-gpu-over-integrated-graphics/36533/1 "2015-01-27T15:55:23Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![MutantJohn](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@MutantJohn](https://forums.developer.nvidia.com/u/MutantJohn)\
**Post date:** [January 27, 2015, 8:01pm UTC](https://forums.developer.nvidia.com/t/programmatically-forcing-the-nvidia-gpu-over-integrated-graphics/36533/2 "2015-01-27T20:01:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![droettger](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/droettger/32/14043_2.png) [@droettger](https://forums.developer.nvidia.com/u/droettger)\
**Post date:** [January 28, 2015, 10:28am UTC](https://forums.developer.nvidia.com/t/programmatically-forcing-the-nvidia-gpu-over-integrated-graphics/36533/3 "2015-01-28T10:28:06Z")

</div>

Try if this SDK supports what you need: [url][https://developer.nvidia.com/nvapi[/url]](https://developer.nvidia.com/nvapi%5B/url%5D)

---

<div class="post-metadata">

**Author:** ![cbuchner1](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/cbuchner1/32/14168_2.png) [@cbuchner1](https://forums.developer.nvidia.com/u/cbuchner1)\
**Post date:** [January 28, 2015, 10:34am UTC](https://forums.developer.nvidia.com/t/programmatically-forcing-the-nvidia-gpu-over-integrated-graphics/36533/4 "2015-01-28T10:34:19Z")

</div>

[http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf](http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf)

---

<div class="post-metadata">

**Author:** ![Deancooper](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/deancooper/32/71264_2.png) [@Deancooper](https://forums.developer.nvidia.com/u/Deancooper)\
**Post date:** [January 28, 2015, 2:07pm UTC](https://forums.developer.nvidia.com/t/programmatically-forcing-the-nvidia-gpu-over-integrated-graphics/36533/5 "2015-01-28T14:07:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Hugo\_He](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Hugo\_He](https://forums.developer.nvidia.com/u/Hugo_He)\
**Post date:** [May 24, 2016, 6:36am UTC](https://forums.developer.nvidia.com/t/programmatically-forcing-the-nvidia-gpu-over-integrated-graphics/36533/6 "2016-05-24T06:36:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SPWorley](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@SPWorley](https://forums.developer.nvidia.com/u/SPWorley)\
**Post date:** [May 25, 2016, 6:36pm UTC](https://forums.developer.nvidia.com/t/programmatically-forcing-the-nvidia-gpu-over-integrated-graphics/36533/7 "2016-05-25T18:36:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pavliuk.vlad](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@pavliuk.vlad](https://forums.developer.nvidia.com/u/pavliuk.vlad)\
**Post date:** [June 25, 2023, 9:51pm UTC](https://forums.developer.nvidia.com/t/programmatically-forcing-the-nvidia-gpu-over-integrated-graphics/36533/8 "2023-06-25T21:51:43Z")

</div>

@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

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

```
