r/archlinux • • 3h ago

QUESTION NBFC > [Bug]: GPU never SUSPEND!

https://github.com/nbfc-linux/nbfc-linux/issues/317

I use Arch Linux, and the Nvidia driver has finally been updated. Device: i5-12500H, RTX 3050 Ti, Acer Nitro 5 AN515-58

Before, there was a "Runtime D3 status: Disabled" problem, which was fixed by the Nvidia driver update. Now the problem is that the GPU never suspends! It doesn't sleep at all.

I use the @GPU sensor, which always checks the temperature via nvidia-smi, and this keeps the GPU active!

When i use this command sudo systemctl stop nbfc_service after 15 seconds,

File: /sys/bus/pci/devices/0000:01:00.0/power/runtime_status -> suspended

So I created a sensor script, but I haven't used it yet. Instead, I want a script for the @GPU sensor that doesn't constantly use nvidia-smi, because that always wakes up the GPU.

Could you please help me create a flawless GPU sensor script? What do you think about below script?

#!/usr/bin/env bash

STATUS_FILE="/sys/bus/pci/devices/0000:01:00.0/power/runtime_status"
CACHE_FILE="/tmp/nbfc_gpu_temp.cache"
COOLDOWN=15

# 1. Kart uykudaysa önbelleği temizle ve sabit 38 döndür
if [[ -f "$STATUS_FILE" ]] && [[ "$(<"$STATUS_FILE")" == "suspended" ]]; then
    rm -f "$CACHE_FILE"
    echo 38
    exit 0
fi

NOW=$(date +%s)

# 2. Kart aktifse: Son okumadan bu yana 15 saniye geçmediyse nvidia-smi ÇALIŞTIRMA
# (Bu süre, oyun kapandıktan sonra GPU'nun uykuya dalabilmesi için gerekli boşluğu sağlar)
if [[ -f "$CACHE_FILE" ]]; then
    read -r LAST_TIME LAST_TEMP < "$CACHE_FILE"
    if (( NOW - LAST_TIME < COOLDOWN )); then
        echo "$LAST_TEMP"
        exit 0
    fi
fi

# 3. 15 saniye dolduysa ve kart hâlâ aktifse gerçek sıcaklığı oku ve önbelleğe yaz
TEMP=$(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits 2>/dev/null)

if [[ "$TEMP" =~ ^[0-9]+$ ]]; then
    echo "$NOW $TEMP" > "$CACHE_FILE"
    echo "$TEMP"
else
    echo 40
fi
1 Upvotes

0 comments sorted by