pub struct Gpu { /* private fields */ }Expand description
Type containing GPU information.
It is returned by Gpus.
use sysinfo::Gpus;
if let Ok(gpus) = Gpus::new_with_refreshed_list() {
for gpu in &gpus {
println!("{gpu:?}");
}
}Implementations§
Source§impl Gpu
impl Gpu
Sourcepub fn pci(&self) -> &PCI
pub fn pci(&self) -> &PCI
Returns the PCI of this GPU. Can be used as ID as it’s unique to this GPU.
Returns an invalid PCI Address, ffffffff:ff:ff.255, for Apple M Series GPUs.
Sourcepub fn vendor(&self) -> Option<&str>
pub fn vendor(&self) -> Option<&str>
Returns the name of the vendor of this GPU. Returns None if the information cannot be
retrieved.
Sourcepub fn model(&self) -> Option<&str>
pub fn model(&self) -> Option<&str>
Returns the model of this GPU. Returns None if the information cannot be retrieved.
Sourcepub fn usage(&self) -> Option<f32>
pub fn usage(&self) -> Option<f32>
Returns the % usage of this GPU.
On Linux, it’s generally very tricky to get this information, as such, only some GPUs like NVIDIA’s or AMD’s provide this information.
On macOS, the information should always be available.
On Windows, the first time you query this information, it’ll return None as it is
time-diff based.
Sourcepub fn total_memory(&self) -> Option<u64>
pub fn total_memory(&self) -> Option<u64>
Returns the total VRAM of this GPU in bytes.
⚠️ It does not take into account the GPU memory that is shared with the system’s RAM.
On macOS, GPUs share memory with the system, it always returns None.
Returns None if the information cannot be retrieved.
Sourcepub fn used_memory(&self) -> Option<u64>
pub fn used_memory(&self) -> Option<u64>
Returns the used VRAM of this GPU in bytes.
⚠️ It does not take into account the GPU memory that is shared with the system’s RAM.
On macOS, GPUs share memory with the system, it always returns None.
Returns None if the information cannot be retrieved.