有没有办法在多GPU环境中以编程方式选择渲染GPU? (视窗) [英] Is there a way to programmatically select the rendering GPU in a multi-GPU environment? (Windows)

查看:105
本文介绍了有没有办法在多GPU环境中以编程方式选择渲染GPU? (视窗)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个OpenGL应用程序,它将在具有多种multi-GPU配置(可能从XP到7的Windows版本)的计算机上运行.是否有一种通用方法来选择独立于GPU组合(例如NVIDIA + NVIDIA,NVIDIA + AMD,NVIDIA + Intel等)的将用作OpenGL渲染器的特定GPU?它必须是一种可以从应用程序代码中应用的解决方案,即直接在C ++中使用,或者可以从应用程序中调用的脚本,而无需最终用户干预.

I have an OpenGL application that will run in machines with diverse multi-GPU configurations (and possibly different Windows versions, from XP to 7). Is there a general way to select the specific GPU that will act as the OpenGL renderer independently of the GPU combination (e.g. NVIDIA + NVIDIA, NVIDIA + AMD, NVIDIA + Intel, etc.)? It has to be a solution that can be applied from application code, i.e. directly in C++ or a script that would be called from the application, with no end-user intervention.

下面是我为找到解决方案而进行的几次测试的详细信息,从非常特殊的情况开始,但是也许有一种解决方案可以在所有或大多数情况下使用.

Below are the details of several tests I have done to try to find a solution, starting with very specific cases, but maybe there is a solution that can work in all or most cases.

是否有任何可靠的方法来强制执行OpenGL渲染的GPU?

Is ther any reliable method to force which GPU does the OpenGL rendering?

任何提示将不胜感激.预先感谢!

Any hint will be very appreciated. Thanks in advance!

使用两个Quadro卡的组合进行测试

Testing with combinations of two Quadro cards

  • Quadro FX 1700 + Quadro FX 570
  • Quadro FX 1700 + Quadro FX 540
  • Quadro FX 1700 + Quadro NVS 285

在64位Windows XP下使用相同的驱动程序(版本275.36),我在各种方法上都取得了相对成功,例如:

using the same driver (version 275.36) under Windows XP 64-bit, I have had relative success with various methods, such as:

  • 由驾驶员决定.
    仅当两张卡使用相同的驱动程序并且决定使用所需的卡时,此解决方案才有效.所以它太具体了,也许是不可预测的.

  • Letting the driver decide.
    This solution is only good as long as both cards use the same driver and it decides to use the desired card. So it is too specific and maybe unpredictable.

在决定驱动程序之前,使用 NVAPI 更改代码中的驱动程序设置.
使用此解决方案,理论上可以让驱动程序根据我的意愿进行决定,但是这很困难,需要两块卡使用相同的驱动程序并且不能始终工作(对于FX 1700 + NVS 285则行不通).

Changing driver settings in code with NVAPI before letting the driver decide.
With this solution it is in theory possible to make the driver decide as I want, but it is hard, needs that both cards use the same drivers and doesn't always work (with FX 1700 + NVS 285 it doesn't work).

更改主屏幕.
这具有默认情况下在选定的主屏幕中打开该应用程序的效果.仅FX 1700 + FX 570组合可单独使用此解决方案.对于FX 1700 + FX 540,渲染器取决于驱动程序设置,而与主屏幕无关,而对于FX 1700 + NVS 285,渲染器始终为FX 1700.

Changing the main screen.
This has the effect that the application opens in the selected main screen by default. This solution has worked on its own only with the FX 1700 + FX 570 combination. With FX 1700 + FX 540 the renderer depends on the driver settings, independently of the main screen, and with FX 1700 + NVS 285 the renderer is always the FX 1700.

在窗口位于特定屏幕中时创建OpenGL上下文.
可以在所需的屏幕中创建窗口,而与主窗口无关,但是它具有与上述解决方案相同的问题.

Creating the OpenGL context when the window is in a specific screen.
The window can be created in the desired screen, independently of which is the main, but it has the same problems as the above solution.

创建OpenGL上下文后,仅启用所需图形卡中的屏幕,然后启用其他屏幕.
这是我发现将NVS 285用作渲染器的唯一方法,但是它很丑陋,我不知道它是否可以自动化或在所有情况下都可以使用.

Creating the OpenGL context having enabled only the screen in the desired graphics card and then enabling the other/s.
This is the only way I have found to use the NVS 285 as the renderer, but it is ugly and I don't know if it is automatizable or if it would work in all cases.

尝试使用 WGL_NV_gpu_affinity 扩展选择渲染GPU.
结合使用FX 1700和FX 570,该扩展程序将两个GPU都报告为兼容,我只能将渲染限制为其中之一.使用FX 1700 + FX 540对时,扩展程序仅报告一个兼容的GPU,这是驱动程序决定用于OpenGL渲染的GPU.使用FX 1700 + NVS 285组合时,始终仅报告FX 1700(我想NVS 285不支持此扩展,因为如果它是唯一使用的卡,则该扩展仍未报告). /p>

Trying to select the rendering GPU using the WGL_NV_gpu_affinity extension.
With the combination of the FX 1700 and the FX 570 the extension reports both GPUs as compatible and I can limit the rendering only to one of them. With the FX 1700 + FX 540 pair the extension reports only one compatible GPU, which is the one the driver decides to use for OpenGL rendering. With the FX 1700 + NVS 285 combination, only the FX 1700 is reported, always (I suppose that the NVS 285 does not support this extension, because if it is the only card in use it is still not reported by the extension).

此系统在Windows 7 64位系统上运行,并且图形卡是一个Intel HD Graphics 2000(集成在CPU(Sandy Bridge)中)和一个AMD Radeon HD6450.在所有情况下,渲染都可在两个屏幕上进行,但是渲染GPU取决于某些变量:

This system runs with Windows 7 64-bit and the graphics cards are one Intel HD Graphics 2000 (integrated in the CPU (Sandy Bridge)) and one AMD Radeon HD 6450. In all cases rendering works on both screens, but the rendering GPU varies depending on some variables:

  • 如果主屏幕已连接到AMD,并且在此屏幕中打开了窗口,则AMD是渲染器.
  • 如果主屏幕连接到AMD,并且在另一个屏幕上打开了窗口,则渲染器为"GDI Generic",这非常慢.
  • 如果主屏幕连接到Intel,则Intel是渲染器,与打开窗口的位置无关.

使用此系统,我还尝试了在OpenGL论坛中提出的解决方案. TL; DR:这是一种选择OpenGL使用的驱动程序的方法,因此可以在使用不同驱动程序的GPU之间进行选择,但不能在使用相同驱动程序的卡之间进行选择.我获得了以下结果:

With this system I have also tried a solution proposed in the OpenGL forums. TL;DR: it's a hacky method to choose the driver used by OpenGL, so it can choose between GPUs that use different drivers, but not between cards that use the same driver. I obtained the following results:

  • 如果主屏幕连接到AMD,我可以选择任何GPU作为渲染器.
  • 如果主屏幕连接到Intel,则可以选择Intel作为渲染器(无用,因为这是自动的),但是如果尝试选择AMD,则会出错.我认为这可能是驱动程序中的错误.

推荐答案

由于您正在使用nvidia Quadro卡,因此可以使用

Since you are using nvidia Quadro cards, you can use the WGL_NV_gpu_affinity extension to select the GPU.

我不确定ATI芯片,但我认为它是 AMD_gpu_association

I am not sure about ATI chips, but I think it is AMD_gpu_association

这篇关于有没有办法在多GPU环境中以编程方式选择渲染GPU? (视窗)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆