Get NVML Version using C++

Get NVML Version using C++

NVML (NVIDIA Management Library) is a C-based library for NVIDIA GPU management and monitoring. By knowing the NVML version, you can ensure compatibility with specific features or debugging tools. This tutorial demonstrates how to get NVML version using C++.

The code initializes the NVML library to enable interaction with NVIDIA GPU hardware. It retrieves the version of the NVML library itself by calling nvmlSystemGetNVMLVersion, storing the version string in a pre-allocated buffer. This version string is then printed to the console. Finally, the code shuts down the NVML library to release any resources allocated during its operation.

#include <iostream>
#include <nvml.h>

int main()
{
    nvmlInit();

    char version[NVML_SYSTEM_NVML_VERSION_BUFFER_SIZE];
    nvmlSystemGetNVMLVersion(version, NVML_SYSTEM_NVML_VERSION_BUFFER_SIZE);

    std::cout << version << std::endl;

    nvmlShutdown();

    return 0;
}

When you run this code, you'll get an output similar to the following, depending on the NVML version installed on your system:

12.555.58.02

Leave a Comment

Cancel reply

Your email address will not be published.