0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

UbuntuでCPUをパフォーマンスモードに設定する方法

0
Posted at

はじめに

UbuntuでCPUの動作モード(CPU Governor)を変更し、パフォーマンスモードに設定する方法を紹介する。UbuntuではCPUの動作モード(CPU Governor)を変更することで、省電力重視または性能重視の動作を選択できる。本記事では、CPU Governorをperformanceへ変更する方法を紹介する。

動作確認環境

  • Ubuntu 22.04 x86_64

方法

依存関係のインストール

以下のコマンドを実行して、依存関係をインストールする。

sudo apt update
sudo apt install linux-tools-common linux-tools-generic
sudo apt install linux-tools-$(uname -r)

現状確認

以下のコマンドを実行する。

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

以下のようにpowersaveと表示される場合は、省電力寄りの設定になっている。

powersave

以下のコマンドを実行して、CPUをパフォーマンスモードに設定する。

sudo cpupower frequency-set -g performance

cpupowerが利用できない場合は、以下のようにsysfsから直接設定することもできる。

sudo bash -c 'for p in /sys/devices/system/cpu/cpufreq/policy*; do
  echo performance > $p/scaling_governor
  [ -w $p/energy_performance_preference ] && echo performance > $p/energy_performance_preference
done'

energy_performance_preferenceは、Intel CPUなどで利用されるEnergy Performance Preference (EPP)の設定であり、performanceを指定すると性能重視の制御となる。

パスワードが求められるので、パスワードを入力する。

[sudo] {username} のパスワード:

設定が変更されたかどうか、以下のコマンドを実行して確認する。

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

以下のようになっていればOK。

performance

この設定は再起動後に元へ戻る場合がある。永続化するには、systemdサービスやcpupower.serviceなどを利用する。

CPUの動作状態を詳しく確認したい場合は、以下のコマンドを実行する。

cpupower frequency-info

以下のようにCPUの動作状態が表示される(一例)。

analyzing CPU 32:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 32
  CPUs which need to have their frequency coordinated by software: 32
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 800 MHz - 4.60 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 800 MHz and 4.60 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 3.48 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes

まとめ

UbuntuでCPUの動作モード(CPU Governor)を変更し、パフォーマンスモードに設定する方法を紹介した。CPUを性能重視で動作させたい場合に試してみてほしい。

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?