2

由于一个模糊的原因,在我的项目中添加 cudart.lib 后,我对 IDXGIOutput5::DuplicateOutput1() 的调用失败并出现错误 0x887a0004 (DXGI_ERROR_UNSUPPORTED)。

我在 Visual Studio 2019 上工作,我的监视器复制代码是经典的:

hr = output5->DuplicateOutput1(this->dxgiDevice, 0, sizeof(supportedFormats) / sizeof(DXGI_FORMAT), supportedFormats, &this->dxgiOutputDuplication);

我目前唯一尝试对 cuda 做的就是列出 Cuda 设备:

 int nDevices = 0;

 cudaError_t error = cudaGetDeviceCount(&nDevices);

 for (int i = 0; i < nDevices; i++) {

            cudaDeviceProp prop;
            cudaGetDeviceProperties(&prop, i);

            LOG_FUNC_DEBUG("Graphic adapter : Descripion: %s, Memory Clock Rate : %d kHz, Memory Bus Width : %u bits",
                prop.name,
                prop.memoryClockRate,
                prop.memoryBusWidth
            );
}

此外,在我尝试使用 DXGI 开始监控复制之后,这段代码被调用了很久。

我的应用程序中的每件事似乎都是正确的:我调用了 SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2),但我没有在离散 GPU 上运行(请参阅 [ https://support.microsoft.com/en-us/help/3019314/error -生成-when-desktop-duplication-api-capable-application-is-ru][1] )

顺便说一句,它曾经工作过,如果我从链接器输入中删除“如此简单”的 Cuda 调用和 cudart.lib ,它就会再次工作!

我真的不明白什么会导致这种奇怪的行为,有什么想法吗?

4

1 回答 1

2

...在我的项目中添加 cudart.lib 之后

当您链接 CUDA 库时,您会强制您的应用程序在离散 GPU 上运行。您已经知道应该避免这种情况,但您仍然通过此链接强制它。

...而且我没有在独立 GPU 上运行...

您是,到 CUDA 的静态链接是提示使用 dGPU 的特定情况。

有些系统桌面复制不适用于 dGPU,而您的系统似乎就是其中之一。即使不明显,您也看到了 [NVIDIA] 设计的行为。

(但也有其他系统,其中桌面复制对 dGPU 有效,但对 iGPU 无效)。

您的潜在解决方案是沿着这条线

应用程序不直接链接到 cuda.lib 或 cudart.lib 或 LoadLibrary 以动态加载 nvcuda.dll 或 cudart*.dll 并使用 GetProcAddress 从 nvcuda.dll 或 cudart*.dll 检索函数地址。

于 2020-03-28T16:00:04.137 回答