forked from ThomasRobertFr/gpu-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fan.sh
executable file
·81 lines (70 loc) · 2.21 KB
/
fan.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
headless=true
verbose=false
if [ "$headless" = true ] ; then
export DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0
fi
#Enable user defined fancontrol for all gpu
nvidia-settings -a "GPUFanControlState=1"
while true
do
#gpu index
i=0
#Get GPU temperature of all cards
for gputemp in $(nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader);do
if [ "$verbose" = true ] ; then
echo "gpu ${i} temp ${gputemp}";
fi
#Note: you need to set the minimum fan speed to a non-zero value, or it won't work
#This fan profile is being used in my GTX580 (Fermi). Change it as necessary
#If temperature is between X to Y degrees, set fanspeed to Z value
case "${gputemp}" in
0[0-9])
newfanspeed="20"
;;
1[0-9])
newfanspeed="20"
;;
2[0-9])
newfanspeed="20"
;;
3[0-9])
newfanspeed="20"
;;
4[0-9])
newfanspeed="35"
;;
5[0-4])
newfanspeed="50"
;;
5[5-6])
newfanspeed="60"
;;
5[7-9])
newfanspeed="60"
;;
6[0-5])
newfanspeed="60"
;;
6[6-9])
newfanspeed="70"
;;
7[0-5])
newfanspeed="80"
;;
7[6-9])
newfanspeed="90"
;;
*)
newfanspeed="90"
;;
esac
nvidia-settings -a "[fan-${i}]/GPUTargetFanSpeed=${newfanspeed}" 2>&1 >/dev/null
if [ "$verbose" = true ] ; then
echo "gpu ${i} new fanspeed ${newfanspeed}";
fi
sleep 3s
#increment gpu index
i=$(($i+1))
done
done