title: cudaMalloc caused "unknown errors" in CUDA
body: <p>I am trying to follow the CUDA By Example book, and just started to try some of their examples. </p>
  
  <p>The "hello world" program ran without a problem. For the following program, it compiled fine, but when I executed, I got the message:</p>
  
  <p>unknown error in simple_kernel_params.cu at line 26</p>
  
  <p>Line 26 is the first cudaMalloc command.</p>
  
  <p>Could someone with experience provide some hints how I should troubleshoot this? Thanks a lot!</p>
  
  <pre><code>/*
   * Copyright 1993-2010 NVIDIA Corporation.  All rights reserved.
   *
   * NVIDIA Corporation and its licensors retain all intellectual property and 
   * proprietary rights in and to this software and related documentation. 
   * Any use, reproduction, disclosure, or distribution of this software 
   * and related documentation without an express license agreement from
   * NVIDIA Corporation is strictly prohibited.
   *
   * Please refer to the applicable NVIDIA end user license agreement (EULA) 
   * associated with this source code for terms and conditions that govern 
   * your use of this NVIDIA software.
   * 
   */
  
  
  #include "../common/book.h"
  
  __global__ void add( int a, int b, int *c ) {
      *c = a + b;
  }
  
  int main( void ) {
      int c;
      int *dev_c;
      HANDLE_ERROR( cudaMalloc( (void**)&amp;dev_c, sizeof(int) ) );
  
      add&lt;&lt;&lt;1,1&gt;&gt;&gt;( 2, 7, dev_c );
  
      HANDLE_ERROR( cudaMemcpy( &amp;c, dev_c, sizeof(int),
                            cudaMemcpyDeviceToHost ) );
      printf( "2 + 7 = %d\n", c );
      HANDLE_ERROR( cudaFree( dev_c ) );
  
      return 0;
  }
  </code></pre>