Getting cuerror Invalid device pointer

unsigned char *uc_d_image=NULL;

code…

When I look uc_d_image it says: 0x00000000
Why Bad Ptr?? Is that a problem? :unsure:
//allocate
cudaMallocPitch((void**)&uc_d_image, &pitchImage, imageSizeX, imageSizeY);

Some Before and after cudaMallocPitch of uc_d_image:
Before:

  •   uc_d_image	0x00000000 <Bad Ptr>	unsigned char *
    

After:

  •   uc_d_image	0x05720000 ""	unsigned char *
    
  •   uc_d_image	0x05720000 "#"	unsigned char *
    
  •   uc_d_image	0x00000000 <Bad Ptr>	unsigned char *
    

after allocate, usually disappear but some times, still there, and some times cudaMallocPitch seems to do nothing, because the address remain the same! Then I get this error:

cerror cudaErrorLaunchFailure cudaError

Why?? The computer freezes for some time when that happens.

code…

//free
if (uc_d_image!=NULL)
cudaFree(uc_d_image);

if ((cerror = cudaGetLastError()))
{
	const char *c;
	c = cudaGetErrorString((cudaError_t) cerror);
}

I get error 17, Invalid device pointer

why?

thanks… External Image

A NULL pointer is most certainly an invalid device pointer, explaining that error message right off.

As to why your pointer changes from a supposed valid 0x05720000 to NULL at some point, there must be a problem in your code. Step through the calls in between those in the debugger and see which one creates the problem. For instance, if you had an out of bounds memory array access, this might happen at random locations in the code. valgrind is also a powerful tool for debugging these types of problems.

It turns (or stay) to null after cudaMallocPitch. I call cudaMallocPitch and nothing happens, the last cudaerror for this case is: cudaErrorLaunchFailure External Media