Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CUDA常量内存无效符号_Cuda - Fatal编程技术网

CUDA常量内存无效符号

CUDA常量内存无效符号,cuda,Cuda,当我打电话时 struct d_struct { // stuff }; __device__ __constant__ d_struct structs[SIZE]; 在主机内存中的d_struct“h_struct”上,我得到一个无效的设备符号cuda错误。如果您能提供更多详细信息,它将有所帮助,例如,您运行的是什么平台以及哪个主机编译器版本?哪个CUDA工具包版本?什么装置 同时,一些建议: 确保您正在使用最新的CUDA工具包。目前,3.1是最新版本,3.2是候选版本 如果您使用CU

当我打电话时

struct d_struct {
// stuff
};

__device__ __constant__ d_struct structs[SIZE];

在主机内存中的
d_struct“h_struct”
上,我得到一个
无效的设备符号
cuda错误。

如果您能提供更多详细信息,它将有所帮助,例如,您运行的是什么平台以及哪个主机编译器版本?哪个CUDA工具包版本?什么装置

同时,一些建议:

  • 确保您正在使用最新的CUDA工具包。目前,3.1是最新版本,3.2是候选版本
  • 如果您使用CUDA向导在Windows中运行,请尝试切换到NVIDIA提供的标准规则文件
  • 您是否在构建正确的计算能力?例如,只需检查您是否不是为sm_13编译并在sm_12上运行
  • 是否从声明了常量的同一文件中调用
    cudaMemcpyToSymbol()
    ?如果没有,那么它应该仍然可以工作,因为查找是按名称而不是符号进行的,但是请检查您没有将其声明为
    extern“C”
    ,并且您是从C调用的++
  • 考虑到您遗漏了很多代码,最好检查-d_结构没有模板化,是吗
    • 在D.2.2.1中,它说

      在以下情况下,不允许使用
      \uuuuuuu设备\uuuuuuu
      \uuuuuuu共享\uuuuuuu
      \uuuuuu常量\uuuuuuu
      限定符:

      • class
        struct
        union
        数据成员
      • 形式参数
      • 在主机上执行的函数中的局部变量

      版本/操作系统?还要确保total结构的大小小于常量内存的大小这不是一个结构数据成员,而是一个结构数组。
      cudaMemcpyToSymbol("structs", &h_struct, sizeof(d_struct), index * sizeof(d_struct), cudaMemcpyHostToDevice)