cudaGetSymbolAddress中的无效设备符号(& cuset_addr,random_states_g)

时间:2016-06-07 11:31:52

标签: c++ cuda

#define cuset(symbol, T, val)
{
   void *cuset_addr;
   cucheck(cudaGetSymbolAddress(&cuset_addr, symbol));
   T cuset_val=(val);
   cucheck(cudaMemcpy(cuset_addr, &cuset_val, sizeof(cuset_val),cudaMemcpyHostToDevice))
}

当我编译并运行项目时,它会出现错误:

  

cudaGetSymbolAddress中的设备符号无效(& cuset_addr,   random_states_g)。

我从https://github.com/canonizer/halloc

下载项目

项目中的自述文件提出了这一点:

  

注意:目前尚未编译库和测试   compute_50 / sm_50,即麦克斯韦。

我的环境是:Ubuntu14.04,cuda7.5,capability5.0。

编译如下:

nvcc -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -lineinfo -O3 -lib -rdc=true -Xptxas -dlcm=cg -Xptxas -dscm=wb \
    -Xptxas -maxrregcount=64 -o bin/libhalloc.a src/*.cu

我不知道这是否是由于我的cuda版本,当我搜索错误时,我发现似乎有一些符号从5.0中删除。

1 个答案:

答案 0 :(得分:2)

<system.web> <customErrors mode="On" defaultRedirect="~/Error"> <error redirect="~/Error/NotFound" statusCode="404" /> </customErrors> </system.web> 中,更改此内容:

makefile

到此:

ARCH= -gencode arch=compute_20,code=sm_20 \
    -gencode arch=compute_30,code=sm_30 \
    -gencode arch=compute_35,code=sm_35

并重建项目。

这里的根本问题是项目编译选项被设置为仅包括设备代码(SASS),即不包括生成PTX的选项。仅使用ARCH= -gencode arch=compute_20,code=sm_20 \ -gencode arch=compute_30,code=sm_30 \ -gencode arch=compute_35,code=compute_35 \ -gencode arch=compute_35,code=sm_35 sm_20sm_30的设备代码,您无法为sm_35设备生成设备代码,因此您的设备无法加载模块

通常,当您尝试运行内核时,此类错误可能会显示为“无效的设备函数”错误。但是,如果第一个活动是访问设备符号,那么这些符号也无效,因为设备上没有加载正确的图像,所以在这种情况下你会得到这个特殊的错误。

通过包含以sm_50结尾的编译选项,我们指示CUDA编译器还为您的项目包含一个PTX模块,并且PTX可以在运行时进行前向JIT编译,以匹配您所使用的任何新设备跑着。

这不是修改编译操作以使用您的设备的唯一可行方法,但这是一种可能的方法,通常与一系列设备向前兼容。

相关问题