prasanthrangan / hyprdots

// Aesthetic, dynamic and minimal dots for Arch hyprland
GNU General Public License v3.0
7.04k stars 840 forks source link

Customize GPU info #348

Closed xfathurrahman closed 12 months ago

xfathurrahman commented 12 months ago

Device: Asus ROG GL553VD with Nvidia 1050

I'm having an issue with nvidia-powerd.service, where the service doesn't run, and it causes the GPU status's power usage to go undetected.

231018_03h34m49s_screenshot

Is it not supported for my GPU? If it's indeed not supported and can't be fixed, how can I customize GPU information in Waybar to remove the Power Usage information? Thank you in advance, and thanks for your hard work! šŸ”„

status: 231018_03h38m54s_screenshot

nvidia-smi: 231018_03h45m54s_screenshot

lspci | grep -i nvidia: 231018_03h47m26s_screenshot

T-Crypt commented 12 months ago

Did you try to enable this service? systemctl enable nvidia-powerd.service

This might be due to the update for the nvidia driver being corrupted or installed incorrectly or it isn't support anymore in the latest driver version. Was it working before the update to 535.104.05?

If you want to remove the power usage you can replace the script in .config/hypr/scripts/gpuinfo.sh with the script below!


#!/bin/bash

# Check for NVIDIA GPU using nvidia-smi
nvidia_gpu=$(nvidia-smi --query-gpu=gpu_name --format=csv,noheader,nounits | head -n 1)

# Function to execute the AMD GPU Python script and use its output
execute_amd_script() {
  local amd_output
  amd_output=$(python3 ~/.config/hypr/scripts/amdgpu.py)
  echo "$amd_output"
}

# Function to get Intel GPU temperature from 'sensors'
get_intel_gpu_temperature() {
  local temperature
  temperature=$(sensors | grep "Package id 0" | awk '{print $4}' | sed 's/+//;s/Ā°C//;s/\.0//')
  echo "$temperature"
}

# Function to define emoji based on temperature
get_temperature_emoji() {
  local temperature="$1"
  if [ "$temperature" -lt 60 ]; then
    echo "ā„ļø"  # Ice emoji for less than 60Ā°C
  else
    echo "šŸ”„"  # Fire emoji for 60Ā°C or higher
  fi
}

# Check if primary GPU is NVIDIA
if [ -n "$nvidia_gpu" ]; then
  # if nvidia-smi failed, format and exit. 
  if [[ $nvidia_gpu == *"NVIDIA-SMI has failed"* ]]; then
    # Print the formatted information in JSON
    echo "{\"text\":\"N/A\", \"tooltip\":\"Primary GPU: Not found\"}"
    exit 0
  fi

  primary_gpu="NVIDIA GPU"
 # Collect GPU information for NVIDIA without power usage
gpu_info=$(nvidia-smi --query-gpu=temperature.gpu,utilization.gpu,clocks.current.graphics,clocks.max.graphics --format=csv,noheader,nounits)
# Split the comma-separated values into an array
IFS=',' read -ra gpu_data <<< "$gpu_info"
# Extract individual values
temperature="${gpu_data[0]// /}"
utilization="${gpu_data[1]// /}"
current_clock_speed="${gpu_data[2]// /}"
max_clock_speed="${gpu_data[3]// /}"

# Get emoji based on temperature
emoji=$(get_temperature_emoji "$temperature")

# Print the formatted information in JSON
echo "{\"text\":\"$temperatureĀ°C\", \"tooltip\":\"Primary GPU: $primary_gpu\n$emoji Temperature: $temperatureĀ°C\n󰾆 Utilization: $utilization%\nī‰¦ Clock Speed: $current_clock_speed/$max_clock_speed MHz\"}"
else
  # Execute the AMD GPU Python script and use its output
  amd_output=$(execute_amd_script)
  # Extract GPU Temperature, GPU Load, GPU Core Clock, and GPU Power Usage from amd_output
  temperature=$(echo "$amd_output" | jq -r '.["GPU Temperature"]' | sed 's/Ā°C//')
  gpu_load=$(echo "$amd_output" | jq -r '.["GPU Load"]' | sed 's/%//')
  core_clock=$(echo "$amd_output" | jq -r '.["GPU Core Clock"]' | sed 's/ GHz//;s/ MHz//')
  power_usage=$(echo "$amd_output" | jq -r '.["GPU Power Usage"]' | sed 's/ Watts//')

  # Get emoji based on temperature
  emoji=$(get_temperature_emoji "$temperature")

  # Print the formatted information in JSON
  if [ -n "$temperature" ]; then
    primary_gpu="AMD GPU"
    echo "{\"text\":\"$temperatureĀ°C\", \"tooltip\":\"Primary GPU: $primary_gpu\n$emoji Temperature: $temperatureĀ°C\n󰾆 Utilization: $gpu_load%\nī‰¦ Clock Speed: $core_clock MHz\nļ‰‚ Power Usage: $power_usage W\"}"
  else
    # Check for Intel GPU
    primary_gpu="Intel GPU"
    intel_gpu=$(lspci -nn | grep -i "VGA compatible controller" | grep -i "Intel Corporation" | awk -F' ' '{print $1}')
    if [ -n "$intel_gpu" ]; then
      temperature=$(get_intel_gpu_temperature)
      emoji=$(get_temperature_emoji "$temperature")
      # Print the formatted information in JSON
      echo "{\"text\":\"$temperatureĀ°C\", \"tooltip\":\"Primary GPU: $primary_gpu\n$emoji Temperature: $temperatureĀ°C\"}"
    else
      primary_gpu="Not found"
      gpu_info=""
      # Print the formatted information in JSON
      echo "{\"text\":\"N/A\", \"tooltip\":\"Primary GPU: $primary_gpu\"}"
    fi
  fi
fi
xfathurrahman commented 12 months ago

Yes, I have tried enabling or restarting, but it still doesn't work. There is an error "SBIOS support not found for NVPCF GET_SUPPORTED function" when I check the service status. So i decide to disabled that service šŸ˜…

Actually, I just did a fresh install of Arch and Hyperdots, so I don't know if it was working on previous versions.

T-Crypt commented 12 months ago

From my understanding the nvidia-powerd.service is only available for the newer cards but I could be wrong.

I did a little research on your error and seems common on the 1000 series cards and could be related to the notebook itself based on boosting capabilities for the GPU.

I would just recommend using the script I provided above if you want to get rid of the power usage section for the waybar module!

xfathurrahman commented 12 months ago

Yeah, I was thinking the same. I've also tried to find out what's causing it, but couldn't find the answer. Nevertheless, thank you. These dotfiles are really cool!