title: Binding a two dimensional array to the texture memory of a GPU with cudaBindTexture2D produces an error
body: <p>I am trying to execute a kernel in a compute capability 1.3 GPU using the CUDA API. Binding one dimensional arrays works as expected but the following code produces an error:</p>
  
  <pre><code>#include &lt;cuda.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define checkCudaErrors(err)           __checkCudaErrors (err, __FILE__, __LINE__)
  
  inline static void __checkCudaErrors( cudaError err, const char *file, const int line )     {
  
      if( cudaSuccess != err) {
          fprintf(stderr, "%s(%i) : CUDA Runtime API error %d: %s.\n", file, line, (int)err, cudaGetErrorString( err ) );
          exit(-1);
      }
  }
  
  texture&lt;int, cudaTextureType2D&gt; tex_transition;
  
  int main ( void ) {
  
      int m = 8, p_size = 100, alphabet = 20;
  
      size_t pitch;
  
      int *transition = ( int * ) malloc ( ( m * p_size + 1 ) * alphabet * sizeof ( int ) );
      memset ( transition, -1, ( m * p_size + 1 ) * alphabet * sizeof ( int ) );
  
      int *d_transition;
  
      checkCudaErrors ( cudaMallocPitch ( &amp;d_transition, &amp;pitch, alphabet * sizeof ( int ), ( m * p_size + 1 ) ) );
  
      checkCudaErrors ( cudaMemcpy2D ( d_transition, pitch, transition, alphabet * sizeof ( int ), alphabet * sizeof ( int ), ( m * p_size + 1 ), cudaMemcpyHostToDevice ) );
  
      cudaChannelFormatDesc desc = cudaCreateChannelDesc&lt;int&gt;();
      checkCudaErrors ( cudaBindTexture2D ( 0, tex_transition, d_transition, desc, alphabet * sizeof ( int ), ( m * p_size + 1 ), pitch ) );
  
      cudaFree ( d_transition );
  
      return 0;
  }
  </code></pre>
  
  <p>When executing i get the error "test.cu(33) : CUDA Runtime API error 11: invalid argument.
  ". By setting alphabet to 10 the error goes away. If i am not mistaken, each array bound to textures can have a maximum size of 65000 x 65000 words (in this case integers) but the <em>transition</em> array is far smaller.</p>