目前由於某種原因,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