如何解决 Ubuntu 18.04 中的 CPU 硬件崩溃问题

如何解决 Ubuntu 18.04 中的 CPU 硬件崩溃问题

几个月前我买了一台新电脑。我安装了 Ubuntu 18.04,它运行良好,除了编译 c++ 代码时:一旦 CPU 使用率飙升(10 个以上内核),它就会严重冻结。

唯一可行的解​​决方法是使用 进行编译-j8-j10大多数情况下,超过 或更高版本会导致系统崩溃。-j16大型项目(且没有 cca​​che)时 100% 会崩溃。

有关我的设置的详细信息:

  • 华硕游戏电脑:Asus Strix GT15 - 最佳购买链接。您猜对了,我买它是为了 GPU……否则我会自己用优质组件(尤其是 PSU 和散热器)组装它。
  • 主板:华硕 strix B460-G Gaming
  • 中央处理器:Intel Core i7-10700KF
  • 显卡:Nvidia 2070 Super
  • 电源:未知 OEM 500W 80 PLUS
  • 当 GPU 空闲(桌面)时会发生崩溃。
  • 由于所需的工作环境,我无法安装较新的 Ubuntu 版本。

我尝试过但没有解决问题的方法(虽然发生的频率较低,但仍然会发生):

简历:

  • 我将 Turbo 降低到最低限度(1 秒而不是 60 秒),对于这种炉子 CPU 来说,CPU 散热器似乎效率很低。
  • 如果 PSU 太弱,则减少 CPU/主板允许使用的安培数和最大瓦数。
  • 当 CPU 温度达到 50C 时,更快地提高风扇速度(温度并没有好多少,但现在编译时声音很大)
  • 用高品质导热膏替换 OEM“导热膏”(温度降低 2-3C)

崩溃记录:

  • journalctl -b -1没有任何关于崩溃的痕迹,所以我认为这是硬件 CPU 崩溃......
  • Ctrl-Alt-F* 键不起作用
  • 崩溃后无法通过 ssh 连接
  • 发生这种情况时音频也会崩溃
  • 我不认为 PSU 是问题所在,因为我可以同时使用stress -c 16和,系统不会崩溃。压力只使用 sqrt()..../gpu_burn 300

提前致谢!

更新 #1

时间:

  • 如果没有这些 BIOS 设置修改,在持续 100% CPU 使用率后,它们很容易升至 90C。在这些温度下,我没有让它运行足够长的时间。
  • 经过改造后,温度很少超过80C。
  • 冻结似乎与 CPU 使用率的突然飙升有关,而不是与高 CPU 温度有关。
  • 室温为20-22C
  • 空闲 CPU 温度为 27-28C

当前内核:

uname -a
Linux rog 5.4.0-87-generic #98~18.04.1-Ubuntu SMP Wed Sep 22 10:45:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

更新 #2

几个月后,即使软件节流阀设置为 40C(thermald),这个问题仍然存在。使用超过 8 个线程会导致问题。最终,我更新到了 Ubuntu 20.04(2022 年 4 月),问题解决了。正确的解决方案是将 Ubuntu 更新到 20.04 以获得完整的 CPU 支持。它解决了另一个问题:挂起功能无法在 18.04 上运行。

答案1

几个月后,即使软件节流阀设置为 40C(thermald),这个问题仍然会出现。使用超过 5 个线程会导致此问题。最终,我全新安装了 Ubuntu 20.04(2022 年 4 月),问题解决了。即使使用 -j16 和默认 bios 设置,计算机现在也可以编译我的大项目。

因此,正确的解决方案是将 Ubuntu 更新到 20.04 以获得完整的 CPU 支持。它解决了另一个问题:暂停功能在 18.04 上不起作用。

非常感谢道格·史密斯了解有关可用热监控软件的详细信息!

答案2

每个人都应该了解计算机的热特性,并提供足够的保护。用户通常不知道处理器封装温度会随着阶跃函数负载而迅速上升。我的 20.04 测试服务器的一个示例:

doug@s19:~$ sudo turbostat --quiet --Summary --show PkgWatt,PkgTmp --interval 0.1
PkgTmp  PkgWatt
33  1.88    
33  1.69    
33  1.56    
33  1.74    
49  24.99   800 degrees per second
57  133.28  80 degrees per second
61  133.66  40 degrees per second
61  132.58  0 degrees per second
63  133.57  
64  134.12

负载施加在采样时间的 4/5 左右(25 / (133.5 - 1.7) ~= 20%,即 4/5),温度已上升 16 度,即每秒 800 度。此处的负载是 prime95 酷刑测试,即最大热量子测试。示例计算机采用水冷,水泵始终以最大速率开启。处理器 i5-10600K。

对于华硕主板,请注意 CPU 风扇传感器实际上是一个外部热敏电阻,它会在时间和数值上滞后于实际处理器封装温度。在我的华硕主板上,在高负载下,CPU 风扇传感器会滞后于实际处理器温度 12 度。

最后,处理器封装温度可能会很快达到关机极限,以至于各种监控程序或守护进程甚至都没有注意到。有时热保护需要更快地做出反应,以便在任何过冲温度触发关机之前有时间生效。

方法一:Thermald

对于 `/etc/thermald/thermal-conf.xml`,使用非常基本和简单的配置,按照 `man thermal-conf.xml` 页面:
<?xml version="1.0"?>

<!--
use "man thermal-conf.xml" for details
-->

<!-- BEGIN -->
<ThermalConfiguration>
        <Platform>
                <Name>Overide CPU default passive</Name>
                <ProductName>*</ProductName>
                <Preference>QUIET</Preference>
                <ThermalZones>
                        <ThermalZone>
                                <Type>cpu</Type>
                                <TripPoints>
                                        <TripPoint>
                                                <Temperature>41000</Temperature>
                                                <type>passive</type>
                                        </TripPoint>
                                </TripPoints>
                        </ThermalZone>
                </ThermalZones>
        </Platform>
</ThermalConfiguration>
<!-- END -->

注意:我使用了 41 度这个非常低的跳变点,因为我的系统是水冷的,我无法达到所需的示例温度。

doug@s19:~$ sudo systemctl start thermald
doug@s19:~$ sudo systemctl status thermald
● thermald.service - Thermal Daemon Service
     Loaded: loaded (/lib/systemd/system/thermald.service; disabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-11-05 07:41:45 PDT; 17s ago
   Main PID: 3461 (thermald)
      Tasks: 2 (limit: 38214)
     Memory: 2.2M
     CGroup: /system.slice/thermald.service
             └─3461 /usr/sbin/thermald --systemd --dbus-enable --adaptive

Nov 05 07:41:45 s19 systemd[1]: Starting Thermal Daemon Service...
Nov 05 07:41:45 s19 systemd[1]: Started Thermal Daemon Service.
Nov 05 07:41:45 s19 thermald[3461]: 22 CPUID levels; family:model:stepping 0x6:a5:5 (6:165:5)
Nov 05 07:41:45 s19 thermald[3461]: 22 CPUID levels; family:model:stepping 0x6:a5:5 (6:165:5)
Nov 05 07:41:45 s19 thermald[3461]: Polling mode is enabled: 4
Nov 05 07:41:45 s19 thermald[3461]: sensor id 5 : No temp sysfs for reading raw temp
Nov 05 07:41:45 s19 thermald[3461]: sensor id 5 : No temp sysfs for reading raw temp
Nov 05 07:41:45 s19 thermald[3461]: sensor id 5 : No temp sysfs for reading raw temp
Nov 05 07:41:45 s19 thermald[3461]: XML zone: invalid sensor type []

虽然 thermald 状态显示出一些抱怨,但它实际上运行正常,尽管响应有点慢:

doug@s19:~$ sudo turbostat --quiet --Summary --show PkgWatt,PkgTmp --interval 1
PkgTmp  PkgWatt
33      1.44
33      1.34
33      1.33
58      63.26
61      114.43
61      114.68
48      86.59
47      55.48
47      55.53
41      42.77
43      33.43
41      34.30
41      28.04
43      33.63
40      34.45
44      33.57
41      34.40
44      33.85
34      14.50
34      1.33
34      1.33

根据需要调整触发点,以充分利用您的系统,同时仍防止过冲高点导致停机。触发点过低可能会使系统性能降低到不理想的水平。

方法 2:TCC 偏移

如果您的内核足够新并且您的处理器受支持,则可以使用 TCC 偏移让处理器本身进行热节流。根据计时窗口参数,响应时间可以更快。对于此示例,计时窗口在 BIOS 中设置为最快的响应时间:

首先,找到哪个冷却设备:

doug@s19:~$ grep . /sys/devices/virtual/thermal/cooling_device*/type
/sys/devices/virtual/thermal/cooling_device0/type:Fan
/sys/devices/virtual/thermal/cooling_device10/type:Processor
/sys/devices/virtual/thermal/cooling_device11/type:Processor
/sys/devices/virtual/thermal/cooling_device12/type:Processor
/sys/devices/virtual/thermal/cooling_device13/type:Processor
/sys/devices/virtual/thermal/cooling_device14/type:Processor
/sys/devices/virtual/thermal/cooling_device15/type:Processor
/sys/devices/virtual/thermal/cooling_device16/type:Processor
/sys/devices/virtual/thermal/cooling_device17/type:intel_powerclamp
/sys/devices/virtual/thermal/cooling_device18/type:TCC Offset
/sys/devices/virtual/thermal/cooling_device1/type:Fan
/sys/devices/virtual/thermal/cooling_device2/type:Fan
/sys/devices/virtual/thermal/cooling_device3/type:Fan
/sys/devices/virtual/thermal/cooling_device4/type:Fan
/sys/devices/virtual/thermal/cooling_device5/type:Processor
/sys/devices/virtual/thermal/cooling_device6/type:Processor
/sys/devices/virtual/thermal/cooling_device7/type:Processor
/sys/devices/virtual/thermal/cooling_device8/type:Processor
/sys/devices/virtual/thermal/cooling_device9/type:Processor

它是设备 18。设置偏移量,然后通过 turbostat 检查它(不使用 --quiet 选项):

doug@s19:~$ echo 59 | sudo tee /sys/devices/virtual/thermal/cooling_device18/cur_state
59
doug@s19:~$ sudo /home/doug/temp-k-git/linux/tools/power/x86/turbostat/turbostat --Summary --show Bzy_MHz,PkgWatt,PkgTmp --interval 0.1
turbostat version 21.05.04 - Len Brown <[email protected]>
CPUID(0): GenuineIntel 0x16 CPUID levels
CPUID(1): family:model:stepping 0x6:a5:5 (6:165:5) microcode 0xec
...
cpu0: MSR_IA32_TEMPERATURE_TARGET: 0x3b641422 (41 C) (100 default - 59 offset)
cpu0: MSR_IA32_PACKAGE_THERM_STATUS: 0x883f0800 (37 C)
...
Bzy_MHz PkgTmp  PkgWatt
800     33      1.35
800     33      1.34
800     34      1.40
4187    49      86.23
4100    52      91.72
4100    53      91.29
...

请注意,节流几乎是立即的,4.8 GHz 将是未节流的 CPU 频率。请注意,我的处理器(并非所有处理器)的节流限制是非涡轮最大时钟频率 4.1 GHz,因此它实际上无法达到 41 度的低限值。

编辑 1:要使 TCC 偏移方法在启动时自动设置,建议使用启动后服务。
编辑 2:TCC 偏移将在挂起/恢复循环后丢失。修改后的启动后服务现在如下。

doug@s19:~$ cat /etc/systemd/system/doug-post-boot-s19.service
[Unit]
Description=Doug post boot script for s19
After=suspend.target

[Service]
ExecStart=/home/doug/post-boot/doug-post-boot-s19.sh

[Install]
WantedBy=multi-user.target suspend.target

被调用的脚本是:

doug@s19:~$ cat post-boot/doug-post-boot-s19.sh
#!/bin/sh
#
# doug-post-boot-s19.sh 2022.04.11
#       For s19 Ubuntu test server.
#       Often this service is disabled, because
#       it isn't really needed.
#
#       Do desired post boot changes and configurations.

logger "doug-post-boot-s19.sh - begin..."#

/home/doug/post-boot/doug-set-tcc-offset.sh

# insert other scripts here, as required.

logger "doug-post-boot-s19.sh - exiting, done..."
exit 0

它调用:

doug@s19:~$ cat post-boot/doug-set-tcc-offset.sh
#!/bin/sh
#
# doug-set-tcc-offset.sh 2022.04.11
#       Set the desired TCC offset.
#       Requires a new enough kernel.
#       Note: The cooling device number is not
#       guarenteed not to change. This script
#       should be improved to auto figure out
#       the proper colling device. (I do not
#       know how.)

logger "doug-set-tcc-offset.sh - begin..."

# TCC is 100 degrees for s19.
# Therefore a trip point of 45 degrees requires an offset of 55.

echo 55 > /sys/devices/virtual/thermal/cooling_device18/cur_state

logger "doug-set-tcc-offset.sh - exiting, done..."
exit 0

注意:读者可能不明白我为什么只是从第一个脚本中调用另一个脚本。事实上,这台服务器不需要它,但在其他服务器上,我有许多启动后要做的事情,这样会更简洁。

一切设置完成后,启用服务:

doug@s19:~$ sudo systemctl enable doug-post-boot-s19.service
Created symlink /etc/systemd/system/multi-user.target.wants/doug-post-boot-s19.service → /etc/systemd/system/doug-post-boot-s19.service.

通过重启测试然后查询:

doug@s19:~$ sudo systemctl status doug-post-boot-s19.service
[sudo] password for doug:
● doug-post-boot-s19.service - Doug post boot script for s19
     Loaded: loaded (/etc/systemd/system/doug-post-boot-s19.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Mon 2022-04-11 17:19:19 PDT; 18s ago
    Process: 839 ExecStart=/home/doug/post-boot/doug-post-boot-s19.sh (code=exited, status=0/SUCCESS)
   Main PID: 839 (code=exited, status=0/SUCCESS)

Apr 11 17:19:19 s19 systemd[1]: Started Doug post boot script for s19.
Apr 11 17:19:19 s19 systemd[1]: doug-post-boot-s19.service: Succeeded.

最后检查偏移量是否确实设置:

doug@s19:~$ cat /sys/devices/virtual/thermal/cooling_device18/cur_state
55

相关内容