pub struct GpuDeviceInfo {
pub name: String,
pub backend: String,
pub total_vram_bytes: u64,
pub available_vram_bytes: u64,
pub used_vram_bytes: u64,
pub driver_version: String,
pub compute_capability: Option<String>,
pub max_threads_per_block: u32,
pub max_shared_memory_per_block: u64,
pub device_id: i32,
pub pci_bus_id: Option<String>,
}Expand description
GPU device information
Provides detailed information about the GPU device including memory, capabilities, and backend-specific details.
§Examples
use hive_gpu::metal::MetalNativeContext;
use hive_gpu::traits::GpuContext;
let context = MetalNativeContext::new().expect("Failed to create Metal context");
let info = context.device_info().expect("Failed to get device info");
println!("Device: {}", info.name);
println!("Backend: {}", info.backend);
println!("VRAM: {} MB", info.total_vram_bytes / 1024 / 1024);
println!("Usage: {:.1}%", info.vram_usage_percent());Fields§
§name: StringDevice name (e.g., “Apple M2 Pro”, “NVIDIA RTX 4090”)
backend: StringBackend type (e.g., “Metal”, “CUDA”, “ROCm”)
total_vram_bytes: u64Total VRAM in bytes
available_vram_bytes: u64Currently available VRAM in bytes
used_vram_bytes: u64Currently used VRAM in bytes (calculated as total - available)
driver_version: StringDriver version string (e.g., “macOS 14.1”, “CUDA 12.0”, “ROCm 5.4”)
compute_capability: Option<String>Compute capability or architecture version
- Metal: None
- CUDA: e.g., “8.9” for sm_89
- ROCm: e.g., “gfx1030”
max_threads_per_block: u32Maximum threads per block/workgroup
Maximum shared memory per block (in bytes)
device_id: i32Device ID (0-indexed)
pci_bus_id: Option<String>PCI bus ID (e.g., “0000:01:00.0”) None for Metal (Apple Silicon doesn’t expose PCI)
Implementations§
Source§impl GpuDeviceInfo
impl GpuDeviceInfo
Sourcepub fn vram_usage_percent(&self) -> f64
pub fn vram_usage_percent(&self) -> f64
Calculate VRAM usage percentage (0.0 to 100.0)
§Examples
let usage = info.vram_usage_percent();
assert!(usage >= 0.0 && usage <= 100.0);Sourcepub fn has_available_vram(&self, required_bytes: u64) -> bool
pub fn has_available_vram(&self, required_bytes: u64) -> bool
Sourcepub fn available_vram_mb(&self) -> u64
pub fn available_vram_mb(&self) -> u64
Get VRAM available in megabytes (convenience method)
§Examples
println!("Available: {} MB", info.available_vram_mb());Sourcepub fn total_vram_mb(&self) -> u64
pub fn total_vram_mb(&self) -> u64
Get total VRAM in megabytes (convenience method)
§Examples
println!("Total: {} MB", info.total_vram_mb());Trait Implementations§
Source§impl Clone for GpuDeviceInfo
impl Clone for GpuDeviceInfo
Source§fn clone(&self) -> GpuDeviceInfo
fn clone(&self) -> GpuDeviceInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more