microsoft / DirectML

DirectML is a high-performance, hardware-accelerated DirectX 12 library for machine learning. DirectML provides GPU acceleration for common machine learning tasks across a broad range of supported hardware and drivers, including all DirectX 12-capable GPUs from vendors such as AMD, Intel, NVIDIA, and Qualcomm.
MIT License
2.22k stars 297 forks source link

How to switch GPUs between integrated graphic chip and independent adapter card? #143

Open daoxian opened 3 years ago

daoxian commented 3 years ago

Hi there. I have a Windows computer with two graphic cards: one is an integrated intel graphic and the other is an nVidia graphic card. I know the way to set the running graphic card by nVidia driver & display tool application. But in fact, I want to control DirectML to use the one of better performance by my program codes instead of setting it manually. Is it possible?

adtsai commented 3 years ago

Absolutely! If you're calling into the DirectML native API directly, you can control this by controlling the device you supply to DMLCreateDevice. Specifically, when creating your D3D12 device you can specify an adapter to use. If you have multiple GPUs, you can automatically select the high-power device using IDXGIFactory6::EnumAdapterByGpuPreference with DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE.

If using a higher-level framework like WinML, OnnxRuntime, or tensorflow-directml, there are also ways to control this: