I had recently some trouble making my pc (ivybridge) use the onboard gpu (intel igpu HD4000) for normal screen display usage, while i run my CUDA programs for computations on the discrete Nvidia GT 640 i have on my machine. The problem was that under iGPU display, CUDA would be unable to spot the nvidia card, and the nvidia drivers would not load at all.
Keep in mind that there are confirmed issues (mostly about concurrency) when using the nvidia windows drivers for display devices, and also want to use CUDA. Those issues can get overridden when you use the Intel gpu as display (thus loading only a minimal part of said Nvidia drivers) and are on many occasions non-existent with nvidia drivers for linux distributions.
After getting in a lot of trouble with bad software like virtu mvp, i found the solution to be really simple, but nowhere to be found.
I post it here in hope that it helps. Please post any comments to make the answers more complete, even if it fails for some pc configurations, so we can clarify the instructions for a wider range of scenarios.
You have to install the drivers for your integrated onboard gpu. This can be done by booting up while using iGPU from bios settings, and your pc shall be able to load the drivers it needs on its own. For my Ivy bridge, the bios settings are these:
Go to bios by repeatedly pressing del on startup.
Go to Advanced Mode by pressing F7 or by mouse clicking the respective option
Go to Advanced tab,System Agent, and enable as primary the iGPU, and the multi-monitor support.
You boot with the iGPU (mine was HD4000), check that all is ok, but now you see the problem mentioned: CUDA devices can't be found/used (Except Tesla, i think, since they are not considered display and so they have nothing to do with this). Normally, you can find the discrete gpu under the device manager and update it manually from there. Then, CUDA should be able to spot your gpu. If that doesn't work, proceed to step 3.
You reboot, go to bios again, select as primary the PCI-E card, and boot. You should be now using the nvidia card and everything should be normal, but still no way to use both iGPU and Nvidia. While using Nvidia card, go to device manager, find Intel iGPU in display devices, and perform a driver update. This is needed despite the fact that we have already let intel get its own drivers on the previous steps.
When done, go to boot menu again, use as primary the iGPU, plug your display in it, and now, when using it, CUDA will be able to see the NVIDIA card and perform computations in it, while the display uses the iGPU, and the system remains responsive! I think this can also be used for gaming, or other performance reasons, like Dual monitors on integrated (onboard GPU) and discrete GPU.
来源:https://stackoverflow.com/questions/28895132/cuda-fails-when-trying-to-use-both-onboard-igpu-and-nvidia-discrete-card-how-ca