AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1226254
Accepted
sam
sam
Asked: 2020-04-12 09:08:38 +0800 CST2020-04-12 09:08:38 +0800 CST 2020-04-12 09:08:38 +0800 CST

设置 Intel H 系列 CPU 的 Max TDP

  • 772

我正在寻找一些程序来设置 CPU 的最大 TDP,就像我们在 Windows 上的 Intel XTU 中所做的那样。我可以通过这个项目降低 CPU 的电压。我还可以使用这个优秀的项目来监控 CPU 的 TDP 。我在 Internet 上搜索过任何此类程序,但找不到。

编辑1:

我的系统有一个 Core i7-9750H CPU,最大 TDP 由 OEM 设置为 60 瓦,在内核 4.18.20-041820-generic 的 Ubuntu 18.04LTS 上运行。

编辑 2

我已将内核更新为 5.3.0-46-generic (signed),输出sudo turbostat --Summary --interval 5 --show Avg_MHz,Busy%,Bzy_MHz,IRQ,PkgTmp,PkgWatt,GFXWatt如下:

...
cpu0: MSR_RAPL_POWER_UNIT: 0x000a0e03 (0.125000 Watts, 0.000061 Joules, 0.000977 sec.)
cpu0: MSR_PKG_POWER_INFO: 0x00000168 (45 W TDP, RAPL 0 - 0 W, 0.000000 sec.)
cpu0: MSR_PKG_POWER_LIMIT: 0x42835800dd8230 (UNlocked)
cpu0: PKG Limit #1: ENabled (70.000000 Watts, 28.000000 sec, clamp ENabled)
cpu0: PKG Limit #2: ENabled (107.000000 Watts, 0.002441* sec, clamp DISabled)
...

的输出rdmsr --bitfield 14:0 -d 0x610为 560。这意味着最大输出为 0.125 * 560 = 70 瓦

的输出sudo rdmsr 0x610是 42835800dd8230。

您能否详细说明计算@doug-smythies

power-management cpu 18.04 intel-cpu
  • 1 1 个回答
  • 4715 Views

1 个回答

  • Voted
  1. Best Answer
    Doug Smythies
    2020-04-12T12:33:47+08:002020-04-12T12:33:47+08:00

    对于您的处理器Core i7 9750H,默认 TDP 为 45 瓦。如果您的处理器支持它,您可以调整 TDP。

    方法一

    本例使用 i5-9600K。首先我使用 turbostat(linux-tools-common 包)来查看 TDP 现在是什么,以及比例因子是什么:

    doug@s18:~$ sudo turbostat --Summary --interval 5 --show Avg_MHz,Busy%,Bzy_MHz,IRQ,PkgTmp,PkgWatt,GFXWatt
    ...
    cpu0: MSR_RAPL_POWER_UNIT: 0x000a0e03 (0.125000 Watts, 0.000061 Joules, 0.000977 sec.)
    cpu0: MSR_PKG_POWER_INFO: 0x000002f8 (95 W TDP, RAPL 0 - 0 W, 0.000000 sec.)
    cpu0: MSR_PKG_POWER_LIMIT: 0x4283e800dd8320 (UNlocked)
    cpu0: PKG Limit #1: ENabled (100.000000 Watts, 28.000000 sec, clamp ENabled)
    cpu0: PKG Limit #2: ENabled (125.000000 Watts, 0.002441* sec, clamp DISabled)
    ...
    

    所以,我们知道比例因子是 0.125 瓦,而且似乎有人已经将功率限制从默认的 95 调整到了 100 瓦,但是让我们通过直接读取 MSR 来检查:

    root@s18:/home/doug# rdmsr --bitfield 14:0 0x610
    320
    
    root@s18:/home/doug# rdmsr --bitfield 14:0 -d 0x610
    800
    

    请注意,我读了两次寄存器,一次是十六进制(以 16 为底),一次是十进制(以 10 为底)。

    800 * 0.125 = 100 瓦。

    现在,假设我想让它变成 50 瓦,首先再次读取寄存器,但保留所有内容:

    root@s18:/home/doug# rdmsr 0x610
    4283e800dd8320
    

    现在更改适当的位字段(从上面的 14 到 0)。对于最低有效 16 位,我们有:

    8    3    2    0
    1000 0011 0010 0000
    

    取出 0x320(800 base 10)并放入 50 / 0.125 = 400 = 0x190:

    8    1    9    0
    1000 0001 1001 0000
    
    root@s18:/home/doug# wrmsr 0x610 0x4283e800DD8190
    root@s18:/home/doug# rdmsr 0x610
    4283e800dd8190
    

    并用 turbostat 检查它:

    doug@s18:~$ sudo ~/turbostat --Summary --interval 5 --show Avg_MHz,Busy%,Bzy_MHz,IRQ,PkgTmp,PkgWatt,GFXWatt
    ...
    cpu0: MSR_RAPL_POWER_UNIT: 0x000a0e03 (0.125000 Watts, 0.000061 Joules, 0.000977 sec.)
    cpu0: MSR_PKG_POWER_INFO: 0x000002f8 (95 W TDP, RAPL 0 - 0 W, 0.000000 sec.)
    cpu0: MSR_PKG_POWER_LIMIT: 0x4283e800dd8190 (UNlocked)
    cpu0: PKG Limit #1: ENabled (50.000000 Watts, 28.000000 sec, clamp ENabled)
    cpu0: PKG Limit #2: ENabled (125.000000 Watts, 0.002441* sec, clamp DISabled)
    ... And now test it:
    Avg_MHz Busy%   Bzy_MHz IRQ     PkgTmp  PkgWatt GFXWatt
    0       0.02    921     205     29      1.90    0.00
    0       0.03    834     195     29      1.90    0.00
    14      0.42    3440    384     29      2.06    0.00
    0       0.03    800     196     29      1.90    0.00
    0       0.03    812     190     29      1.90    0.00
    0       0.03    800     212     29      1.90    0.00  <<< System idle
    0       0.03    811     204     29      1.90    0.00
    3148    72.23   4358    9875    63      97.48   0.00  <<< Heavy load applied
    3612    82.93   4355    11226   65      111.60  0.00  <<< Lots of power being used
    3609    82.94   4351    11182   65      111.50  0.00
    3120    83.35   3743    11145   45      72.32   0.00
    2833    83.58   3389    11141   45      49.79   0.00  <<< Power limited to 50 watts
    2838    83.58   3395    11179   45      49.85   0.00
    2836    83.58   3393    11191   45      49.89   0.00
    2837    83.58   3394    11119   46      49.90   0.00
    2839    83.58   3397    11160   46      49.94   0.00
    2838    83.58   3395    11148   46      49.91   0.00
    2838    83.58   3395    11160   46      49.94   0.00
    2838    83.58   3395    11284   46      49.94   0.00
    654     19.28   3390    2807    32      12.97   0.00
    0       0.03    803     202     32      1.90    0.00
    0       0.03    802     172     32      1.90    0.00
    

    参考:英特尔 SDM

    方法二

    实际上有一个更简单的方法:

    查看确定是否可以使用此方法:

    doug@s18:~$ grep . /sys/class/powercap/intel-rapl/intel-rapl:0/*
    /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_max_power_uw:95000000
    /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_name:long_term
    /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_power_limit_uw:100000000
    /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_time_window_us:27983872
    /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_1_max_power_uw:0
    /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_1_name:short_term
    /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_1_power_limit_uw:125000000
    /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_1_time_window_us:2440
    grep: /sys/class/powercap/intel-rapl/intel-rapl:0/device: Is a directory
    /sys/class/powercap/intel-rapl/intel-rapl:0/enabled:1
    /sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj:259409601961
    grep: /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:0: Is a directory
    grep: /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:1: Is a directory
    grep: /sys/class/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:2: Is a directory
    /sys/class/powercap/intel-rapl/intel-rapl:0/max_energy_range_uj:262143328850
    /sys/class/powercap/intel-rapl/intel-rapl:0/name:package-0
    grep: /sys/class/powercap/intel-rapl/intel-rapl:0/power: Is a directory
    grep: /sys/class/powercap/intel-rapl/intel-rapl:0/subsystem: Is a directory
    

    注意启用线和当前值(如上所示):

        /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_power_limit_uw:100000000
    /sys/class/powercap/intel-rapl/intel-rapl:0/enabled:1
    

    现在更改它并检查:

    doug@s18:~$ echo "93500000" | sudo tee /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_power_limit_uw
    doug@s18:~$ cat /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_power_limit_uw
    93500000
    

    并检查 turbostat:

    doug@s18:~$ sudo ./turbostat --Summary --interval 5 --show Avg_MHz,Busy%,Bzy_MHz,IRQ,PkgTmp,PkgWatt,GFXWatt
    ...
    cpu0: MSR_PKG_POWER_LIMIT: 0x4203e800dc82ec (UNlocked)
    cpu0: PKG Limit #1: ENabled (93.500000 Watts, 28.000000 sec, clamp DISabled)
    ...
    

    请注意,在另一台计算机上,即使处理器未锁定并且位置显示为根可写,这些东西也不起作用(任何一种方法):

    doug@s15:~$ ls -l /sys/class/powercap/intel-rapl/intel-rapl:0/enabled
    -rw-r--r-- 1 root root 4096 Apr 26 08:00 /sys/class/powercap/intel-rapl/intel-rapl:0/enabled
    doug@s15:~$ echo 1 | sudo tee /sys/class/powercap/intel-rapl/intel-rapl:0/enabled
    1
    tee: '/sys/class/powercap/intel-rapl/intel-rapl:0/enabled': Function not implemented
    
    • 5

相关问题

  • 禁用“按需”CPU 缩放守护程序

  • 如何从命令行挂起/休眠?

  • 登录失败并显示低图形然后崩溃?[关闭]

  • 延长笔记本电脑和笔记本电脑电池寿命的技巧

  • 如何让“您的电池坏了”消息消失?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve