NVIFR_ERROR_DX_DRIVER_FAILURE

OS: windows Server 2012 x64
GPU: NVIDIA GRID K520
Driver Version: 354.1 (Link: http://www.nvidia.com/download/driverResults.aspx/95515/en-us)

I am getting ID3D10Device by hooking into DXGISwapChain::Present() method and then This->GetDevice(IID_ID3D10Device, &ppDevice);

The problem is that g_pIFR->NvIFRSetUpH264HWEncoder(&params); returns -4 or NVIFR_ERROR_DX_DRIVER_FAILURE. Why is that? This works fine with DirectX 9

int InitNVIFR(ID3D10Device *g_pD3DDevice)
{
    HINSTANCE g_hNvIFRDll=NULL;
    NvIFRLibrary NvIFRLib;
    //! Load the NvIFR.dll library
    if(NULL == (g_hNvIFRDll = NvIFRLib.load()))
        return -1;

    //! 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;
    }

    for (DWORD i = 0; i < NUMFRAMESINFLIGHT; i++)
    {
        //! Create the events for allowing rendering to continue after a capture is complete
        g_aCanRenderEvents[i] = CreateEvent(NULL, TRUE, TRUE, NULL);    
    }
    g_hThreadQuitEvent = CreateEvent(NULL, TRUE, FALSE, NULL);

    //! 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.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);

    if (res != NVIFR_SUCCESS)
    {
        if (res == NVIFR_ERROR_INVALID_PARAM || res != NVIFR_ERROR_INVALID_PTR)
            gbx_error("NvIFR Buffer creation failed due to invalid params.\n");
        else
            gbx_error("Something is wrong with the driver, cannot initialize IFR buffers\n");
        return -1;
    }

    gbx_error("NVIDIA device configured\n");

    nvIfr_initialized = 1;
    return nvIfr_initialized;
}