目前由于某种原因,cudaMalloc将errno设置为17,尽管返回了cudaSuccess。我一直在搜索互联网,但我的google foo没有给我带来任何启发,所以我决定询问堆栈溢出的人。cudaMalloc设置errno尽管返回cudaSuccess
这里是我的输出
ERROR: What is not going down, ERRSTR: Success, ERRNO 0
ERROR: What is going on here?, ERRSTR: File exists, ERRNO 17
这里是我的代码(有些是至少)
//headers
#define CheckError(MESSAGE) do { fprintf(stderr,"ERROR: %s, ERRSTR: %s, ERRNO %i\n",MESSAGE,strerror(errno),errno); } while(0);
#define CudaSafeCall(err) __cudaSafeCall(err, __FILE__, __LINE__)
#define ARRAY_LENGTH (1000000)
#define ARRAY_ELEMENT_SIZE (sizeof(int))
#define ARRAY_SIZE ((size_t)ARRAY_ELEMENT_SIZE * ARRAY_LENGTH)
inline void __cudaSafeCall(cudaError err, const char *file, const int line)
{
if (cudaSuccess != err)
{
fprintf(stderr, "cudaSafeCall() failed at %s:%i : %s\n",
file, line, cudaGetErrorString(err));
exit(-1);
}
return;
}
int main(int argc,char* argv[])
{
..... Other Code ......
int *device_array;
CheckError("What is not going on here.");
CudaSafeCall(cudaMalloc((void**)&device_array,ARRAY_SIZE));
CheckError("What is going on here?");
..... Other Code ......
}
有没有人有什么anyidea可能是怎么回事?眼下ARRAY_SIZE设置为4亿美元,但同样的问题显示出来,当它是400
您确定错误来自CUDA吗?对我来说,看起来错误来自C++(主机)端,并且与CUDA运行时无关,因为CUDA运行时会给你一个cudaError。 – Turing85 2014-11-05 20:29:00
我不确定错误来自哪里,如果不是来自cuda。我不太了解errno如何工作,但还有什么可能导致它被设置?其他进程可能是原因吗? – robbert229 2014-11-05 20:32:44
我相当肯定,错误不是来自CUDA运行时(尽管它可能是由CUDA引起的)。 – Turing85 2014-11-05 20:48:49