看起来你正在使用的是桌面版的 Ubuntu 22.04。 你可以从官方的 apt 软件源中使用 cpupower-gui。
$ sudo apt install cpupower-gui
它允许您单独设置每个CPU的调频策略,或者一次性为所有CPU设置。因此,您可以立即将其设置为“性能”并应用。
要运行该程序,只需按下超级键/Windows键,然后键入“cpupower”,从启动器中启动该程序。或者,您也可以从终端中启动它。
$ cpupower-gui
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
$ cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
performance
performance
performance
performance
performance
performance
performance
performance
performance
performance
performance
performance
performance
performance
performance
performance
sudo systemctl mask power-profiles-daemon.service
sudo systemctl stop power-profiles-daemon.service
然后我在以下位置创建了三个文件:
/etc/default/mygovernor
-rw-r--r-- 1 root root 447 Oct 2 13:11 mygovernor
文件内容如下:
# J.T. 2022-10-02
# Environment file for systemd service /etc/systemd/system /mygovernor.service
# which set the cpufreq governor to be used by the system. A list of supported
# governors may be found by the following command:
# "cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors"
# conservative ondemand userspace powersave performance schedutil
#GOVERNOR=powersave
#GOVERNOR=schedutil
#GOVERNOR=ondemand
GOVERNOR=performance
#! /bin/bash
# J.T. 2022-10-02
# This script is called by script /etc/systemd/system/mygovernor.service
# It will set the CPU Frequency Scaling governor to the value passed in
# the first command line argument "$1"
set -eu
FIRSTCPU=$(cut -f1 -d- /sys/devices/system/cpu/online)
AVAILABLE=$(/bin/cat /sys/devices/system/cpu/cpu${FIRSTCPU}/cpufreq/scaling_available_governors)
# Check if the specified commandline governor ID is supported on this PC
GOVERNOR=""
for gov in ${AVAILABLE}; do
if [[ "${gov}" == "${1}" ]]; then
GOVERNOR="${gov}"
break
fi
done
if [ -z ${GOVERNOR} ]; then
echo "Unknown governor =" \"${1}\"
exit 1
fi
echo "Setting CPUFreq Scaling governor = \"$GOVERNOR\" for all CPUs"
for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
do
[ -f "${CPUFREQ}" ] || continue
echo -n "${GOVERNOR}" > ${CPUFREQ}
done
# J.T. 2022-10-02
# This service set the cpufreq scaling governor, to the value of
# environment variable "GOVERNOR" defined in file "/etc/default/mygovernor"
# This service will not execute unless Ubuntu service "power-profiles-daemon.service"
# is masked. It may be masked with the following command:
# "sudo systemctl mask power-profiles-daemon.service"
[Unit]
Description=Set CPU Frequency Scaling governor
ConditionVirtualization=no
ConditionPathExists=/sys/devices/system/cpu/online
[Service]
Type=idle
EnvironmentFile=/etc/default/mygovernor
ExecCondition=/bin/bash -xc '/bin/systemctl is-masked --quiet power-profiles-daemon.service && exit 1 || exit 0'
ExecStart=/etc/systemd/set-mygovernor ${GOVERNOR}
[Install]
WantedBy=multi-user.target
sudo systemctl enable mygovernor.service
sudo systemctl start mygovernor.service
#!/bin/bash
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
chmod +x set_performance.sh
sudo nano /etc/systemd/system/myscript.service
[Unit]
Description=My Script
After=network.target
[Service]
ExecStart=/path/to/myscript.sh
[Install]
WantedBy=default.target
sudo systemctl daemon-reload
sudo systemctl enable myscript.service
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
。然后检查它:grep . /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
。我只使用原始命令进行工作,您可能有其他运行中的东西覆盖了原始命令。 - Doug Smythiessudo POWER_PROFILE_DAEMON_FAKE_DRIVER=1 /usr/libexec/power-profiles-daemon -r -v
我使它起作用。它告诉我当前处于平衡模式。所以我切换到性能模式,现在错误消失了。但说实话,每次启动都要手动进行这些操作非常令人沮丧,而且我也不确定性能模式是否真正起作用,或者只是名义上的。 - facialrecognition