前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Ubuntu设置CPU频率cpufrequtils

Ubuntu设置CPU频率cpufrequtils

作者头像
zhangrelay
发布2023-02-26 18:57:46
2.8K0
发布2023-02-26 18:57:46
举报
文章被收录于专栏:机器人课程与技术

安装:

代码语言:javascript
复制
sudo apt install cpufrequtils 

安装完成之后:

  1. cpufreq-aperf
  2. cpufreq-info
  3. cpufreq-set

如果要设置为性能模式:

命令是:sudo cpufreq-set -g performance

查看CPU设置后效果:

代码语言:javascript
复制
$ cpufreq-info 
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 10.0 us.
  hardware limits: 933 MHz - 2.53 GHz
  available frequency steps: 2.53 GHz, 2.40 GHz, 2.27 GHz, 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz, 1.47 GHz, 1.33 GHz, 1.20 GHz, 1.07 GHz, 933 MHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 933 MHz and 2.53 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency is 2.03 GHz.
  cpufreq stats: 2.53 GHz:52.30%, 2.40 GHz:0.32%, 2.27 GHz:0.35%, 2.13 GHz:0.34%, 2.00 GHz:0.36%, 1.87 GHz:0.42%, 1.73 GHz:0.28%, 1.60 GHz:0.38%, 1.47 GHz:0.51%, 1.33 GHz:0.98%, 1.20 GHz:1.37%, 1.07 GHz:7.04%, 933 MHz:35.35%  (8411)
analyzing CPU 1:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 1
  CPUs which need to have their frequency coordinated by software: 1
  maximum transition latency: 10.0 us.
  hardware limits: 933 MHz - 2.53 GHz
  available frequency steps: 2.53 GHz, 2.40 GHz, 2.27 GHz, 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz, 1.47 GHz, 1.33 GHz, 1.20 GHz, 1.07 GHz, 933 MHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 933 MHz and 2.53 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 2.43 GHz.
  cpufreq stats: 2.53 GHz:45.33%, 2.40 GHz:0.33%, 2.27 GHz:0.33%, 2.13 GHz:0.28%, 2.00 GHz:0.35%, 1.87 GHz:0.40%, 1.73 GHz:0.37%, 1.60 GHz:0.39%, 1.47 GHz:0.64%, 1.33 GHz:0.86%, 1.20 GHz:1.55%, 1.07 GHz:4.69%, 933 MHz:44.47%  (8822)
analyzing CPU 2:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 2
  CPUs which need to have their frequency coordinated by software: 2
  maximum transition latency: 10.0 us.
  hardware limits: 933 MHz - 2.53 GHz
  available frequency steps: 2.53 GHz, 2.40 GHz, 2.27 GHz, 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz, 1.47 GHz, 1.33 GHz, 1.20 GHz, 1.07 GHz, 933 MHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 933 MHz and 2.53 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1.84 GHz.
  cpufreq stats: 2.53 GHz:45.94%, 2.40 GHz:0.26%, 2.27 GHz:0.37%, 2.13 GHz:0.39%, 2.00 GHz:0.50%, 1.87 GHz:0.31%, 1.73 GHz:0.32%, 1.60 GHz:0.28%, 1.47 GHz:0.54%, 1.33 GHz:0.82%, 1.20 GHz:1.65%, 1.07 GHz:5.84%, 933 MHz:42.77%  (8362)
analyzing CPU 3:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 3
  CPUs which need to have their frequency coordinated by software: 3
  maximum transition latency: 10.0 us.
  hardware limits: 933 MHz - 2.53 GHz
  available frequency steps: 2.53 GHz, 2.40 GHz, 2.27 GHz, 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz, 1.47 GHz, 1.33 GHz, 1.20 GHz, 1.07 GHz, 933 MHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 933 MHz and 2.53 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 2.30 GHz.
  cpufreq stats: 2.53 GHz:44.93%, 2.40 GHz:0.35%, 2.27 GHz:0.38%, 2.13 GHz:0.38%, 2.00 GHz:0.31%, 1.87 GHz:0.33%, 1.73 GHz:0.37%, 1.60 GHz:0.36%, 1.47 GHz:0.56%, 1.33 GHz:0.81%, 1.20 GHz:1.54%, 1.07 GHz:6.20%, 933 MHz:43.49%  (8707)

制定固定频率:2.53Ghz

sudo cpufreq-set -f 2.53Ghz

代码语言:javascript
复制
cpufreq-info 
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 10.0 us.
  hardware limits: 933 MHz - 2.53 GHz
  available frequency steps: 2.53 GHz, 2.40 GHz, 2.27 GHz, 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz, 1.47 GHz, 1.33 GHz, 1.20 GHz, 1.07 GHz, 933 MHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 933 MHz and 2.53 GHz.
                  The governor "userspace" may decide which speed to use
                  within this range.
  current CPU frequency is 2.53 GHz.
  cpufreq stats: 2.53 GHz:87.73%, 2.40 GHz:0.08%, 2.27 GHz:0.09%, 2.13 GHz:0.09%, 2.00 GHz:0.09%, 1.87 GHz:0.11%, 1.73 GHz:0.07%, 1.60 GHz:0.10%, 1.47 GHz:0.13%, 1.33 GHz:0.25%, 1.20 GHz:0.35%, 1.07 GHz:1.81%, 933 MHz:9.09%  (8411)
analyzing CPU 1:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 1
  CPUs which need to have their frequency coordinated by software: 1
  maximum transition latency: 10.0 us.
  hardware limits: 933 MHz - 2.53 GHz
  available frequency steps: 2.53 GHz, 2.40 GHz, 2.27 GHz, 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz, 1.47 GHz, 1.33 GHz, 1.20 GHz, 1.07 GHz, 933 MHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 933 MHz and 2.53 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 2.53 GHz.
  cpufreq stats: 2.53 GHz:16.04%, 2.40 GHz:0.15%, 2.27 GHz:0.16%, 2.13 GHz:0.16%, 2.00 GHz:0.16%, 1.87 GHz:0.21%, 1.73 GHz:0.20%, 1.60 GHz:0.22%, 1.47 GHz:0.31%, 1.33 GHz:0.52%, 1.20 GHz:1.07%, 1.07 GHz:2.98%, 933 MHz:77.82%  (19676)
analyzing CPU 2:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 2
  CPUs which need to have their frequency coordinated by software: 2
  maximum transition latency: 10.0 us.
  hardware limits: 933 MHz - 2.53 GHz
  available frequency steps: 2.53 GHz, 2.40 GHz, 2.27 GHz, 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz, 1.47 GHz, 1.33 GHz, 1.20 GHz, 1.07 GHz, 933 MHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 933 MHz and 2.53 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 2.53 GHz.
  cpufreq stats: 2.53 GHz:16.09%, 2.40 GHz:0.16%, 2.27 GHz:0.16%, 2.13 GHz:0.16%, 2.00 GHz:0.21%, 1.87 GHz:0.16%, 1.73 GHz:0.19%, 1.60 GHz:0.18%, 1.47 GHz:0.28%, 1.33 GHz:0.53%, 1.20 GHz:1.11%, 1.07 GHz:3.17%, 933 MHz:77.57%  (18850)
analyzing CPU 3:
  driver: acpi-cpufreq
  CPUs which run at the same hardware frequency: 3
  CPUs which need to have their frequency coordinated by software: 3
  maximum transition latency: 10.0 us.
  hardware limits: 933 MHz - 2.53 GHz
  available frequency steps: 2.53 GHz, 2.40 GHz, 2.27 GHz, 2.13 GHz, 2.00 GHz, 1.87 GHz, 1.73 GHz, 1.60 GHz, 1.47 GHz, 1.33 GHz, 1.20 GHz, 1.07 GHz, 933 MHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 933 MHz and 2.53 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 2.53 GHz.
  cpufreq stats: 2.53 GHz:15.86%, 2.40 GHz:0.17%, 2.27 GHz:0.17%, 2.13 GHz:0.21%, 2.00 GHz:0.16%, 1.87 GHz:0.17%, 1.73 GHz:0.21%, 1.60 GHz:0.22%, 1.47 GHz:0.28%, 1.33 GHz:0.49%, 1.20 GHz:1.06%, 1.07 GHz:2.95%, 933 MHz:78.05%  (19112)

CPU:0-3都工作在2.53Ghz。

cpufreq-set -g参数可以用来设置 CPU 的频率,可以控制 CPU 的工作频率,从而实现节能和性能的优化。它的具体功能包括:控制 CPU 的最大和最小工作频率,设置 CPU 频率的调节策略,设置 CPU 的功耗模式,以及设置 CPU 的功耗管理策略。

代码语言:javascript
复制
   cpufrequtils 008: cpufreq-set (C) Dominik Brodowski 2004-2009   
Report errors and bugs to cpufreq@vger.kernel.org, please.   
Usage: cpufreq-set [options]   
Options:   
 -c CPU, --cpu CPU number of CPU where cpufreq settings shall be modified   
 -d FREQ, --min FREQ new minimum CPU frequency the governor may select   
 -u FREQ, --max FREQ new maximum CPU frequency the governor may select   
 -g GOV, --governor GOV new cpufreq governor   
 -f FREQ, --freq FREQ specific frequency to be set. Requires userspace   
 governor to be available and loaded   
 -r, --related Switches all hardware-related CPUs   
 -h, --help Prints out this screen   
Notes:   
1. Omitting the -c or --cpu argument is equivalent to setting it to zero   
2. The -f FREQ, --freq FREQ parameter cannot be combined with any other parameter   
 except the -c CPU, --cpu CPU parameter   
3. FREQuencies can be passed in Hz, kHz (default), MHz, GHz, or THz   
 by postfixing the value with the wanted unit name, without any space   
 (FREQuency in kHz =^ Hz * 0.001 =^ MHz * 1000 =^ GHz * 1000000).  

cpufrequils用于控制CPU频率缩放功能(速度步进、节流等)。

该软件包主要有2个程序:

/usr/bin/cpufreq-info

/usr/bin/cpufreq-set

它基本上是使用Sys界面的一种用户友好的选择。

频率缩放允许您动态设置CPU频率或指定自动调速器。通过在计算机空闲时降低CPU频率,可以保留大量电池电量并保持系统冷却。

默认情况下,大多数系统使用ondemand调控器。对于电池供电的环境,保守型和节能型调速器更为有利。

cpufreq-set 是一个用于调整 CPU 频率的命令行工具,可以用来设置 CPU 的最大、最小频率、检查当前频率设置等。

使用 cpufreq-set 命令的具体案例:

设置 CPU 的最大频率:

sudo cpufreq-set -c 0 -u 2.6GHz

设置 CPU 的最小频率:

sudo cpufreq-set -c 0 -d 1.2GHz

检查当前频率设置:

cpufreq-info

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-02-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
命令行工具
腾讯云命令行工具 TCCLI 是管理腾讯云资源的统一工具。使用腾讯云命令行工具,您可以快速调用腾讯云 API 来管理您的腾讯云资源。此外,您还可以基于腾讯云的命令行工具来做自动化和脚本处理,以更多样的方式进行组合和重用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档