Skip to content
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

feat(win): better gpu detection #1141

Merged

Conversation

axel7083
Copy link
Contributor

@axel7083 axel7083 commented May 31, 2024

What does this PR do?

Remove the old GPUManager code detecting the Nvidia GPU using nvidia-smi and replace it with a generic worker system.

This PR is adding the WinGPUDetector worker. This worker is responsible of detecting the GPUs available on windows.

How

We need two information, the name and the VRAM available for each GPU, sadly windows is crap123, and they don't fix their code1, so we have to read the registry4 to access the exact value of the VRAM for each GPU detected.

Reading the registry could feel scary but we are simply following the official Microsoft documentation here, with long term support values. Therefore not too scary :)

Other solution do not provide accurate value3.

Screenshot / video of UI

What issues does this PR fix or reference?

Related to https://github.com/containers/podman-desktop-internal/issues/270

Fixes #1144

How to test this PR?

  • Unit tests has been added

Manually

Adding the following in the studio.ts file (activate function)

const gpuManager = new GPUManager(this.#panel?.webview);
gpuManager.collectGPUs().then((gpus) => {
  console.log('Collected GPUs', gpus);
}).catch((err: unknown) => {
  console.error('Something went wrong while tryng to collect GPUs', err);
});

Example output

[ai-lab] Collected GPUs [ { model: 'NVIDIA GeForce GTX 1060 6GB', vram: 6442450944 } ]

Footnotes

  1. Msinfo32.exe reports an unexpected value for the Display Adapter RAM when the graphics adapter has 2 GB or more of dedicated video memory https://learn.microsoft.com/en-us/troubleshoot/windows-client/setup-upgrade-and-drivers/msinfo32-report-wrong-display-adapter-ram 2

  2. Windows is crap https://superuser.com/questions/1461858/fetch-correct-vram-for-gpu-via-command-line-on-windows

  3. Windows is crap https://stackoverflow.com/questions/68274009/wmi-win32-videocontroller-ram-4gb-limit 2

  4. Windows registry values https://learn.microsoft.com/fr-fr/windows-hardware/drivers/install/system-defined-device-setup-classes-available-to-vendors

@axel7083 axel7083 requested review from benoitf and a team as code owners May 31, 2024 13:27
@axel7083 axel7083 requested review from feloy and lstocchi May 31, 2024 13:27
Copy link
Contributor

@lstocchi lstocchi left a comment

Choose a reason for hiding this comment

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

Tested and my output is model: "Intel(R) UHD Graphics\u0000" vram: undefined which is in line with what i have since my gpu does not have dedicated ram.

LGTM

@axel7083 axel7083 merged commit 9672180 into containers:main Jun 4, 2024
4 checks passed
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.

Detecting GPU(s) on Windows (Name, VRAM)
2 participants