HELP PELASE! CudaMallocPitch freezing

So I am trying to use cudamallocpitch and my code keeps freezing when it tries to malloc. My code is:

[codebox]/Main mex function/

void mexFunction(int nlhs, mxArray *plhs, int nrhs, const mxArray *prhs)


int    N;

double *vhA, *vhC;

size_t a_pitch;

size_t c_pitch;


/*GPU variables:*/

double *dA, *dC;

/* Find the dimensions of the vector */

N = mxGetN(prhs[0]);

/*N = mxGetM(prhs[0]);*/

/Create result vector/

plhs[0] = mxCreateDoubleMatrix(N,N,mxREAL);

/* Retrieve the input data */

vhA = mxGetPr(prhs[0]);

vhC = mxGetPr(plhs[0]);

printf(“Calling CUDA mallocs…\n”);


cudaMallocPitch((void**)&dA,&a_pitch, N*sizeof(double),N);

cudaMallocPitch((void**)&dC,&c_pitch, N*sizeof(double),N);


It freezes right after printing “Calling CUDA mallocs”.

Any ideas?