domalab / ha-unraid

Monitor and control your Unraid server directly from Home Assistant. Track system metrics (CPU, RAM, disk usage), manage VMs and Docker containers, monitor UPS status, and receive real-time alerts. Features automated discovery and an easy-to-use interface for seamless integration with your smart home.
Apache License 2.0
29 stars 1 forks source link

Add GPU Statistics #16

Open martindell opened 1 week ago

martindell commented 1 week ago

First off - thank you for this addon. I'm using it to halt a GPU-heavy Unraid docker to save my home battery from running out of juice 👍

Is your feature request related to a problem? Please describe. I use the GPU Statistics plugin to display this kind of info on my Unraid dashboard.

Screenshot 2024-11-17 at 09 34 21

Describe the solution you'd like It'd be great to see this kind of info as sensors inside the HomeAssistant addon

Additional context I can pull some of this GPU info via user scripts. Maybe there's a way to pass it back to the HomeAssistant addon?

domalab commented 1 week ago

@martindell can you run this commands from unraid console?

To retrieve GPU information (NVIDIA, AMD, and integrated GPUs) on an Unraid system and save it to a text file, you can use the following approaches:

  1. Using lspci

The lspci command can be used to list all PCI devices, including GPUs. You can filter the output for NVIDIA, AMD, and integrated GPUs.

lspci | grep -i 'vga|3d|display' > /boot/config/gpu_info.txt

•   Explanation:
•   grep -i 'vga\|3d\|display': Filters lines related to GPUs.
•   > /boot/config/gpu_info.txt: Redirects output to a file.
  1. Using nvidia-smi for NVIDIA GPUs

If you have the NVIDIA driver plugin installed, nvidia-smi provides detailed information for NVIDIA GPUs.

nvidia-smi -q > /boot/config/nvidia_gpu_info.txt

•   Explanation:
•   -q: Outputs detailed GPU information.
•   > /boot/config/nvidia_gpu_info.txt: Saves the output to a file.
  1. Using glxinfo for Integrated and AMD GPUs

If you have mesa-utils installed, you can use glxinfo to retrieve GPU details.

glxinfo | grep -i 'device|renderer' > /boot/config/gpu_info_glx.txt

  1. Using inxi for Comprehensive GPU Info

If you have inxi installed, it provides detailed GPU information.

inxi -Gxx > /boot/config/gpu_info_inxi.txt

Installing Missing Tools

If some commands are missing, you might need to install additional packages using nerdpack or Unraid plugins. For example: • nvidia-smi requires the NVIDIA driver plugin. • glxinfo and inxi might need nerdpack.

martindell commented 1 week ago

Ah yes, nvidia-smi works OK. I'm not too sure what to do with the output if I run the command as a user script?

nvidia_gpu_info.txt

This command also gets me the values I'm looking for, but again I'm not sure where to go next to get them in HA

nvidia-smi --query-gpu=utilization.gpu,temperature.gpu,fan.speed,power.draw,pstate --format=csv,noheader --id=GPU-46250647-39eb-0df2-0faa-9ee13e7745fd

88 %, 71, 85 %, 248.67 W, P2

This is also useful: nvidia-smi -q -d PERFORMANCE | grep -E "Performance State|Idle|Slowdown" Performance State : P8 Idle : Active HW Slowdown : Not Active HW Thermal Slowdown : Not Active HW Power Brake Slowdown : Not Active SW Thermal Slowdown : Not Active

domalab commented 4 days ago

@martindell Would you mind testing experimental gpu monitoring feature?

If you can, then I'll upload the code and let you know how to test it.

martindell commented 4 days ago

Sure, I'd be delighted to 👍

s1mpleman commented 4 days ago

@martindell Would you mind testing experimental gpu monitoring feature?

If you can, then I'll upload the code and let you know how to test it.

Happy to test as well, just came here to make the same feature request.