How to Get The Actual Fan Speed of Quadro

Hi.

Would you please tell me how to get the actual fan speed of Quadro GPU Card?
I understand that the nvmlDeviceGetFanSpeed function returns the intended fan speed not the actual speed.
Because the NVIDIA X Server Settings GUI shows the actual fan speed (when I blocked the fan, the value decreased.), I think there is a way to get the actual fan speed.

Thanks.

There are TWO different API - NVML and XNVCtrl.

NVML is public API distributed with CUDA (docs - https://docs.nvidia.com/deploy/nvml-api/index.html). NVML communicates with driver directly (nvidia-smi is based on this API). But it covers only 1/3 of “features”.

XNVCtrl is private API. It is working only when Xorg graphics driver is loaded and communicate with Xprotocol extensions with this driver (API level is expandable with “coolbits” settings) (nvidia-settings is based on this API). NVidia published “special” version of “nvidia-settings” (https://github.com/NVIDIA/nvidia-settings) but true XNVCtrl protocol is unimplemented and waiting to implement new APIs in old NVML:
https://github.com/NVIDIA/nvidia-settings/blob/master/src/libXNVCtrlAttributes/NvCtrlAttributesNvml.c#L1073-L1079
(check the difference between NV_CTRL_THERMAL_COOLER_LEVEL (eg. nvmlDeviceGetFanSpeed()) and NV_CTRL_THERMAL_COOLER_SPEED (unimplemented) - https://github.com/NVIDIA/nvidia-settings/blob/master/src/libXNVCtrl/NVCtrl.h)
And many many other unimplemented …
https://github.com/NVIDIA/nvidia-settings/blob/master/src/libXNVCtrlAttributes/NvCtrlAttributesNvml.c#L534-L545
https://github.com/NVIDIA/nvidia-settings/blob/master/src/libXNVCtrlAttributes/NvCtrlAttributesNvml.c#L795-L868
https://github.com/NVIDIA/nvidia-settings/blob/master/src/libXNVCtrlAttributes/NvCtrlAttributesNvml.c#L1181-L1196

From nvml.h:

/**
 * Retrieves the intended operating speed of the device's fan.
 *
[b] * Note: The reported speed is the intended fan speed.  If the fan is physically blocked and unable to spin, the
 * output will not match the actual fan speed.[/b]
 * 
 * For all discrete products with dedicated fans.
 *
 * The fan speed is expressed as a percent of the maximum, i.e. full speed is 100%.
 *
 * @param device                               The identifier of the target device
 * @param speed                                Reference in which to return the fan speed percentage
 * 
 * @return 
 *         - \ref NVML_SUCCESS                 if \a speed has been set
 *         - \ref NVML_ERROR_UNINITIALIZED     if the library has not been successfully initialized
 *         - \ref NVML_ERROR_INVALID_ARGUMENT  if \a device is invalid or \a speed is NULL
 *         - \ref NVML_ERROR_NOT_SUPPORTED     if the device does not have a fan
 *         - \ref NVML_ERROR_GPU_IS_LOST       if the target GPU has fallen off the bus or is otherwise inaccessible
 *         - \ref NVML_ERROR_UNKNOWN           on any unexpected error
 */
nvmlReturn_t DECLDIR nvmlDeviceGetFanSpeed(nvmlDevice_t device, unsigned int *speed);

/**
 * Retrieves the intended operating speed of the device's specified fan.
 *
[b] * Note: The reported speed is the intended fan speed. If the fan is physically blocked and unable to spin, the
 * output will not match the actual fan speed.[/b]
 *
 * For all discrete products with dedicated fans.
 *
 * The fan speed is expressed as a percentage of the maximum, i.e. full speed is 100%
 *
 * @param device                                The identifier of the target device
 * @param fan                                   The index of the target fan, zero indexed.
 * @param speed                                 Reference in which to return the fan speed percentage
 *
 * @return
 *        - \ref NVML_SUCCESS                   if \a speed has been set
 *        - \ref NVML_ERROR_UNINITIALIZED       if the library has not been successfully initialized
 *        - \ref NVML_ERROR_INVALID_ARGUMENT    if \a device is invalid, \a fan is not an acceptable index, or \a speed is NULL
 *        - \ref NVML_ERROR_NOT_SUPPORTED       if the device does not have a fan or is newer than Maxwell
 *        - \ref NVML_ERROR_GPU_IS_LOST         if the target GPU has fallen off the bus or is otherwise inaccessible
 *        - \ref NVML_ERROR_UNKNOWN             on any unexpected error
 */
nvmlReturn_t DECLDIR nvmlDeviceGetFanSpeed_v2(nvmlDevice_t device, unsigned int fan, unsigned int * speed);