NVIDIA Management Library (NVML) is a robust API for monitoring and managing NVIDIA GPUs. One of its many features is the ability to retrieve the driver version of the NVIDIA GPU. This can be especially useful for debugging, system monitoring, or ensuring compatibility between the software and GPU driver. This tutorial explains how to get driver version of Nvidia GPU using NVML and C++.
The code initializes the NVML library to enable interaction with NVIDIA GPU hardware. It then retrieves the system's NVIDIA driver version using the nvmlSystemGetDriverVersion
function, storing the version string in a pre-allocated buffer. The driver version is printed to the console. Finally, the code shuts down the NVML library to release any resources it allocated during execution.
#include <iostream>
#include <nvml.h>
int main()
{
nvmlInit();
char version[NVML_SYSTEM_DRIVER_VERSION_BUFFER_SIZE];
nvmlSystemGetDriverVersion(version, NVML_SYSTEM_DRIVER_VERSION_BUFFER_SIZE);
std::cout << version << std::endl;
nvmlShutdown();
return 0;
}
The code should output something like:
555.58.02
Leave a Comment
Cancel reply