feat(roles/common): added power optimization

power optimization via unbinding unsed gpu cards
This commit is contained in:
ITQ
2026-03-30 00:04:23 +03:00
parent 0900981db4
commit ace47c5cfb
4 changed files with 48 additions and 0 deletions
+7
View File
@@ -1,3 +1,10 @@
--- ---
common_journal_retention_days: 21 common_journal_retention_days: 21
common_journal_max_disk_limit: "5%" common_journal_max_disk_limit: "5%"
gpu_unbind_devices: []
# Example:
# gpu_unbind_devices:
# - pci_id: "0000:06:00.0"
# driver: "amdgpu"
# label: "amd_igpu_cezanne"
+4
View File
@@ -3,3 +3,7 @@
ansible.builtin.service: ansible.builtin.service:
name: ssh name: ssh
state: restarted state: restarted
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: true
+19
View File
@@ -23,3 +23,22 @@
- { user: "*", type: "soft", limit: "65536" } - { user: "*", type: "soft", limit: "65536" }
- { user: "*", type: "hard", limit: "65536" } - { user: "*", type: "hard", limit: "65536" }
tags: limits tags: limits
- name: Deploy GPU unbind systemd units
become: true
ansible.builtin.template:
src: gpu-unbind.service.j2
dest: /etc/systemd/system/gpu-unbind-{{ item.label }}.service
mode: "0644"
loop: "{{ gpu_unbind_devices }}"
notify: Reload systemd
tags: optimization
- name: Enable and start GPU unbind servie
become: true
ansible.builtin.systemd:
name: gpu-unbind-{{ item.label }}
enabled: true
state: started
loop: "{{ gpu_unbind_devices }}"
tags: optimization
@@ -0,0 +1,18 @@
[Unit]
Description=Unbind {{ item.label }} ({{ item.pci_id }}) and enable runtime PM
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c '\
if [ -e /sys/bus/pci/drivers/{{ item.driver }}/{{ item.pci_id }} ]; then \
echo "{{ item.pci_id }}" > /sys/bus/pci/drivers/{{ item.driver }}/unbind; \
fi && \
echo auto > /sys/bus/pci/devices/{{ item.pci_id }}/power/control'
ExecStop=/bin/sh -c '\
echo on > /sys/bus/pci/devices/{{ item.pci_id }}/power/control && \
echo "{{ item.pci_id }}" > /sys/bus/pci/drivers/{{ item.driver }}/bind'
[Install]
WantedBy=multi-user.target