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

Add support for GPU #1026

Open
GuillaumeGomez opened this issue Jul 26, 2023 · 6 comments
Open

Add support for GPU #1026

GuillaumeGomez opened this issue Jul 26, 2023 · 6 comments

Comments

@GuillaumeGomez
Copy link
Owner

It's possible to gather some GPU information with vulkan, like memory available and memory usage: https://www.asawicki.info/news_1695_there_is_a_way_to_query_gpu_memory_usage_in_vulkan_-_use_dxgi

@JaydenElliott
Copy link

would you consider wrapping nvidia-smi and putting it behind a nvidia-gpu feature flag? or are you hoping to keep it generic enough to use across device types?

@GuillaumeGomez
Copy link
Owner Author

I'd prefer to not have any GPU-specific code as it greatly increases the code complexity.

@Notarin
Copy link

Notarin commented Sep 18, 2023

In case it assists, this was my method of getting GPU information (in my implementation i only needed names), I used gfx_hal.

fn get_gpus() -> Vec<String> {

    let instance: gfx_backend_vulkan::Instance =
        back::Instance::create("hayabusa", 1).unwrap();
    let adapters: Vec<Adapter<Backend>> = instance.enumerate_adapters();

    let mut names: Vec<String> = Vec::new();

    for adapter in adapters {
        names.push(adapter.info.name.to_string());
    }

    names
}

@GuillaumeGomez
Copy link
Owner Author

I had in mind to use opengl/vulkan to query information like GPU type, name, total memory and if possible % usage, memory usage and temperature.

If you are interested into adding this, it'd be very welcome! Also thanks for allowing me to discover gfx-hal, didn't know about this crate.

@GuillaumeGomez
Copy link
Owner Author

GuillaumeGomez commented Dec 30, 2023

So to get the total memory and potentially memory usage (I got it from here):

The VRAM size though can be determined by finding the memory heap with the DEVICE_LOCAL bit set using vkGetPhysicalDeviceMemoryProperties. The VkPhysicalDeviceMemoryProperties returned by that function contains all available memory heaps in the memoryHeaps member. The configuration differs esp. between discrete and integrated GPUs, so this may not always be what you're looking for, e.g. on integrated GPUs with shared memory.

To get the GPU name/type, we can use vkGetPhysicalDeviceProperties.

@Notarin
Copy link

Notarin commented Dec 30, 2023

@GuillaumeGomez
Juggling a lot of things rn, but ty for putting this back on my radar, may see what I can do with it, if I fork even for purposes as simple as playing around with this I'll leave a comment

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

No branches or pull requests

3 participants