title: CUDA H.264 decoder initialization problems
body: <p>I am trying to develop multi-streaming H.264 video player based on cudaDecodeD3D9 example from NVIDIA GPU Computing SDK 4.2.</p>
  <p>Application works correctly with a few streams but it raises assertion (CUDA_ERROR_OUT_OF_MEMORY) in cuvidCreateDecoder function for 12 streams with resolution 800x600 or 9 streams with resolution 1920x1080. cudaMemGetInfo returns 387MB (for video card with 1GB) and 1.3Gb (for video card with 2GB) available memory. Does memory fragmentation cause this? How can I use available memory?</p>
  <pre><code>VideoDecoder::VideoDecoder(const CUVIDEOFORMAT &amp; rVideoFormat, 
                         CUcontext &amp;rContext, 
                         cudaVideoCreateFlags eCreateFlags, 
                         CUvideoctxlock &amp;vidCtxLock) 
  : m_VidCtxLock(vidCtxLock)
  {
  // get a copy of the CUDA context
  m_Context          = rContext;
  m_VideoCreateFlags = eCreateFlags;
  
  // Fill the decoder-create-info struct from the given video-format struct.
  memset(&amp;oVideoDecodeCreateInfo_, 0, sizeof(CUVIDDECODECREATEINFO));
          // Create video decoder
  oVideoDecodeCreateInfo_.CodecType           = rVideoFormat.codec;
  oVideoDecodeCreateInfo_.ulWidth             = rVideoFormat.coded_width;
  oVideoDecodeCreateInfo_.ulHeight            = rVideoFormat.coded_height;
  oVideoDecodeCreateInfo_.ulNumDecodeSurfaces = FrameQueue::cnMaximumSize;
  
          // Limit decode memory to 24MB (16M pixels at 4:2:0 = 24M bytes)
  while (oVideoDecodeCreateInfo_.ulNumDecodeSurfaces * rVideoFormat.coded_width * rVideoFormat.coded_height &gt; 16*1024*1024)
  {
      oVideoDecodeCreateInfo_.ulNumDecodeSurfaces--;
  }
  oVideoDecodeCreateInfo_.ChromaFormat        = rVideoFormat.chroma_format;
  oVideoDecodeCreateInfo_.OutputFormat        = cudaVideoSurfaceFormat_NV12;
  oVideoDecodeCreateInfo_.DeinterlaceMode     = cudaVideoDeinterlaceMode_Adaptive;
  
          // No scaling
  oVideoDecodeCreateInfo_.ulTargetWidth       = oVideoDecodeCreateInfo_.ulWidth;
  oVideoDecodeCreateInfo_.ulTargetHeight      = oVideoDecodeCreateInfo_.ulHeight;
  oVideoDecodeCreateInfo_.ulNumOutputSurfaces = MAX_FRAME_COUNT;  // We won't simultaneously map more than 8 surfaces
  oVideoDecodeCreateInfo_.ulCreationFlags     = m_VideoCreateFlags;
  oVideoDecodeCreateInfo_.vidLock             = m_VidCtxLock;
  
  size_t available, total;
  cudaMemGetInfo(&amp;available, &amp;total);
  
          // create the decoder
  CUresult oResult = cuvidCreateDecoder(&amp;oDecoder_, &amp;oVideoDecodeCreateInfo_);
  assert(CUDA_SUCCESS == oResult);
  }
  </code></pre>
  <p>Can cuvidCreateDecoder work with resolution over 1920x1080? When I try 2560x1920 stream cuvidCreateDecoder asserts CUDA_ERROR_INVALID_SOURCE.</p>
  <h3>My environment</h3>
  <ul>
  <li>Hardware: NVidia GTX 550 Ti 1Gb, NVidia GT 610 2Gb, driver version 306.23</li>
  <li>Windows 7 x64</li>
  <li>Visual Studio 2010 SP1</li>
  <li>Windows SDK 7.1</li>
  <li>NVIDIA GPU Computing Toolkit v.4.2, v.5.0</li>
  <li>NVIDIA GPU Computing SDK 4.2.</li>
  </ul>