--- - hosts: localhost become: yes vars: # the multipliers against power capability to determine power limits for the non-OC (default)/OC (custom) profiles # 0.5 = 50% # 1.0 = 100% (of card power capability, not stock limits) # should not exceed 1.0, must be a float. driver will do some rounding/stepping power_max_custom_multi: 1.0 # used to boost GPU power to board capability for some overclocking power_max_default_multi: 0.75 # used to limit GPU power to some lower percentage on default perf mode gpu_clock_min: "2200" # minimum GPU clock (in 3D) - defaults 500Mhz gpu_clock_max: "2575" # maximum GPU clock (also 3D) - range allows up to 3000Mhz. default 2529 gpumem_clock_max: "1075" # maximum GPU memory clock - default 1000Mhz, range allows 1075Mhz gpu_mv_offset: "+100" # optional, applies offset to GPU voltage, eg: +100 = boost 100mV or 0.1V. for the 'custom' GPU profile. # note: (all clocks based on my non-reference 6900XT) # consult '/sys/class/drm/{{ card }}/device/pp_od_clk_voltage' card: card0 # default to card0 base_profiles: # list of source tuned profiles available on Fedora (TODO: should dynamically discover?) - balanced # these are further modified with secondary (templated) profiles, see 'templates/tuned.conf.j2' - desktop - latency-performance - network-latency - network-throughput - powersave - virtual-host amdgpu_profiles: # statically defined mapping of the contents in /sys/class/drm/{{ card }}/device/pp_power_profile_mode - { name: 'default', value: 0 } - { name: 'custom', value: 6 } handlers: - name: restart tuned ansible.builtin.service: name: tuned state: restarted tasks: - name: Gather package facts ansible.builtin.package_facts: manager: auto - name: replace 'power-profiles-daemon' with 'tuned' on Fedora 35+ dnf: # use with_items since 'dnf' module in Ansible doesn't support 'swap' name: "{{ item.name }}" state: "{{ item.state }}" with_items: - {name: 'power-profiles-daemon', state: 'absent'} - {name: 'tuned', state: 'present'} when: ('power-profiles-daemon' in ansible_facts.packages) or (('tuned' not in ansible_facts.packages) and ((ansible_distribution == 'Fedora') and (ansible_distribution_major_version|int > 35))) register: fed_ppdtuned_swap # 'power-profiles-daemon' was added/conflicts with 'tuned' since F35 # otherwise, ensure the 'tuned' package is installed - name: install tuned package: name: tuned state: present when: (fed_ppdtuned_swap is not defined) or ('tuned' not in ansible_facts.packages) - name: find hwmon/max power capability file for {{ card }} find: paths: /sys/class/drm/{{ card }}/device/hwmon file_type: file recurse: yes use_regex: yes patterns: - '^power1_cap_max$' register: hwmon - name: find hwmon/current power limit file for {{ card }} find: paths: /sys/class/drm/{{ card }}/device/hwmon file_type: file recurse: yes use_regex: yes patterns: - '^power1_cap$' register: powercap_set - name: get max power capability for {{ card }} slurp: src: "{{ hwmon.files.0.path }}" register: power_max_b64 - name: create custom profile directories file: state: directory path: /etc/tuned/{{ item.1 }}-amdgpu-{{ item.0.name }} mode: "0755" with_nested: - "{{ amdgpu_profiles }}" - "{{ base_profiles }}" - name: template AMDGPU clock control scripts (default/GPU profile dependency) template: src: templates/amdgpu-clock.sh.j2 dest: /etc/tuned/{{ item.1 }}-amdgpu-{{ item.0.name }}/amdgpu-clock.sh owner: root group: root mode: "0755" with_nested: - "{{ amdgpu_profiles }}" - "{{ base_profiles }}" notify: restart tuned - name: template custom tuned profiles template: src: templates/tuned.conf.j2 dest: /etc/tuned/{{ item.1 }}-amdgpu-{{ item.0.name }}/tuned.conf owner: root group: root mode: "0644" with_nested: - "{{ amdgpu_profiles }}" - "{{ base_profiles }}" notify: restart tuned