Added gpu_governor role

This commit is contained in:
2026-08-26 08:19:42 +02:00
parent 75f68198ce
commit 4340f5d6c2
4 changed files with 226 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
- name: Restart the GPU governor
become: true
ansible.builtin.systemd_service:
name: cyan-skillfish-governor-smu
state: restarted
+99
View File
@@ -0,0 +1,99 @@
- name: Check if the governor is already installed
ansible.builtin.command:
argv:
- pacman
- -Qq
- cyan-skillfish-governor-smu
register: is_gov_installed
changed_when: false
failed_when: false
- name: Build and install the governor from the AUR
when: is_gov_installed.rc != 0
block:
- name: Create temporary dir for build
ansible.builtin.tempfile:
state: directory
suffix: csgov
register: gov_tmp
- name: Download the AUR snapshot
ansible.builtin.get_url:
url: "https://aur.archlinux.org/cgit/aur.git/snapshot/cyan-skillfish-governor-smu.tar.gz"
dest: "{{ gov_tmp.path }}/cyan-skillfish-governor-smu.tar.gz"
- name: Extract the snapshot
ansible.builtin.unarchive:
src: "{{ gov_tmp.path }}/cyan-skillfish-governor-smu.tar.gz"
dest: "{{ gov_tmp.path }}"
remote_src: true
- name: Read the package metadata
ansible.builtin.slurp:
src: "{{ gov_tmp.path }}/cyan-skillfish-governor-smu/.SRCINFO"
register: gov_srcinfo
- name: Extract build and runtime dependencies
ansible.builtin.set_fact:
gov_build_deps: >-
{{ (gov_srcinfo.content | b64decode)
| regex_findall('(?m)^\s*(?:make|check)?depends(?:_\w+)?\s*=\s*([^\s<>=]+)')
| unique }}
- name: Ensure build prerequisites are present
become: true
ansible.builtin.pacman:
name: "{{ ['base-devel', 'fakeroot'] + gov_build_deps }}"
state: present
# Rust build, expect several minutes on Zen 2.
- name: Build the package (no install)
ansible.builtin.command:
argv:
- makepkg
- --noconfirm
chdir: "{{ gov_tmp.path }}/cyan-skillfish-governor-smu"
environment:
PKGDEST: "{{ gov_tmp.path }}/cyan-skillfish-governor-smu"
- name: Locate built package(s)
ansible.builtin.find:
paths: "{{ gov_tmp.path }}/cyan-skillfish-governor-smu"
patterns: "*.pkg.tar.zst"
excludes: "*-debug-*"
file_type: file
register: gov_built_pkgs
# Install with root, but OUTSIDE makepkg
- name: Install built package(s)
become: true
ansible.builtin.command:
argv:
- pacman
- -U
- --noconfirm
- "{{ item.path }}"
loop: "{{ gov_built_pkgs.files }}"
notify: Restart the GPU governor
always:
- name: Remove temporary directory
ansible.builtin.file:
path: "{{ gov_tmp.path }}"
state: absent
when: gov_tmp.path is defined
- name: Deploy the governor configuration
become: true
ansible.builtin.template:
src: config.toml.j2
dest: /etc/cyan-skillfish-governor-smu/config.toml
mode: '0644'
notify: Restart the GPU governor
- name: Enable and start the GPU governor
become: true
ansible.builtin.systemd_service:
name: cyan-skillfish-governor-smu
enabled: true
state: started
+119
View File
@@ -0,0 +1,119 @@
# {{ ansible_managed }}
# Default config
# https://github.com/filippor/cyan-skillfish-governor/blob/v0.4.12/default-config.toml
# us
[timing.intervals]
sample = 250
adjust = 100_000
[gpu-usage]
fix-metrics = true
fix-freq = false
method = "busy-flag" # "busy-flag" , "process" or "kernel"
flush-every = 10
[gpu]
set-method = "smu" # "smu" or "kernel"
[dbus]
enabled = true
# Optional: set initial frequency range limits
# Both min and max can be omitted or set to 0 for no limit
[frequency-range]
min = 1000 # MHz
max = 1850 # MHz
# MHz/ms
[timing.ramp-rates]
normal = 1
burst = 50
# number of samples
[timing]
burst-samples = 60
down-events = 5
# MHz
[frequency-thresholds]
adjust = 10
# %
[load-target]
upper = 0.65
lower = 0.50
#°C
[temperature]
throttling = 85
throttling_recovery = 75
[[safe-points]]
frequency = 500
voltage = 700
[[safe-points]]
frequency = 1000
voltage = 800
[[safe-points]]
frequency = 1175
voltage = 850
[[safe-points]]
frequency = 1500
voltage = 900
[[safe-points]]
frequency = 1600
voltage = 910
[[safe-points]]
frequency = 1700
voltage = 920
[[safe-points]]
frequency = 1850
voltage = 930
[[safe-points]]
frequency = 2000
voltage = 960
# [[safe-points]]
# frequency = 2050
# voltage = 980
#
# [[safe-points]]
# frequency = 2100
# voltage = 1000
#
# [[safe-points]]
# frequency = 2125
# voltage = 1020
#
# [[safe-points]]
# frequency = 2150
# voltage = 1035
#
# [[safe-points]]
# frequency = 2200
# voltage = 1050
#
# [[safe-points]]
# frequency = 2230
# voltage = 1085
#
# [[safe-points]]
# frequency = 2300
# voltage = 1110
#
# [[safe-points]]
# frequency = 2350
# voltage = 1130
#
# [[safe-points]]
# frequency = 2400
# voltage = 1150
+2
View File
@@ -5,3 +5,5 @@
role: kernel
- name: Install fan control and temperature driver
role: fan
- name: Install GPU governor
role: gpu_governor