Skip to content

Instantly share code, notes, and snippets.

@wodor
Created February 16, 2025 16:01
Show Gist options
  • Select an option

  • Save wodor/d2a87b64445c1d07527061ebd725dec3 to your computer and use it in GitHub Desktop.

Select an option

Save wodor/d2a87b64445c1d07527061ebd725dec3 to your computer and use it in GitHub Desktop.
Control fan from nvidia-smi
#! /bin/bash
TEMP=$(nvidia-smi -q -d temperature | grep "GPU Current" | tail -n 1 | cut -d ":" -f 2 | cut -d " " -f 2)
DEVICE=/sys/devices/platform/nct6775.2608/hwmon/hwmon2/pwm1
echo 1 > /sys/devices/platform/nct6775.2608/hwmon/hwmon2/pwm1_enable
while true; do
TEMP=$(nvidia-smi -q -d temperature | grep "GPU Current" | tail -n 1 | cut -d ":" -f 2 | cut -d " " -f 2)
echo "Current temperature: $TEMP"
if (( TEMP > 70 )); then
# echo "Temperature is above 75, writing 256 to /tmp/test"
echo 256 > $DEVICE
elif (( TEMP > 50 )); then
# echo "Temperature is above 50, writing 150 to /tmp/test"
echo 160 > $DEVICE
elif (( TEMP > 40 )); then
# echo "Temperature is above 40, writing 130 "
echo 130 > $DEVICE
else
# echo "Temperature is below 40, writing 0"
echo 0 > $DEVICE
fi
sleep 1
done
@wodor
Copy link
Author

wodor commented Feb 16, 2025

$ cat /proc/modules | grep nct
nct6775 40960 0 - Live 0x0000000000000000
nct6775_core 106496 1 nct6775, Live 0x0000000000000000
hwmon_vid 12288 1 nct6775, Live 0x0000000000000000

@wodor
Copy link
Author

wodor commented Feb 16, 2025

$ cat /etc/modules-load.d/modules.conf
coretemp
lm75
nct6775

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