fix: blackwell nvapi temps parsing (#1096)

* fix: blackwell nvapi temps parsing

* chore: make the checks more reliable

---------

Co-authored-by: Ilya Zlobintsev <ilya.zl@protonmail.com>
This commit is contained in:
Roman Makarov
2026-06-29 20:53:29 +03:00
committed by GitHub
co-authored by Ilya Zlobintsev
parent 5613ccbcd5
commit 3ea235aca1
2 changed files with 21 additions and 6 deletions
@@ -733,11 +733,13 @@ impl GpuController for NvidiaGpuController {
let mut voltage = None;
if let Some((nvapi, handle)) = self.nvapi.as_ref() {
let arch = device.architecture().ok();
unsafe {
if let Some(mask) = self.nvapi_thermals_mask
&& let Ok(thermals) = nvapi.get_thermals(*handle, mask)
{
if let Some(hotspot) = thermals.hotspot() {
if let Some(hotspot) = thermals.hotspot(arch.as_ref()) {
temps.insert(
"GPU Hotspot".to_owned(),
TemperatureEntry {
@@ -752,7 +754,12 @@ impl GpuController for NvidiaGpuController {
);
}
if let Some(vram) = thermals.vram() {
let vram_type = self
.driver_handle
.as_ref()
.and_then(|driver| driver.get_ram_type().ok());
if let Some(vram) = thermals.vram(vram_type) {
temps.insert(
"VRAM".to_owned(),
TemperatureEntry {
@@ -10,6 +10,7 @@ use crate::bindings::nvidia::{
NvU8, NvU32,
};
use anyhow::{Context, bail};
use nvml_wrapper::enums::device::DeviceArchitecture;
use std::{
ffi::{CStr, c_char},
mem::{self, transmute},
@@ -318,12 +319,19 @@ impl NvApiThermals {
.filter(|&value| value > 0 && value < 255)
}
pub fn hotspot(&self) -> Option<i32> {
self.get_value(9)
pub fn hotspot(&self, arch: Option<&DeviceArchitecture>) -> Option<i32> {
if arch.is_some_and(|arch| arch.as_c() >= DeviceArchitecture::Blackwell.as_c()) {
None
} else {
self.get_value(9)
}
}
pub fn vram(&self) -> Option<i32> {
self.get_value(15)
pub fn vram(&self, vram_type: Option<&str>) -> Option<i32> {
match vram_type {
Some("GDDR7") => self.get_value(10),
_ => self.get_value(15),
}
}
}