-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solve ratio problem #12
Conversation
solves the ratio problem for laptops and fanless cards.
changed the message when there is no fans, no fan to no fans
src/app.rs
Outdated
@@ -154,7 +154,9 @@ pub fn run( | |||
selected_gpu = usize::from(n - 1) | |||
} | |||
KeyCode::Char('p') => { | |||
// re-scan pci tree to let driver discover new devices (only works as sudo) | |||
//commented out because discover_gpus not implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is implemented https://docs.rs/nvml-wrapper/latest/nvml_wrapper/struct.Nvml.html#method.discover_gpus, it's probably not available on the platform (laptop gpus).
We need a better way to conditionally show/not-show this for sure.
You can actually see it working on a multi-gpu system here #6 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was not able to compile, i will look again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* snip
# Platform Support
Only supports Linux.
*/
// TODO: constructor for default pci_infos ^
// Checked against local
// Tested
#[cfg(target_os = "linux")]
#[doc(alias = "nvmlDeviceDiscoverGpus")]
pub fn discover_gpus(&self, pci_info: PciInfo) -> Result<(), NvmlError> {
let sym = nvml_sym(self.lib.nvmlDeviceDiscoverGpus.as_ref())?;
unsafe { nvml_try(sym(&mut pci_info.try_into()?)) }
}
/* snip */
as it writes, this function is only for linux, im testing it on windows. so i will try to not show "p to rescan" on windows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I too should've gone deeper in the docs before snarking, soz.
src/app.rs
Outdated
|
||
let percentage = (avg / 100.).clamp(0., 1.0); | ||
let label = format!("{:.1}%", avg); | ||
let percentage = match avg.is_nan() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is defnitely no issue with the code -- I'm thinking that maybe we should just not run the call to draw_fan-speed
at all if we're on a fan-less system, because we're checking this every time the loop runs.
Wanna hoist something out side the loop to where we can check if we get values then just never run this code if we don't have to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will convert it to something like Result<Gauge, Error>, if error is no fans, it will get there is no fans. and, you can implement other errors in future.
Hey bktexh -- thanks for your contribution: After thinking more about it I think we'll do something like this: pub fn run(
nvml: nvml_wrapper::Nvml,
/* Snip */
let mut gpu_list = crate::gpu::try_init_gpus(&nvml, lh)?; //Line 32, in `src/app.rs
// Let's work out if there's any GPUs we can get a fan off.
let has_fans = gpu_list
.iter()
.any(|gpu| gpu.inner.num_fans().map_or(0, |fc| fc) != 0);
/* Snip */ // Then later (in the endless loop:
// Fanspeed:
if has_fans {
let fan_gauge = draw_fan_speed(gpu);
f.render_widget(fan_gauge, chunks[2]);
} (apologies for not writing more code to exemplify what I'm after here, on mobile & on the move atm. |
Thank you :) |
i forgot something, we are only checking at program start, not when rescanning |
I'll fix it in an hour or so -- don't think it'll tick anyone off too badly till then 😉 |
solves the ratio problem for laptops and fanless cards.