[問題] CUDA cudaMalloc 執行錯誤

看板C_and_CPP (C/C++)作者 (LDPC)時間12年前 (2013/07/27 12:03), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/2 (看更多)
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) MS VC2010 express 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) CUDA 問題(Question): float data[16384]; int ans_cuda[16384]; cudaMalloc((void**)&data_cuda, sizeof(float)*length); err = cudaGetLastError(); if( cudaSuccess != err) printf("Cuda error4: %s.\n", cudaGetErrorString(err) ); err = cudaMalloc((void**)&cuda , sizeof(int )*length); if( cudaSuccess != err) printf("Cuda error3: %s.\n",cudaGetErrorString(err) ); err = cudaMemcpy(data_cuda, data, sizeof(float)*length,cudaMemcpyHostToDevice); length =8192 cudaGetErrorString(err) 沒任何訊息 (應該ok?...) length =9216 cudaGetErrorString(err) 為 invalid argument 我的deviceQuery http://imgur.com/xVUeZTu
err = cudaMemcpy(ans_cuda, cuda, sizeof(int )*length, cudaMemcpyDeviceToHost); 所以計算出來的也同步一起對 或一起錯 另外想問 我的顯卡GT540M 每個block 最大的thread為1024 我想知道這種 dim3 dimGrid(1,1,1); dim3 dimBlock(BLOCK_SIZE, BLOCK_SIZE,BLOCK_SIZE); 根據我的device該怎麼設定 還有 該看哪裡可以知道 cudaMalloc 的最大size呢? 是 Total amount of shared memory per block: 49152 bytes 這行?? 程式碼(Code):(請善用置底文網頁, 記得排版) 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 112.105.78.136

07/27 14:51, , 1F
應該把變數設定成指標之後才配空間給他吧
07/27 14:51, 1F
文章代碼(AID): #1HyqQ4LS (C_and_CPP)
討論串 (同標題文章)
文章代碼(AID): #1HyqQ4LS (C_and_CPP)