fixed units
All checks were successful
Rust Cross-Platform Build / Detect Rust Project (push) Successful in 5s
Rust Cross-Platform Build / Set Tag Name (push) Successful in 5s
Rust Cross-Platform Build / Run Tests (push) Successful in 1m8s
Rust Cross-Platform Build / Build (x86_64-unknown-linux-gnu) (push) Successful in 3m5s
Rust Cross-Platform Build / Build (x86_64-pc-windows-gnu) (push) Successful in 3m56s
Rust Cross-Platform Build / Build and Push Docker Image (push) Successful in 2m24s
Rust Cross-Platform Build / Create Tag (push) Successful in 6s
Rust Cross-Platform Build / Workflow Summary (push) Successful in 1s

This commit is contained in:
2025-10-01 13:13:18 +02:00
parent f78e48900a
commit 49f1af392d
6 changed files with 28 additions and 26 deletions

View File

@@ -14,8 +14,8 @@ use std::error::Error;
/// ## Units
/// - `current_load`: GPU usage as a percentage (**0.0100.0**)
/// - `current_temp`: GPU temperature in **degrees Celsius (°C)**
/// - `vram_total`: Total VRAM in **megabytes (MB)**
/// - `vram_used`: Used VRAM in **megabytes (MB)**
/// - `vram_total`: Total VRAM in **bytes**
/// - `vram_used`: Used VRAM in **bytes**
///
/// GPU statistics for the host system.
///
@@ -23,8 +23,8 @@ use std::error::Error;
/// - `name`: GPU model name (string)
/// - `current_load`: GPU usage as a percentage (**0.0100.0**)
/// - `current_temp`: GPU temperature in **degrees Celsius (°C)**
/// - `vram_total`: Total VRAM in **megabytes (MB)**
/// - `vram_used`: Used VRAM in **megabytes (MB)**
/// - `vram_total`: Total VRAM in **bytes**
/// - `vram_used`: Used VRAM in **bytes**
#[derive(Debug)]
pub struct GpuInfo {
pub name: Option<String>,
@@ -69,7 +69,7 @@ pub async fn get_gpu_info() -> Result<GpuInfo, Box<dyn Error + Send + Sync>> {
/// Queries NVML for GPU metrics: temperature, load, VRAM used/total.
///
/// # Returns
/// * `Result<(f64, f64, f64, f64), Box<dyn Error + Send + Sync>>` - Tuple of (temperature °C, load %, VRAM used MB, VRAM total MB).
/// * `Result<(f64, f64, f64, f64), Box<dyn Error + Send + Sync>>` - Tuple of (temperature °C, load %, VRAM used bytes, VRAM total bytes).
pub fn get_gpu_metrics() -> Result<(f64, f64, f64, f64), Box<dyn Error + Send + Sync>> {
let nvml = Nvml::init();
if let Ok(nvml) = nvml {