Last active
March 3, 2022 17:14
-
-
Save thaddeusc1/1e8c0490272f1debe57e28ac1389e379 to your computer and use it in GitHub Desktop.
Set a static fan speed for an AMD GPU in Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
[Unit] | |
Description=Configure custom tuned fan behavior for the Radeon RX 580 during OS initialization. | |
Documentation="https://www.kernel.org/doc/html/v5.11/gpu/amdgpu.html#gpu-power-thermal-controls-and-monitoring" | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/local/sbin/tune-RX580-fans.sh | |
[Install] | |
WantedBy=multi-user.target# Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
[Unit] | |
Description=Configure custom tuned fan behavior for the Radeon RX 580 during OS initialization. | |
Documentation="https://www.kernel.org/doc/html/v5.11/gpu/amdgpu.html#gpu-power-thermal-controls-and-monitoring" | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/local/sbin/tune-RX580-fans.sh | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
NO_FAN_CTL=0 | |
MANUAL_FAN_CTL=1 | |
AUTO_FAN_CTL=2 | |
AMDGPU_FAN_RPM='fan1' | |
AMDGPU_DEVICE='/sys/class/drm/card0/device' | |
HWMON_ID='hwmon/hwmon1' | |
# Pulse Width Modulation (PWM) Duty-Cycle (DC) HWMON controls | |
AMDGPU_FAN_DUTY_CYCLE='pwm1' | |
AMDGPU_FAN_CTL="${AMDGPU_FAN_DUTY_CYCLE}_enable" | |
# Revolutions Per Minute (RPM) HWMON controls | |
AMDGPU_FAN_TGT="${AMDGPU_FAN_RPM}_target" | |
# Fan operating parameters | |
read FAN_PWM_MIN < "${AMDGPU_DEVICE}/${HWMON_ID}/${AMDGPU_FAN_DUTY_CYCLE}_min" | |
read FAN_PWM_MAX < "${AMDGPU_DEVICE}/${HWMON_ID}/${AMDGPU_FAN_DUTY_CYCLE}_max" | |
read FAM_RPM_MIN < "${AMDGPU_DEVICE}/${HWMON_ID}/${AMDGPU_FAN_RPM}_min" | |
read FAM_RPM_MAX < "${AMDGPU_DEVICE}/${HWMON_ID}/${AMDGPU_FAN_RPM}_max" | |
# Dell Radeon RX 580 (OEM) | |
# See also: https://www.techpowerup.com/gpu-specs/radeon-rx-580-oem.c3112 | |
#TARGET_MIN_DC=155 # 2,200 RPM | |
#TARGET_MIN_DC=160 # 2,300 RPM | |
#TARGET_MIN_DC=163 # 2,400 RPM | |
TARGET_MIN_DC=165 # 2,450 RPM | |
#TARGET_MIN_DC=167 # 2,500 RPM | |
#TARGET_MIN_RPM=2157 | |
echo "${MANUAL_FAN_CTL}" | tee "${AMDGPU_DEVICE}/${HWMON_ID}/${AMDGPU_FAN_CTL}" | |
echo "${TARGET_MIN_DC}" | tee "${AMDGPU_DEVICE}/${HWMON_ID}/${AMDGPU_FAN_DUTY_CYCLE}" | |
#echo "${TARGET_MIN_RPM}" | tee "${AMDGPU_DEVICE}/${HWMON_ID}/${AMDGPU_FAN_TGT}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment