ffmpeg Video transcoding not working with MPS server

When running ffmpeg transcode stream with MPS server started I’m getting the following error:
[h264_cuvid @ 0x55baf17ea0c0] cuvidCreateDecoder(&cudec, &cuinfo) failed -> CUDA_ERROR_INVALID_DEVICE: invalid device ordinal

The ffmpeg command that I’m running is:
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i -map 0:0 -r:v 1 -c:v h264_nvenc -threads 1 -y
I;m running this on an NVIDIA GeForce 1070 GPU on Ubuntu 16.04. The CUDA version is 8.0.

If there is no MPS server running the same command executes with no errors. Is this a limitation in MPS server or in ffmpeg? Has anyone successfully tried running ffmpeg with MPS server before?

Thanks in advance.

Just to be clear, but MPS, do you mean CUDA multi-process service?

Yes that is correct, CUDA Multiprocess service.

I also find NVDEC SDK cannot work with MPS server.
When I execute NVDEC sample like this:

./AppDec -i input.mp4  -resize 640x480 -o output.mp4

, I get the following error:

GPU in use: GeForce GTX 1060 6GB
Decode with demuxing.
[INFO ][11:30:49] Media format: QuickTime / MOV (mov,mp4,m4a,3gp,3g2,mj2)
Session Deinitialization Time: 0 ms
HandleVideoSequence : cuvidGetDecoderCaps(&decodecaps) returned error 101 at …/…/NvCodec/NvDecoder/NvDecoder.cpp:155

When I execute the same sample without MPS server, it works well.

Hi, I’m trying to use MPS with 418.67/ffmpeg4.2 driver but getting this messages:
[h264_cuvid @ 0x2a10ec0] ctx->cvdl->cuvidGetDecoderCaps(&ctx->caps8) failed -> CUDA_ERROR_INVALID_DEVICE: invalid device ordinal
[h264_cuvid @ 0x2a10ec0] ctx->cvdl->cuvidGetDecoderCaps(&ctx->caps10) failed -> CUDA_ERROR_INVALID_DEVICE: invalid device ordinal
[h264_cuvid @ 0x2a10ec0] ctx->cvdl->cuvidGetDecoderCaps(&ctx->caps12) failed -> CUDA_ERROR_INVALID_DEVICE: invalid device ordinal

Any idea what could be the issue ?