nvjpegEncodeImage 4K image with random data crash at quality 100 issue

Hi all.

I’m getting NVJPEG_STATUS_EXECUTION_FAILED errors when doing a 4K image encode but only at jpeg quality 100:

    for(int t=0; t<10; ++t)
    {
        nvjpegHandle_t nv_handle;
        nvjpegEncoderState_t nv_enc_state;
        nvjpegEncoderParams_t nv_enc_params;

        nvjpegCreateSimple(&nv_handle);
        nvjpegEncoderStateCreate(nv_handle, &nv_enc_state, 0);
        nvjpegEncoderParamsCreate(nv_handle, &nv_enc_params, 0);

        int width = 4096;
        int height = 2160;

        srand(4771);

        std::vector<unsigned char> rand_data(width*height*3);
        for(int i=0; i<rand_data.size(); ++i){
            rand_data[i] = rand()%255;
        }

        void* device_ptr;
        cudaMalloc(&device_ptr, width*height*3);
        cudaMemcpy(device_ptr, rand_data.data(), rand_data.size(), cudaMemcpyHostToDevice);

        nvjpegImage_t nv_image;
        nv_image.channel[0] = (unsigned char*)device_ptr;
        nv_image.pitch[0] = width*3;

        nvjpegEncoderParamsSetQuality(nv_enc_params, 100, 0);

        nvjpegEncoderParamsSetSamplingFactors(nv_enc_params, NVJPEG_CSS_444, 0);
        auto er0 = nvjpegEncodeImage(nv_handle, nv_enc_state, nv_enc_params, &nv_image, NVJPEG_INPUT_RGBI, width, height, 0);
        if(er0 != NVJPEG_STATUS_SUCCESS){
            std::cout << "er0: BOOM! !NVJPEG_STATUS_SUCCESS: " << er0 << std::endl; 
            // NVJPEG_STATUS_EXECUTION_FAILED here
        }
        
        size_t length = 0;
        nvjpegEncodeRetrieveBitstream(nv_handle, nv_enc_state, NULL, &length, 0);
        cudaStreamSynchronize(0);

        std::vector<unsigned char> data(length);
        auto er1 = nvjpegEncodeRetrieveBitstream(nv_handle, nv_enc_state, data.data(), &length, 0);
        if(er1 != NVJPEG_STATUS_SUCCESS){
            std::cout << "er1: BOOM! !NVJPEG_STATUS_SUCCESS: " << er1 << std::endl;
        }

        nvjpegEncoderParamsDestroy(nv_enc_params);
        nvjpegEncoderStateDestroy(nv_enc_state);
        nvjpegDestroy(nv_handle);
    }

I’m guessing this is unexpected. It works for an uninitialized image (comment out the cudaMemcpy and it works) or my regular non-random test image. Is this a known issue?

(using cuda SDK 11.4.0, Windows, Visual Studio 2017 version 15.9.3, Driver Version 471.11, Quadro P5000)

Cheers