C++ 链接Cuda(cudart.lib)会使DXGI DuplicateOutput1()失败

C++ 链接Cuda(cudart.lib)会使DXGI DuplicateOutput1()失败,c++,cuda,dxgi,desktop-duplication,C++,Cuda,Dxgi,Desktop Duplication,由于一个模糊的原因,在我将cudart.lib添加到项目中后,我对IDXGIOutput5::DuplicateOutput1()的调用失败,错误为0x887a0004(不支持DXGI_error_) 我在Visual Studio 2019上工作,我的监视器复制代码是经典的: hr = output5->DuplicateOutput1(this->dxgiDevice, 0, sizeof(supportedFormats) / sizeof(DXGI_FORMAT), supp

由于一个模糊的原因,在我将cudart.lib添加到项目中后,我对IDXGIOutput5::DuplicateOutput1()的调用失败,错误为0x887a0004(不支持DXGI_error_)

我在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
            );
}
int nDevices=0;
cudaError\u t error=cudaGetDeviceCount(&N设备);
对于(int i=0;i
此外,这段代码是在我尝试使用DXGI开始监视复制之后调用的

在我的应用程序中,每件事似乎都是正确的:我调用了SetProcessDpiAwarenessContext(DPI\U感知\U上下文\U PER\U监视器\U感知\U V2),并且我没有在离散GPU上运行(请参见[)

顺便说一句,它以前是工作的,如果我从链接器输入中删除“如此简单”的Cuda调用和cudart.lib,它又能工作了

我真的不明白是什么导致了这种奇怪的行为,知道吗

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

当你们链接CUDA库时,你们强迫你们的应用程序在离散的GPU上运行。你们已经知道这应该避免,但你们仍然强迫它通过这个链接

…我不是在e离散GPU上运行

您是,CUDA的静态链接是一个提示使用dGPU的特定案例

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

(但是,还有其他系统,桌面复制对dGPU起作用,而对iGPU不起作用)

您的潜在解决方案是:

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


您是否尝试过使用调试层:它经常显示有用的额外信息(在VisualStudio的输出窗口中)