cudaMemcpy problem - pass vector data to the funcion

Hello everyone,

I have the following problem in my C++ code. I think it is pretty basic, but I have no clue how to avoid this:

  1. I have 1D vector filled with data:
    vector image;

  2. Then I allocate memory on GPU (works fine!).
    double *d_image;
    cudaMalloc(&d_image,sizeof(double)*image.size());

  3. Here’s the problem:
    cudaMemcpy(d_image,&image,sizeof(double)*image.size(),cudaMemcpyHostToDevice));

The error comes out:
“Unhandled exception at 0x52858b34 in 2ndcuda.exe: 0xC0000005: Access violation reading location 0x002a1000.”

How to solve this?
Michał

See http://stackoverflow.com/questions/6485496/how-to-get-stdvector-pointer-to-the-raw-data