CUDA Question about cudaMemcpy

Hello everyone,in my program,I need to call cudaMemcpy() many times in a while{ },and I find that after I run program many times,the result of cudaMemcpy() in while{} is wrong,result in my total program is down.
Can you tell me why and how to resolve the issue? thanks.

Can you please post some code to reproduce the error? (otherwise it’s difficult to guess what has gone wrong) You can use the function checkCudaErrors that is found in helper_cuda.h to check whether there are any errors in allocation or data transfer. There are various reasons for which cudaMemcpy can fail; for instance there is cudaErrorInvalidDevicePointer. Have you previously allocated space on the device memory?