作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试熟悉 cuSparse 库。在我的简单代码中,函数 cusparseSnnz 返回状态 6,即 CUSPARSE_STATUS_INTERNAL_ERROR。我认为 CUDA 驱动程序和 cuSparse 库已正确安装。如果有人可以帮助我,我将不胜感激。谢谢。
cusparseStatus_t status;
cusparseHandle_t handle=0;
cusparseMatDescr_t descr=0;
status = cusparseCreate(&handle);
if (status != CUSPARSE_STATUS_SUCCESS) {
cout << "CUSPARSE Library initialization failed" << endl;
}
status = cusparseCreateMatDescr(&descr);
if (status != CUSPARSE_STATUS_SUCCESS) {
cout << "Matrix descriptor initialization failed" << endl;
}
status = cusparseSetMatType(descr, CUSPARSE_MATRIX_TYPE_GENERAL);
if (status != CUSPARSE_STATUS_SUCCESS) {
cout << "cusparseSetMatType failed" << endl;
}
status = cusparseSetMatIndexBase(descr, CUSPARSE_INDEX_BASE_ZERO);
if (status != CUSPARSE_STATUS_SUCCESS) {
cout << "cusparseSetMatIndexBase failed" << endl;
}
int nnzPerRow[2];
int nnzTotal;
float tempf[6];
tempf[0] = 1.0;
tempf[1] = 0.0;
tempf[2] = 3.4;
tempf[3] = 0.0;
tempf[4] = 2.2;
tempf[5] = 8.6;
float* d_Temp;
cudaMalloc((void**)&d_Temp, sizeof(float)*6);
cudaMemcpy(d_Temp, tempf, sizeof(float)*6, cudaMemcpyHostToDevice);
status = cusparseSnnz(handle, CUSPARSE_DIRECTION_ROW, 2, 3, descr, d_Temp, 2, nnzPerRow, &nnzTotal);
if (status != CUSPARSE_STATUS_SUCCESS) {
cout << "nnz calculation failed" << endl;
cout << "status = " << status << endl;
}
cout << "nnzPerRow[0] = " << nnzPerRow[0] << endl;
cout << "nnzPerRow[1] = " << nnzPerRow[1] << endl;
最佳答案
我刚刚发现出了什么问题。 nnzPerRow 需要位于设备中。
int nnzPerRow[2];
int* nnzPerRow=0;
checkCudaErrors(cudaMalloc((void**)&nnzPerRow, sizeof(int)*2));
关于cuda - CUSPARSE_STATUS_INTERNAL_ERROR 与 cuSparse cusparseSnnz 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12738305/
我正在尝试熟悉 cuSparse 库。在我的简单代码中,函数 cusparseSnnz 返回状态 6,即 CUSPARSE_STATUS_INTERNAL_ERROR。我认为 CUDA 驱动程序和 c
我是一名优秀的程序员,十分优秀!