Skip to content

Add config to select GPU index - #143

Open
osimarr wants to merge 3 commits into
PolpOnline:masterfrom
osimarr:master
Open

Add config to select GPU index#143
osimarr wants to merge 3 commits into
PolpOnline:masterfrom
osimarr:master

Conversation

@osimarr

@osimarr osimarr commented Apr 10, 2026

Copy link
Copy Markdown

This pull request adds support for selecting which GPU to monitor by index, improving multi-GPU system compatibility. It introduces a new gpu_index configuration option, updates both AMD and NVIDIA backends to respect this index, and exposes the GPU index in formatting fields and outputs.

I have AMD GPU and tested my changes on it. But I need somebody with NVIDIA to do the same.

osimarr added 3 commits April 10, 2026 15:20
The order of the drm minor may not match the order of the cards on sysfs.
When enumerating AMD GPUs, the minor number plays a better role.
In multiple GPU scenarios, let the user decide which one to collect data.
@osimarr osimarr changed the title Add config to select GPU idex Add config to select GPU index Apr 10, 2026
Comment thread src/main.rs
Comment on lines +32 to 40
pub fn new(gpu_index: u8) -> Result<Self> {
let modules = procfs::modules()?;

if modules.contains_key("nvidia") {
return Ok(Self::Nvml(Box::new(Nvml::init()?)));
}
if modules.contains_key("amdgpu") {
return Ok(Self::Amd(Box::new(AmdSysFS::init()?)));
return Ok(Self::Amd(Box::new(AmdSysFS::init(gpu_index)?)));
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have both NVIDIA and AMD cards, this will always return NVIDIA instance.

@Bowen951209

Copy link
Copy Markdown
Contributor

I think this is duplicated of #127.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants