WEIRD cudaMemcpy error
Please help me, I don't know what I'm doing wrong.

I'm using the MACRO HANDLE_ERROR to check where my program is not working and it seems that some of the cudaMemcpy calls are not working 'cuz I'm getting this error:

"unspecified launch failure in X.cu at line 198"

and that line is :

[b]HANDLE_ERROR( cudaMemcpy( id, dev_id, sizeof(int), cudaMemcpyDeviceToHost ) );[/b]

the weird part is that I've already reserve memory for both id and dev_id before that cudaMemcpy call here is a part of my code:

...
int *id;
id = (int*)malloc(sizeof(int));
...
HANDLE_ERROR( cudaMalloc( (void**)&dev_id, sizeof(int) ) );
...
recognize<<<blocks,threads>>>(dev_red, dev_redVec, dev_cmp, dev_con, dev_ptr, dev_id);
...
HANDLE_ERROR( cudaMemcpy( id, dev_id, sizeof(int), cudaMemcpyDeviceToHost ) );
HANDLE_ERROR( cudaMemcpy( MRED, dev_red, *tamRed * sizeof(int), cudaMemcpyDeviceToHost ) );
HANDLE_ERROR( cudaMemcpy( MREDvec, dev_redVec, *tamRedV * sizeof(int), cudaMemcpyDeviceToHost ) );
...

I'm getting the same error in the other two calls of cudaMemcpy.

Please help me, I don't know what I'm doing wrong.
Please help me, I don't know what I'm doing wrong.



I'm using the MACRO HANDLE_ERROR to check where my program is not working and it seems that some of the cudaMemcpy calls are not working 'cuz I'm getting this error:



"unspecified launch failure in X.cu at line 198"



and that line is :



HANDLE_ERROR( cudaMemcpy( id, dev_id, sizeof(int), cudaMemcpyDeviceToHost ) );



the weird part is that I've already reserve memory for both id and dev_id before that cudaMemcpy call here is a part of my code:



...

int *id;

id = (int*)malloc(sizeof(int));

...

HANDLE_ERROR( cudaMalloc( (void**)&dev_id, sizeof(int) ) );

...

recognize<<<blocks,threads>>>(dev_red, dev_redVec, dev_cmp, dev_con, dev_ptr, dev_id);

...

HANDLE_ERROR( cudaMemcpy( id, dev_id, sizeof(int), cudaMemcpyDeviceToHost ) );

HANDLE_ERROR( cudaMemcpy( MRED, dev_red, *tamRed * sizeof(int), cudaMemcpyDeviceToHost ) );

HANDLE_ERROR( cudaMemcpy( MREDvec, dev_redVec, *tamRedV * sizeof(int), cudaMemcpyDeviceToHost ) );

...



I'm getting the same error in the other two calls of cudaMemcpy.



Please help me, I don't know what I'm doing wrong.

#1
Posted 11/15/2011 03:50 AM   
The error is not in the cudaMemcpy()s, but in the kernel(s) preceding them. Check them for illegal memory accesses etc. (out of bounds array accesses, mistakes in pointer arithmetic).
Also check the launch configuration (threads, blocks) and whether you are compiling for the right architecture.

EDIT: I see njuffa has already answered the same posting in a different thread. Please do not cross-post to multiple subforums.
The error is not in the cudaMemcpy()s, but in the kernel(s) preceding them. Check them for illegal memory accesses etc. (out of bounds array accesses, mistakes in pointer arithmetic).

Also check the launch configuration (threads, blocks) and whether you are compiling for the right architecture.



EDIT: I see njuffa has already answered the same posting in a different thread. Please do not cross-post to multiple subforums.

Always check return codes of CUDA calls for errors. Do not use __syncthreads() in conditional code unless the condition is guaranteed to evaluate identically for all threads of each block. Run your program under cuda-memcheck to detect stray memory accesses. If your kernel dies for larger problem sizes, it might exceed the runtime limit and trigger the watchdog timer.

#2
Posted 11/15/2011 10:13 AM   
thanks, and sorry I'm new in the forum, I solve it... in my kernel I was accessing and modifying dev_red more than *tamRed * sizeof(int) ...

Thanks again.
thanks, and sorry I'm new in the forum, I solve it... in my kernel I was accessing and modifying dev_red more than *tamRed * sizeof(int) ...



Thanks again.

#3
Posted 11/15/2011 11:46 AM   
Scroll To Top