title: Launch out of resources
body: <p>I wrote the following simple CUDA kernel:</p>
  
  <pre><code>__global__ void pr_kernel(float* O, const float* I, const float* W, int N)
  {
    int x = threadIdx.x;
    float sum;
    int i;
    if (x &lt; N) {
      for (i = 0; i &lt; N; i++) {
        if (i == x) continue;
        sum += W[x*N+i] * I[x];
      }
      O[x] = (0.15 / N) + 0.85 * sum;
    }
  }
  </code></pre>
  
  <p>The variables are allocated in Python as follows:</p>
  
  <pre><code>N      = np.int32(4)
  W      = np.float32(np.asarray(
           [0, 1, 0, 1, 1, 0, 1, 1, 
           0, 1, 0, 1,1, 1, 0]))
  I      = np.float32(np.asarray(
           [0.25, 0.25, 0.25, 0.25]))
  O      = np.float32(np.zeros(N))
  </code></pre>
  
  <p>I'm transferring the variables using <code>gpuarray.to_gpu</code>, and I'm calling the kernel on a Tesla C2070 with the following line:</p>
  
  <pre><code>pr_kernel(O_d, I_d, W_d, N_d, block=blocksize, grid=gridsize)
  </code></pre>
  
  <p>Where:</p>
  
  <pre><code>blocksize = (128, 1, 1)
  gridsize = (1, 1)
  </code></pre>
  
  <p>I get the error message:</p>
  
  <pre><code>pycuda.driver.LaunchError: cuLaunchKernel failed: launch out of resources.
  </code></pre>
  
  <p>This happens even if I reduce blocksize to something like <code>(8, 1, 1)</code>. I can run other CUDA programs on the GPU with a blocksize of <code>(512, 1, 1)</code> so I'm confident this is not due to a GPU configuration issue.</p>
  
  <p>What am I doing wrong? Thanks for any help.</p>