CUDA 合作组:链接错误 [英] CUDA Cooperative Groups : Linking error

查看:25
本文介绍了CUDA 合作组:链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读了 CUDA 9 中的合作组之后,我一直在尝试在网格级别进行同步.

After reading about Cooperative Groups in CUDA 9, I've been trying synchronize at a grid level.

我正在使用 Visual Studio 2017、GTX 1060 和 CUDA 9.1.

I'm using Visual Studio 2017, a GTX 1060 and CUDA 9.1.

我修改了我的代码如下:

I altered my code as follows:

__global__ void ExplicitKernel_American(/* ... */) {
    int i = threadIdx.x + blockDim.x * blockIdx.x;
    auto grid = cooperative_groups::this_grid();
    if (i < sizeS) {
        //...
        for (int j = 1; j < sizeT; ++j) {
            // ...
            grid.sync(); // __syncthreads();
        }
    }
}

而且,正如文档中所述,我这样称呼我的内核:

And, as stated in the documentation, I call my kernel this way :

void* Explicit_Args[] = { &PDE_Grid, /* ... */, &sizeS, &sizeT };
cudaLaunchCooperativeKernel(
    (void*)ExplicitKernel_American, 
    dim3((sizeS + TPB - 1) / TPB), 
    dim3(TPB),  
    Explicit_Args
); // TPB being 256...

不幸的是,我在内核中添加网格"部分后立即出现链接错误.

Unfortunately, I get linking errors as soon as I add the "grid" part in the kernel.

error LNK2001: unresolved external symbol __fatbinwrap_38_cuda_device_runtime_compute_70_cpp1_ii_8b1a5d37
fatal error LNK1120: 1 unresolved externals

我设置了 -rdc=true 和 sm_61 但找不到它为什么不起作用...有什么想法吗?

I've set -rdc=true and sm_61 but cannot find why it is not working... Any ideas ?

非常感谢!

推荐答案

使用协同内核启动(协同网格 - CG)需要 Pascal 或 Volta GPU,并且需要在 TCC 模式下运行的 Linux 或 Windows 设备.如果你测试设备属性结构中的 deviceProp.cooperativeLaunch 属性,我想你会发现你的GPU在WDDM模式下不支持它.

Use of a cooperative kernel launch (cooperative grid - CG) requires a Pascal or Volta GPU, and requires either Linux or a windows device operating in TCC mode. If you test the deviceProp.cooperativeLaunch property in the device properties structure, I think you will find that it is not supported on your GPU operating in WDDM mode.

在尝试使用协作网格启动之前,最好在代码中测试此属性.

It's good practice to test this property in your code, before attempting to use a cooperative grid launch.

但是,您要问的问题是编译/链接问题.为此,我的建议是研究 CG(协作网格)示例代码,例如 6_Advanced/reductionMultiBlockCG.对于网格同步,绝对需要设置 -rdc=true(即启用可重定位设备代码链接).根据您设置 -rdc=true 的方式,它可能无法正确应用于您的项目.此处

The issue you are asking about is a compile/link issue, however. For that, my recommendation is to study a CG (cooperative grid) sample code, such as 6_Advanced/reductionMultiBlockCG. For grid sync, its definitely a requirement to set -rdc=true (i.e. enable relocatable device code linking). Depending on how you set -rdc=true, it may not be applied to your project correctly. The correct methodology is outlined here

这里的近端问题似乎是您没有正确链接到设备运行时库,例如-lcudadevrt

The proximal issue here appears to be that you are not correctly linking against the device runtime library, e.g. -lcudadevrt

这篇关于CUDA 合作组:链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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