GRID SDK 2.3.7, NvIFRSetUpH264HWEncoder failure

NvIFRSetUpH264HWEncoder(&params) fails on some games. It does not return or throw an exception.

//! Set up the H.264 encoder and target buffers
	DWORD dwBitRate720p = 3000000;
	double  dBitRate = double(dwBitRate720p);
    NvIFR_H264HWEncoder_Config encodeConfig = {0};
    encodeConfig.dwVersion = NVIFR_H264HWENCODER_CONFIG_VER;
    encodeConfig.dwAvgBitRate = (DWORD)dBitRate;
	encodeConfig.dwFrameRateDen = 1;
	encodeConfig.dwFrameRateNum = 30;
    encodeConfig.dwPeakBitRate = (encodeConfig.dwAvgBitRate * 12/10);   // +20%
	encodeConfig.dwGOPLength = 0xffffffff;
	//encodeConfig.bRepeatSPSPPSHeader = true;
	encodeConfig.bEnableIntraRefresh = 1;
	encodeConfig.dwMaxNumRefFrames = 16;
	encodeConfig.dwProfile = 100;
	encodeConfig.eRateControl = NVIFR_H264_ENC_PARAMS_RC_2_PASS_QUALITY;
	encodeConfig.ePresetConfig = NVIFR_H264_PRESET_LOW_LATENCY_HQ;
	encodeConfig.dwQP = 26;
	encodeConfig.bEnableAQ = 1;

	NVIFR_SETUP_H264_PARAMS params = {0};
    params.dwVersion = NVIFR_SETUP_H264_PARAMS_VER;
    params.pEncodeConfig = &encodeConfig;
	params.eStreamStereoFormat = NVIFR_H264_STEREO_NONE;
    params.dwNBuffers = NUMFRAMESINFLIGHT;
	params.dwBSMaxSize = 256*1024;
    params.ppPageLockedBitStreamBuffers = g_pMainBuffer;
	params.ppEncodeCompletionEvents = g_hCaptureCompleteEvent;	
	params.dwTargetHeight = video_source_out_height(0);
	params.dwTargetWidth = video_source_out_width(0);

    NVIFRRESULT res = g_pIFR->NvIFRSetUpH264HWEncoder(&params);

Also NvIFRLib.create() also shows the same behavior some times. Execution gets stuck on NvIFRLib.create() and does not return or throw any exception.

//! Create the NvIFRToH264HWEncoder object
g_pIFR = (NvIFRToH264HWEncoder *) NvIFRLib.create (g_pD3DDevice, NVIFR_TOH264HWENCODER);
if(NULL == g_pIFR)
{
   gbx_error("Failed to create the NvIFRToH264HWEncoder\r\n");
   return -1;
}

What are we doing wrong?

This works fine for other games but not for Fiesta, we think this issue is with the SDK.
GRID SDK version 4.0.27 has been provided on partners.nvidia.com but it is for Maxwell only. While we are using Kepler K520. Is latest GRID SDK also available for Kepler?