pub struct GpuHandle {
    pub hw_monitors: Vec<HwMon>,
    /* private fields */
}
Expand description

A GpuHandle represents a handle over a single GPU device, as exposed in the Linux SysFS.

Fields§

§hw_monitors: Vec<HwMon>

A collection of all HwMons bound to this GPU. They are used to expose real-time data.

Implementations§

source§

impl GpuHandle

source

pub fn new_from_path(sysfs_path: PathBuf) -> Result<Self, Error>

Initializes a new GpuHandle from a given SysFS device path.

Normally, the path should look akin to /sys/class/drm/card0/device, and it needs to at least contain a uevent file.

source

pub fn get_driver(&self) -> &str

Gets the kernel driver used.

source

pub fn get_pci_id(&self) -> Option<(&str, &str)>

Gets the GPU’s PCI vendor and ID. This is the ID of your GPU chip, e.g. AMD Radeon RX 580.

source

pub fn get_pci_subsys_id(&self) -> Option<(&str, &str)>

Gets the Card’s PCI vendor and ID. This is the ID of your card model, e.g. Sapphire RX 580 Pulse.

source

pub fn get_pci_slot_name(&self) -> Option<&str>

Gets the pci slot name of the card.

Gets the current PCIe link speed.

Gets the current PCIe link width.

Gets the maximum possible PCIe link speed.

Gets the maximum possible PCIe link width.

source

pub fn get_total_vram(&self) -> Result<u64, Error>

Gets total VRAM size in bytes. May not be reported on some devices, such as integrated GPUs.

source

pub fn get_used_vram(&self) -> Result<u64, Error>

Gets how much VRAM is currently used, in bytes. May not be reported on some devices, such as integrated GPUs.

source

pub fn get_busy_percent(&self) -> Result<u8, Error>

Returns the GPU busy percentage.

source

pub fn get_vbios_version(&self) -> Result<String, Error>

Returns the GPU VBIOS version.

source

pub fn get_power_force_performance_level( &self ) -> Result<PerformanceLevel, Error>

Returns the currently forced performance level.

source

pub fn set_power_force_performance_level( &self, level: PerformanceLevel ) -> Result<(), Error>

Forces a given performance level.

source

pub fn get_clock_levels<T>( &self, kind: PowerLevelKind ) -> Result<PowerLevels<T>, Error>
where T: FromStr, <T as FromStr>::Err: Display,

Retuns the list of power levels and index of the currently active level for a given kind of power state. T is the type that values should be deserialized into.

source

pub fn get_core_clock_levels(&self) -> Result<PowerLevels<u64>, Error>

Gets clocks levels.

source

pub fn get_memory_clock_levels(&self) -> Result<PowerLevels<u64>, Error>

Gets clocks levels.

source

pub fn get_pcie_clock_levels(&self) -> Result<PowerLevels<String>, Error>

Gets clocks levels.

source

pub fn set_enabled_power_levels( &self, kind: PowerLevelKind, levels: &[u8] ) -> Result<(), Error>

Sets the enabled power levels for a power state kind to a given list of levels. This means that only the given power levels will be allowed.

Can only be used if power_force_performance_level is set to manual.

source

pub fn get_clocks_table(&self) -> Result<ClocksTableGen, Error>

Reads the clocks table from pp_od_clk_voltage.

source

pub fn set_clocks_table(&self, table: &ClocksTableGen) -> Result<(), Error>

Writes and commits the given clocks table to pp_od_clk_voltage.

source

pub fn reset_clocks_table(&self) -> Result<(), Error>

Resets the clocks table to the default configuration.

source

pub fn get_power_profile_modes(&self) -> Result<PowerProfileModesTable, Error>

Reads the list of predefined power profiles and the relevant heuristics settings for them from pp_power_profile_mode

https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#pp-power-profile-mode

source

pub fn set_active_power_profile_mode(&self, i: u16) -> Result<(), Error>

Sets the current power profile mode. You can get the available modes with [get_power_profile_modes]. Requires the performance level to be set to “manual” first using [set_power_force_performance_level]

Trait Implementations§

source§

impl Clone for GpuHandle

source§

fn clone(&self) -> GpuHandle

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for GpuHandle

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl SysFS for GpuHandle

source§

fn get_path(&self) -> &Path

Gets the path of the current SysFS.
source§

fn read_file(&self, file: &str) -> Result<String, Error>

Reads the content of a file in the SysFS.
source§

fn read_file_parsed<T: FromStr<Err = E>, E: ToString>( &self, file: &str ) -> Result<T, Error>

Reads the content of a file and then parses it
source§

fn write_file<C: AsRef<[u8]> + Send>( &self, file: &str, contents: C ) -> Result<(), Error>

Write to a file in the SysFS.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.