Monitoring NVENC hardware (Active or idle)

3.1k views Asked by At

we can query the available GPU with nvenc hardware like this:

     cuResult = cuInit(0);

if (cuResult != CUDA_SUCCESS)
{
    printf(">> GetNumberEncoders() - cuInit() failed error:0x%x\n", cuResult);
    exit(EXIT_FAILURE);
}

checkCudaErrors(cuDeviceGetCount(&deviceCount));

if (deviceCount == 0)
{
    printf(">> GetNumberEncoders() - reports no devices available that support CUDA\n");
    exit(EXIT_FAILURE);
}
else
{
    printf(">> GetNumberEncoders() has detected %d CUDA capable GPU device(s) <<\n", deviceCount);

    for (int currentDevice=0; currentDevice < deviceCount; currentDevice++)
    {
        checkCudaErrors(cuDeviceGet(&cuDevice, currentDevice));
        checkCudaErrors(cuDeviceGetName(gpu_name, 100, cuDevice));
        checkCudaErrors(cuDeviceComputeCapability(&SMmajor, &SMminor, currentDevice));
        printf("  [ GPU #%d - < %s > has Compute SM %d.%d, NVENC %s ]\n",
               currentDevice, gpu_name, SMmajor, SMminor,
               (((SMmajor << 4) + SMminor) >= 0x30) ? "Available" : "Not Available");

        if (((SMmajor << 4) + SMminor) >= 0x30)
        {
            encoderInfo[NVENC_devices].device = currentDevice;
            strcpy(encoderInfo[NVENC_devices].gpu_name, gpu_name);
            NVENC_devices++;
        }
    }
}

I have 8 GPU whit NVENC capability:

How can we check that specific NVENC hardware is now running or Idle. Is there any way to monitoring NVENC hardware ?

What about specific NVENC API function "OR" CUDA Driver or API functions that help me to find out which GPU or NVENC hardware is Idle?

NOTE: I know that CUDA and NVENC hardware are completely separate things but I am looking for Direct or Indirect (using Cuda API like using Cuda for specifying the available NVENC hardware) way for checking specific NVENC's status ???

2

There are 2 answers

3
Farzad Salimi Jazi On BEST ANSWER

you can monitor your NVENC hardware is Active or not in a indirect way using this command

nvidia-smi 

to see specific NVENC hardware is busy or idle, because when you want to use specific NVENC you should create a cuda thread on that GPU first, and use its memory too, so by checking the status of the GPU we can extend it to its NVENC hardware.

1
Robert Crovella On

Regarding this question:

What about specific ... CUDA Driver or API functions that help me to find out which ... NVENC hardware is Idle?

There are none.

NVENC and CUDA are orthogonal. The APIs to access and manage CUDA are completely separate from the APIs to access and manage NVENC. The code you've shown here identifies what GPUs are in the system, and happens to use the CUDA API to do that, but your question otherwise has nothing to do with CUDA. There are no CUDA API functions that will allow you to do anything with NVENC hardware.

Ultimately, managing the NVENC hardware is the responsibility of the client application that is using the NVENC API. This client application can easily make a busy/non-busy status available upstream to other applications if desired (since it knows the individual status of the hardware it is managing.