在运行Linux的无头节点上,如何控制多个消费类NVIDIA GPU(例如Titan和1080 Ti)的风扇速度?
在运行Linux的无头节点上,如何控制多个消费类NVIDIA GPU(例如Titan和1080 Ti)的风扇速度?
Answers:
以下是一种简单的方法,不需要编写脚本,连接假显示器或摆弄,可以通过SSH执行以控制多个NVIDIA GPU的风扇。它已在Arch Linux上进行了测试。
编辑:我现在不确定什么是最好的方法。以前,我建议过lspci -k | grep -A 2 -E "(VGA|3D)"。但是,这在我的新Threadripper系统上没有提供正确的ID。
有效的方法是sudo startx打开/var/log/Xorg.0.log(或startX在其输出中在“日志文件:”行下列出的任何位置),然后寻找该行NVIDIA(0): Valid display device(s) on GPU-<GPU number> at PCI:<PCI ID>。
/etc/X11/xorg.conf这是一个三GPU机器的示例:
Section "ServerLayout"
Identifier "dual"
Screen 0 "Screen0"
Screen 1 "Screen1" RightOf "Screen0"
Screen 1 "Screen2" RightOf "Screen1"
EndSection
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BusID "PCI:5:0:0"
Option "Coolbits" "7"
Option "AllowEmptyInitialConfiguration"
EndSection
Section "Device"
Identifier "Device1"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BusID "PCI:6:0:0"
Option "Coolbits" "7"
Option "AllowEmptyInitialConfiguration"
EndSection
Section "Device"
Identifier "Device2"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BusID "PCI:9:0:0"
Option "Coolbits" "7"
Option "AllowEmptyInitialConfiguration"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Device0"
EndSection
Section "Screen"
Identifier "Screen1"
Device "Device1"
EndSection
Section "Screen"
Identifier "Screen2"
Device "Device2"
EndSection
该BusID咄咄在上一步中确定的PCI ID匹配。AllowEmptyInitialConfiguration即使未连接监视器,该选项也允许X启动。该选件Coolbits可以控制风扇。它还可以允许超频,但这未经我测试。
/root/.xinitrcnvidia-settings -q fans
nvidia-settings -a [gpu:0]/GPUFanControlState=1 -a [fan:0]/GPUTargetFanSpeed=75
nvidia-settings -a [gpu:1]/GPUFanControlState=1 -a [fan:1]/GPUTargetFanSpeed=75
nvidia-settings -a [gpu:2]/GPUFanControlState=1 -a [fan:2]/GPUTargetFanSpeed=75
cat
为了方便起见,我使用.xinitrc执行nvidia设置,尽管可能还有其他方法。在这里,我将粉丝人数设置为75%。我阻止X服务器使用空cat命令关闭。这不是严格必要的,但是我发现有时候X卡关闭时,卡会拒绝离开P8低功耗状态,这会给我带来麻烦。第一行将打印出系统中的每个GPU风扇。
sudo startx -- :0
您可以从SSH执行此命令。输出将是:
Current version of pixman: 0.34.0
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Sat May 27 02:22:08 2017
(==) Using config file: "/etc/X11/xorg.conf"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
Attribute 'GPUFanControlState' (pushistik:0[gpu:0]) assigned value 1.
Attribute 'GPUTargetFanSpeed' (pushistik:0[fan:0]) assigned value 75.
Attribute 'GPUFanControlState' (pushistik:0[gpu:1]) assigned value 1.
Attribute 'GPUTargetFanSpeed' (pushistik:0[fan:1]) assigned value 75.
Attribute 'GPUFanControlState' (pushistik:0[gpu:2]) assigned value 1.
Attribute 'GPUTargetFanSpeed' (pushistik:0[fan:2]) assigned value 75.
nvidia-smi可用于观察温度和功率消耗。较低的温度将使该卡具有更高的时钟频率并增加其功耗。您可以sudo nvidia-smi -pl 150用来限制功耗并保持显卡散热,也可以sudo nvidia-smi -pl 300用来使其超频。如果给定150W,我的1080 Ti将以1480 MHz运行,如果给定300W,则将在1800 MHz以上运行,但这取决于工作负载。您可以使用以下命令nvidia-smi -q或更具体地监控其时钟速度,watch 'nvidia-smi -q | grep -E "Utilization| Graphics|Power Draw"'
重启。我还没有找到另一种使风扇自动运转的方法。
nvidia-settings -q fans节目?(您可以在.xinitrc中执行它)如果正确解决了所有风扇的问题,也许可以调整所有风扇。
AllowEmptyInitialConfiguration正确设置xorg.conf中的正确PCI ID?该文件可能很棘手。
nvidia-xconfig --allow-empty-initial-configuration --enable-all-gpus --cool-bits=28 --separate-x-screens
nvidia-smi -pl 120。这会将每个GPU的功耗限制为120W。您也可以使用nvidia-smi或来对内核和内存进行超频/欠频nvidia-settings。nvidia-smi此处的文档中有一个超频示例:devblogs.nvidia.com/… 如果已nvidia-settings安装,则可以使用时钟偏移,而不必使用特定的时钟:nvidia-settings -a [gpu]/GPUGraphicsClockOffset[3]=100
我已经编写了可点子安装的Python脚本,以执行类似于@AlexsandrDubinsky的建议。
当您运行fans.py时,它将为每个GPU设置一个临时的X服务器,并附加一个假显示器。然后,它每隔几秒钟循环遍历GPU,并根据其温度设置风扇速度。脚本死后,它将风扇的控制权返回给驱动程序并清理X服务器。
nvidia-settings