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
impl GpuHandle
Sourcepub fn new_from_path(sysfs_path: PathBuf) -> Result<Self, Error>
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.
Sourcepub fn get_driver(&self) -> &str
pub fn get_driver(&self) -> &str
Gets the kernel driver used.
Sourcepub fn get_pci_id(&self) -> Option<(&str, &str)>
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.
Sourcepub fn get_pci_subsys_id(&self) -> Option<(&str, &str)>
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.
Sourcepub fn get_pci_slot_name(&self) -> Option<&str>
pub fn get_pci_slot_name(&self) -> Option<&str>
Gets the pci slot name of the card.
Sourcepub fn get_current_link_speed(&self) -> Result<String, Error>
pub fn get_current_link_speed(&self) -> Result<String, Error>
Gets the current PCIe link speed.
Sourcepub fn get_current_link_width(&self) -> Result<String, Error>
pub fn get_current_link_width(&self) -> Result<String, Error>
Gets the current PCIe link width.
Sourcepub fn get_max_link_speed(&self) -> Result<String, Error>
pub fn get_max_link_speed(&self) -> Result<String, Error>
Gets the maximum possible PCIe link speed.
Sourcepub fn get_max_link_width(&self) -> Result<String, Error>
pub fn get_max_link_width(&self) -> Result<String, Error>
Gets the maximum possible PCIe link width.
Sourcepub fn get_total_vram(&self) -> Result<u64, Error>
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.
Sourcepub fn get_used_vram(&self) -> Result<u64, Error>
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.
Sourcepub fn get_busy_percent(&self) -> Result<u8, Error>
pub fn get_busy_percent(&self) -> Result<u8, Error>
Returns the GPU busy percentage.
Sourcepub fn get_vbios_version(&self) -> Result<String, Error>
pub fn get_vbios_version(&self) -> Result<String, Error>
Returns the GPU VBIOS version.
Sourcepub fn get_vram_vendor(&self) -> Result<String, Error>
pub fn get_vram_vendor(&self) -> Result<String, Error>
Returns the VRAM vendor
Sourcepub fn get_power_force_performance_level(
&self,
) -> Result<PerformanceLevel, Error>
pub fn get_power_force_performance_level( &self, ) -> Result<PerformanceLevel, Error>
Returns the currently forced performance level.
Sourcepub fn set_power_force_performance_level(
&self,
level: PerformanceLevel,
) -> Result<(), Error>
pub fn set_power_force_performance_level( &self, level: PerformanceLevel, ) -> Result<(), Error>
Forces a given performance level.
Sourcepub fn get_clock_levels<T>(
&self,
kind: PowerLevelKind,
) -> Result<PowerLevels<T>, Error>
pub fn get_clock_levels<T>( &self, kind: PowerLevelKind, ) -> Result<PowerLevels<T>, Error>
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.
Sourcepub fn get_core_clock_levels(&self) -> Result<PowerLevels<u64>, Error>
pub fn get_core_clock_levels(&self) -> Result<PowerLevels<u64>, Error>
Gets clocks levels.
Sourcepub fn get_memory_clock_levels(&self) -> Result<PowerLevels<u64>, Error>
pub fn get_memory_clock_levels(&self) -> Result<PowerLevels<u64>, Error>
Gets clocks levels.
Sourcepub fn get_pcie_clock_levels(&self) -> Result<PowerLevels<String>, Error>
pub fn get_pcie_clock_levels(&self) -> Result<PowerLevels<String>, Error>
Gets clocks levels.
Sourcepub fn set_enabled_power_levels(
&self,
kind: PowerLevelKind,
levels: &[u8],
) -> Result<(), Error>
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
.
Sourcepub fn get_clocks_table(&self) -> Result<ClocksTableGen, Error>
pub fn get_clocks_table(&self) -> Result<ClocksTableGen, Error>
Reads the clocks table from pp_od_clk_voltage
.
Sourcepub fn set_clocks_table(
&self,
new_table: &ClocksTableGen,
) -> Result<CommitHandle, Error>
pub fn set_clocks_table( &self, new_table: &ClocksTableGen, ) -> Result<CommitHandle, Error>
Writes and commits the given clocks table to pp_od_clk_voltage
.
Sourcepub fn reset_clocks_table(&self) -> Result<(), Error>
pub fn reset_clocks_table(&self) -> Result<(), Error>
Resets the clocks table to the default configuration.
Sourcepub fn get_power_profile_modes(&self) -> Result<PowerProfileModesTable, Error>
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
Sourcepub fn set_active_power_profile_mode(&self, i: u16) -> Result<(), Error>
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
]
Sourcepub fn set_custom_power_profile_mode_heuristics(
&self,
components: &[Vec<Option<i32>>],
) -> Result<(), Error>
pub fn set_custom_power_profile_mode_heuristics( &self, components: &[Vec<Option<i32>>], ) -> Result<(), Error>
Sets a custom power profile mode. You can get the available modes, and the list of heuristic names with [get_power_profile_modes
].
Requires the performance level to be set to “manual” first using [set_power_force_performance_level
]
Sourcepub fn get_fan_acoustic_limit(&self) -> Result<FanInfo, Error>
pub fn get_fan_acoustic_limit(&self) -> Result<FanInfo, Error>
Gets the fan acoustic limit. Values are in RPM.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#acoustic-limit-rpm-threshold
Sourcepub fn get_fan_acoustic_target(&self) -> Result<FanInfo, Error>
pub fn get_fan_acoustic_target(&self) -> Result<FanInfo, Error>
Gets the fan acoustic target. Values are in RPM.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#acoustic-target-rpm-threshold
Sourcepub fn get_fan_target_temperature(&self) -> Result<FanInfo, Error>
pub fn get_fan_target_temperature(&self) -> Result<FanInfo, Error>
Gets the fan temperature target. Values are in degrees.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#fan-target-temperature
Sourcepub fn get_fan_minimum_pwm(&self) -> Result<FanInfo, Error>
pub fn get_fan_minimum_pwm(&self) -> Result<FanInfo, Error>
Gets the fan minimum PWM. Values are in percentages.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#fan-minimum-pwm
Sourcepub fn get_fan_zero_rpm_enable(&self) -> Result<bool, Error>
pub fn get_fan_zero_rpm_enable(&self) -> Result<bool, Error>
Gets the current fan zero RPM mode.
Only available on Navi3x (RDNA 3) or newer.
Sourcepub fn get_fan_zero_rpm_stop_temperature(&self) -> Result<FanInfo, Error>
pub fn get_fan_zero_rpm_stop_temperature(&self) -> Result<FanInfo, Error>
Gets the current fan zero RPM stop temperature.
Only available on Navi3x (RDNA 3) or newer.
Sourcepub fn set_fan_acoustic_limit(&self, value: u32) -> Result<CommitHandle, Error>
pub fn set_fan_acoustic_limit(&self, value: u32) -> Result<CommitHandle, Error>
Sets the fan acoustic limit. Value is in RPM.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#acoustic-limit-rpm-threshold
Sourcepub fn set_fan_acoustic_target(&self, value: u32) -> Result<CommitHandle, Error>
pub fn set_fan_acoustic_target(&self, value: u32) -> Result<CommitHandle, Error>
Sets the fan acoustic target. Value is in RPM.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#acoustic-target-rpm-threshold
Sourcepub fn set_fan_target_temperature(
&self,
value: u32,
) -> Result<CommitHandle, Error>
pub fn set_fan_target_temperature( &self, value: u32, ) -> Result<CommitHandle, Error>
Sets the fan temperature target. Value is in degrees.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#fan-target-temperature
Sourcepub fn set_fan_minimum_pwm(&self, value: u32) -> Result<CommitHandle, Error>
pub fn set_fan_minimum_pwm(&self, value: u32) -> Result<CommitHandle, Error>
Sets the fan minimum PWM. Value is a percentage.
Only available on Navi3x (RDNA 3) or newer.
Sourcepub fn set_fan_zero_rpm_enable(
&self,
enabled: bool,
) -> Result<CommitHandle, Error>
pub fn set_fan_zero_rpm_enable( &self, enabled: bool, ) -> Result<CommitHandle, Error>
Sets the current fan zero RPM mode.
Only available on Navi3x (RDNA 3) or newer.
Sourcepub fn set_fan_zero_rpm_stop_temperature(
&self,
value: u32,
) -> Result<CommitHandle, Error>
pub fn set_fan_zero_rpm_stop_temperature( &self, value: u32, ) -> Result<CommitHandle, Error>
Sets the fan zero RPM stop temperature.
Only available on Navi3x (RDNA 3) or newer.
Sourcepub fn reset_fan_acoustic_limit(&self) -> Result<(), Error>
pub fn reset_fan_acoustic_limit(&self) -> Result<(), Error>
Resets the fan acoustic limit.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#acoustic-limit-rpm-threshold
Sourcepub fn reset_fan_acoustic_target(&self) -> Result<(), Error>
pub fn reset_fan_acoustic_target(&self) -> Result<(), Error>
Resets the fan acoustic target.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#acoustic-target-rpm-threshold
Sourcepub fn reset_fan_target_temperature(&self) -> Result<(), Error>
pub fn reset_fan_target_temperature(&self) -> Result<(), Error>
Resets the fan target temperature.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#fan-target-temperature
Sourcepub fn reset_fan_minimum_pwm(&self) -> Result<(), Error>
pub fn reset_fan_minimum_pwm(&self) -> Result<(), Error>
Resets the fan minimum pwm.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#fan-minimum-pwm
Sourcepub fn get_fan_curve(&self) -> Result<FanCurve, Error>
pub fn get_fan_curve(&self) -> Result<FanCurve, Error>
Gets the PMFW (power management firmware) fan curve. Note: if no custom curve is used, all of the curve points may be set to 0.
Only available on Navi3x (RDNA 3) or newer. Older GPUs do not have a configurable fan curve in firmware, they need custom logic.
Sourcepub fn set_fan_curve(&self, new_curve: &FanCurve) -> Result<CommitHandle, Error>
pub fn set_fan_curve(&self, new_curve: &FanCurve) -> Result<CommitHandle, Error>
Sets and applies the PMFW fan curve.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#fan-curve
Sourcepub fn reset_fan_curve(&self) -> Result<(), Error>
pub fn reset_fan_curve(&self) -> Result<(), Error>
Resets the PMFW fan curve.
Only available on Navi3x (RDNA 3) or newer. https://kernel.org/doc/html/latest/gpu/amdgpu/thermal.html#fan-curve