Skip to content

Commit 3cf86e7

Browse files
committed
--versions: Add support for dumping NVIDIA graphics info
Trying it out with thunderbolt eGPUs Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 6dd82ff commit 3cf86e7

3 files changed

Lines changed: 210 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 121 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

framework_lib/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ clap-num = { version = "1.2.0" }
5252
clap-verbosity-flag = { version = "2.2.1" }
5353
windows-version = "0.1.4"
5454
winreg = "0.55.0"
55+
nvml-wrapper = "0.11.0"
5556

5657
[target.'cfg(unix)'.dependencies]
5758
libc = "0.2.155"
@@ -62,6 +63,7 @@ env_logger = "0.11"
6263
clap = { version = "4.5", features = ["derive", "cargo"] }
6364
clap-num = { version = "1.2.0" }
6465
clap-verbosity-flag = { version = "2.2.1" }
66+
nvml-wrapper = "0.11.0"
6567

6668
[target.'cfg(windows)'.dependencies.windows]
6769
version = "0.59.0"

framework_lib/src/commandline/mod.rs

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ use sha2::{Digest, Sha256, Sha384, Sha512};
7272
//use smbioslib::*;
7373
use smbioslib::{DefinedStruct, SMBiosInformation};
7474

75+
#[cfg(any(target_os = "linux", target_os = "windows"))]
76+
use nvml_wrapper::{enum_wrappers::device::TemperatureSensor, Nvml};
77+
7578
use crate::chromium_ec::{CrosEc, CrosEcDriverType, HardwareDeviceType};
7679

7780
#[cfg(feature = "uefi")]
@@ -363,6 +366,8 @@ fn print_pd_details(ec: &CrosEc) {
363366
#[cfg(feature = "hidapi")]
364367
const NOT_SET: &str = "NOT SET";
365368

369+
const UNKNOWN: &str = "Unknown";
370+
366371
#[cfg(feature = "rusb")]
367372
fn print_audio_card_details() {
368373
check_synaptics_fw_version();
@@ -767,6 +772,88 @@ fn print_versions(ec: &CrosEc) {
767772
}
768773
}
769774
}
775+
776+
#[cfg(any(target_os = "linux", target_os = "windows"))]
777+
print_nvidia_details();
778+
}
779+
780+
#[cfg(any(target_os = "linux", target_os = "windows"))]
781+
fn print_nvidia_details() {
782+
let nvml = match Nvml::init() {
783+
Ok(nvml) => nvml,
784+
Err(err) => {
785+
debug!("Nvidia, library init fail: {:?}", err);
786+
return;
787+
}
788+
};
789+
// Get the first `Device` (GPU) in the system
790+
let device = match nvml.device_by_index(0) {
791+
Ok(device) => device,
792+
Err(err) => {
793+
debug!("Nvidia, device not found: {:?}", err);
794+
return;
795+
}
796+
};
797+
798+
println!("NVIDIA GPU");
799+
// GeForce
800+
info!(" BRAND: {:?}", device.brand());
801+
println!(
802+
" Name: {}",
803+
device.name().unwrap_or(UNKNOWN.to_string())
804+
);
805+
println!(" Architecture: {:?}", device.architecture());
806+
println!(
807+
" VBIOS Version: {}",
808+
device.vbios_version().unwrap_or(UNKNOWN.to_string())
809+
);
810+
println!(
811+
" INFO ROM Ver: {}",
812+
device
813+
.info_rom_image_version()
814+
.unwrap_or(UNKNOWN.to_string())
815+
);
816+
println!(" PCI Info: {:X?}", device.pci_info());
817+
println!(" Performance State:{:?}", device.performance_state());
818+
println!(
819+
" Pwr Mgmt Limit Df:{:?}mW",
820+
device.power_management_limit_default()
821+
);
822+
// NotSupported
823+
println!(
824+
" Pwr Mgmt Limit: {:?}mW",
825+
device.power_management_limit()
826+
);
827+
println!(
828+
" Pwr Mgmt Limit Cs:{:?}",
829+
device.power_management_limit_constraints()
830+
);
831+
println!(" Pwr Usage: {:?}mW", device.power_usage());
832+
println!(
833+
" Total Energy: {:?}mJ",
834+
device.total_energy_consumption()
835+
);
836+
// 0/NotSupported right now
837+
println!(" Serialnum: {:?}", device.serial());
838+
println!(
839+
" Throttle Reason: {:?}",
840+
device.current_throttle_reasons()
841+
);
842+
println!(
843+
" Temperature: {:?}C",
844+
device.temperature(TemperatureSensor::Gpu)
845+
);
846+
//println!(" Temperature Thres:{:?}C", device.temperature_threshold());
847+
println!(" Util Rate: {:?}", device.utilization_rates());
848+
println!(" Memory Info: {:?}", device.memory_info());
849+
// Not supported
850+
println!(" Part Number: {:?}", device.board_part_number());
851+
println!(" Board ID: {:?}", device.board_id());
852+
// 0
853+
println!(" Num Fans: {:?}", device.num_fans());
854+
// Works
855+
println!(" Display Active?: {:?}", device.is_display_active());
856+
println!(" Display Conn?: {:?}", device.is_display_connected());
770857
}
771858

772859
fn print_esrt() {

0 commit comments

Comments
 (0)