0
我想使用cudaMemcpy設備內存中的數據複製memcpy的設備,這裏是我的代碼CUDA到設備錯誤
unsigned char* red_src ;
unsigned char* blue_src ;
unsigned char* green_src;
checkCudaErrors(cudaMalloc(&red_src, sizeof(unsigned char) * numRowsSource * numColsSource));
checkCudaErrors(cudaMalloc(&blue_src, sizeof(unsigned char) * numRowsSource * numColsSource));
checkCudaErrors(cudaMalloc(&green_src, sizeof(unsigned char) * numRowsSource * numColsSource));
//bla bla ..........
//initialization
compute_g<<<grid, block>>>(red_src, strictInteriorPixels,g_red, numRowsSource, numColsSource);
compute_g<<<grid, block>>>(blue_src, strictInteriorPixels,g_blue, numRowsSource, numColsSource);
compute_g<<<grid, block>>>(green_src, strictInteriorPixels,g_green, numRowsSource, numColsSource);
float *blendedValsRed_1 ;
float *blendedValsRed_2 ;
//set memory
checkCudaErrors(cudaMalloc(&blendedValsRed_1, sizeof(float) * numRowsSource * numColsSource));
checkCudaErrors(cudaMalloc(&blendedValsRed_2, sizeof(float) * numRowsSource * numColsSource));
checkCudaErrors(cudaMemcpy(blendedValsRed_1, red_src, sizeof(float) * numRowsSource * numColsSource,cudaMemcpyDeviceToDevice));
checkCudaErrors(cudaMemcpy(blendedValsRed_2, red_src, sizeof(float) * numRowsSource * numColsSource,cudaMemcpyDeviceToDevice));
它編譯,但是當我嘗試運行它,在cudaMemcpy
得到一個錯誤,說:
tintin ~/programming/cs344/Problem Sets/Problem Set 6 $ optirun ./HW6 source.png destination.png
CUDA error at: student_func.cu:365
invalid argument cudaMemcpy(blendedValsRed_1, red_src, sizeof(float) * numRowsSource * numColsSource,cudaMemcpyDeviceToDevice)
任何人都可以幫助,謝謝!