2

我正在尝试将内存从设备复制到主机,但出现以下错误:

CUDA 错误 13:设备符号无效

__device__ __constant__ unsigned int cuda_delta = 0;
int delta = 0;
checkCuda(cudaMemcpyToSymbol(cuda_delta, 
                             &delta,sizeof(unsigned int),
                             0,
                             cudaMemcpyHostToDevice)); // work
... // call kernel

// does not work, return  CUDA Error 13: invalid device symbol
checkCuda(cudaMemcpyToSymbol(&delta,
                             &cuda_delta,
                             sizeof(unsigned int), 
                             cudaMemcpyDeviceToHost)); 
4

1 回答 1

5

符号引用 GPU 内存,因此当您想从设备复制到主机时不能使用 *ToSymbol。对于要托管的设备,请使用cudaMemcpyFromSymbol.

cudaError_t cudaMemcpyFromSymbol    (   void *  dst,
  const char *  symbol,
  size_t    count,
  size_t    offset = 0,
  enum cudaMemcpyKind   kind = cudaMemcpyDeviceToHost    
)       
于 2013-09-16T04:34:10.887 回答