How to get the GPU Architecture of a Device for CUVID?

1.2k views Asked by At

I am implementing a video decoder using NVidia's NvDec CUVID feature. According to chapter 2 of the (woefully inadequate) manual, decoding limits are specified by GPU architecture. ie, the maximum h265 horizontal resolution is 8192 on a GP10x, 4096 on a GP100 or less, and unsupported on any architecture less than GM206.

How do I use CUDA to detect such architectures? Am I supposed to infer it from compute capabilities or what? And if I'm supposed to infer it, is there a table of architectures vs compute capabilities?

1

There are 1 answers

0
halfelf On BEST ANSWER

Though there isn't a function that returns code name of GPU, NVIDIA provides cuvidGetDecoderCaps() API to let users query the capabilities of underlying hardware video decoder.

A detailed example of cuvidGetDecoderCaps() can be found in Video_Codec_SDK_x.x.x downloaded from nvenc official site. One example in Samples/NvDecodeD3D11/NvDecodeD3D11.cpp:

CUVIDEOFORMAT videoFormat = g_pVideoSource->format();
CUVIDDECODECAPS videoDecodeCaps = {};
videoDecodeCaps.eCodecType = videoFormat.codec;
videoDecodeCaps.eChromaFormat = videoFormat.chroma_format;
videoDecodeCaps.nBitDepthMinus8 = videoFormat.bit_depth_luma_minus8;
if (cuvidGetDecoderCaps(&videoDecodeCaps) != CUDA_SUCCESS)
{
    printf("cuvidGetDecoderCaps failed: %d\n", result);
    return;
}
if (!videoDecodeCaps.bIsSupported) {
    printf("Error: This video format isn't supported on the selected GPU.");
    exit(1);;
}