关于cudaError_t的返回值为77,怎么解决?

帅气的小王子 帅气的小王子 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
代码如下所示,
	
cudaMalloc((unsigned char **)&dev_bdecoded, CodeLength * sizeof(unsigned char));
cudaMalloc((int **)&dev_jc, (n + 1) * sizeof(int));
cudaMalloc((double **)&dev_LLR_extrinsic, nzmax * sizeof(double));
cudaMalloc((double **)&dev_LLR_intrinsic, CodeLength * sizeof(double));

cudaMemcpy(dev_bdecoded, bdecoded, CodeLength * sizeof(unsigned char), cudaMemcpyHostToDevice);
cudaMemcpy(dev_jc, jc, (n + 1) * sizeof(int), cudaMemcpyHostToDevice);
cudaMemcpy(dev_LLR_intrinsic, LLR_intrinsic, CodeLength * sizeof(double), cudaMemcpyHostToDevice);

threadsPerBlock = 256;
blocksPerGrid = (n + threadsPerBlock - 1) / threadsPerBlock;
Kernel1<<<blocksPerGrid,threadsPerBlock>>>(dev_bdecoded, dev_jc, dev_LLR_extrinsic, dev_LLR_intrinsic);
cudaStatus = cudaDeviceSynchronize();
if (cudaStatus != cudaSuccess) {
fprintf(stderr, "cudaDeviceSynchronize returned error code %d after launching addKernel!\n", cudaStatus);
}

其中bdecoded,jc,LLR_intrinsic是作为参数传递进来的指针。
内核函数如下

__global__ void Kernel1(unsigned char *dev_bdecoded, int *dev_jc, double *dev_LLR_extrinsic, double *dev_LLR_intrinsic)
{
int i = blockDim.x * blockIdx.x + threadIdx.x;
int j;
dev_bdecoded[i] = 0;
for (j = dev_jc[i]; j < dev_jc[i + 1]; j++)
dev_LLR_extrinsic[j] = dev_LLR_intrinsic[i];
}

在上面cudaStatus的返回值为77,

/**
* The device encountered a load or store instruction on an invalid memory address.
* The context cannot be used, so it must be destroyed (and a new one should be created).
* All existing device memory allocations from this context are invalid
* and must be reconstructed if the program is to continue using CUDA.
*/
cudaErrorIllegalAddress = 77,

去查了下解释说是内存问题,如上面所示,我想知道该如何解决这个问题?
...全文
评论 5
收藏 已收藏
分享
返回顶部
帅气的小王子
CUDA 591 成员 2,925 内容