title: cuda segmentation fault
body: <p>I am programming with cuda in C. I got a segmentation fault with the code lines following:</p>
  
  <pre><code>int width = 0;
  int height = 0;
  
  // load input image
  unsigned char * image_input = loadFile(&amp;width, &amp;height, "test.bmp");
  
  // allocate memory for output
  unsigned char * image_output = (unsigned char *) malloc(width*height*sizeof(unsigned char));
  
  // set the size of the input and out array 2D
  int size = width*height*sizeof(int);
  
  // Allocate space on the GPU for input and output
  char* GPU_input = 0;
  char* GPU_output = 0;   
  
  cudaMalloc(&amp;GPU_input, size);       
  cudaMalloc(&amp;GPU_output, size);
  
  // Copy the input data to the GPU (host to device)
  cudaMemcpy(GPU_input, image_input, size, cudaMemcpyHostToDevice); //segmentation fault here
  </code></pre>
  
  <p>Any idea?</p>
  
  <p>Thanks in advance.</p>