Git Product home page Git Product logo

radeon-scripts's Introduction

radeon-scripts

Scripts to manage various aspects of the AMD line of cards in Linux.

vega-power-control notes

Set AMD Vega clock/voltage/profile settings:

  • Reduce temps
  • Increase performance
  • Increase longevity of card

I've set this to some sane defaults that I know work on my card (Sapphire Radeon RX Vega 64). The cooler isn't the best on the reference card, but these settings keep the speeds in the 1500Mhz to 1600Mhz range. You may need to tweak your particular card more to get decent performance.

You can use this script to overclock your card as well. Adjust the p-state clock and voltage to get higher clocks if you'd like. Be forwarned, you can damage your card though. Be judicious with how far you overclock.

You can now adjust your POWERCAP for your card. It requires kernel 4.20+. To enable the feature, simply set $POWERCAP = 1. You can set the wattage in the example in the main body:

  # To set the allowed maximum power consumption of the GPU to e.g. 220 Watts (Default wattage):
  echo 220000000 > "$SYSPATH/$HWMONPATH/power1_cap"

It's currently set the card default, this may need more checks if more cards are introduced at a later time.

Profiles have now been implemented. By default, the script is set auto and the profile is set to balanced (DEFAULTDPMSTATE is there for legacy support only). This can easily be adjusted by adjusting the values for DEFAULTDPMSTATE and DEFAULTDPMPERFLVL. The different profile options are described in the docs.

NOTES:

  • To get live metrics of the card while testing:

    watch -n 1 sudo cat /sys/kernel/debug/dri/0/amdgpu_pm_info

  • You need to add the amdgpu.ppfeaturemask on the GRUB_CMDLINE and regenerate the config file. Edit the following line in Ubuntu:

    /etc/default/grub

    and modify the following line:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash amdgpu.ppfeaturemask=0xffffffff"

    with the following argument:

    amdgpu.ppfeaturemask=0xffffffff

    Then run:

    sudo update-grub

  • Verify the configuration after reboot, it should match what you used:

    printf "0x%08x\n" $(cat /sys/module/amdgpu/parameters/ppfeaturemask)

  • You can check the currently loaded settings by running the following:

    SYSPATH=$(awk '{print}' <<< `find /sys/devices -name power_dpm_force_performance_level -type f -exec dirname {} \;`)
    cat $SYSPATH/pp_od_clk_voltage
    

Command format:

  • echo "[s|m] p-state clock voltage" > "$SYSPATH/pp_od_clk_voltage"
  • echo "r" > $SYSPATH/pp_od_clk_voltage to restore the default values
  • echo "c" > $SYSPATH/pp_od_clk_voltage to commit the changes

Install Notes:

  • Install Notes for vega-power-control can be found here.

vega-fan-control notes

Script to set AMD card fan curves.

NOTES:

To adjust the FANRPM, simply edit the following block in the script to the desired RPM for each temperature range.

 if [ "$GPUTEMP" -ge "20" ] && [ "$GPUTEMP" -le "24" ]; then
    FANRPM=400
 elif [ "$GPUTEMP" -ge "25" ] && [ "$GPUTEMP" -le "29" ]; then
    FANRPM=600
 elif [ "$GPUTEMP" -ge "30" ] && [ "$GPUTEMP" -le "34" ]; then
    FANRPM=800
 elif [ "$GPUTEMP" -ge "35" ] && [ "$GPUTEMP" -le "39" ]; then
    FANRPM=1200
 elif [ "$GPUTEMP" -ge "40" ] && [ "$GPUTEMP" -le "44" ]; then
    FANRPM=1600
 elif [ "$GPUTEMP" -ge "44" ] && [ "$GPUTEMP" -le "49" ]; then
    FANRPM=1800
 elif [ "$GPUTEMP" -ge "50" ] && [ "$GPUTEMP" -le "54" ]; then
    FANRPM=2000
 elif [ "$GPUTEMP" -ge "55" ] && [ "$GPUTEMP" -le "59" ]; then
    FANRPM=2200
 elif [ "$GPUTEMP" -ge "60" ] && [ "$GPUTEMP" -le "64" ]; then
    FANRPM=2400
 elif [ "$GPUTEMP" -ge "65" ] && [ "$GPUTEMP" -le "69" ]; then
    FANRPM=2600
 elif [ "$GPUTEMP" -ge "70" ] && [ "$GPUTEMP" -le "74" ]; then
    FANRPM=2800
 elif [ "$GPUTEMP" -ge "75" ] && [ "$GPUTEMP" -le "79" ]; then
    FANRPM=3000
 elif [ "$GPUTEMP" -ge "80" ] && [ "$GPUTEMP" -le "86" ]; then
    FANRPM=3200
 fi

To watch temperatures, simply enable DEBUG in the script if running it manually. You can also watch the temps via sysfs and use the following command:

    SYSPATH=$(awk '{print}' <<< `find /sys/devices -name power_dpm_force_performance_level -type f -exec dirname {} \;`)
    watch -t -n 1 "awk '{print \$1/(1000)}' $SYSPATH/hwmon/hwmon0/temp1_input && cat $SYSPATH/hwmon/hwmon0/fan1_target"

Install Notes:

  • Install Notes for vega-fan-control can be found here.

radeon-scripts's People

Contributors

dasunsrule32 avatar famo avatar leaphant avatar natemaia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

radeon-scripts's Issues

Reset pwm1_enable to defaults on exit

The current implementation of the trap command doesn't work. I want the script to reset the pwm1_enable sys to be reset to stock settings on script exit. This should prevent odd issues, like overheating cards, etc. Currently, when the script exists, the fans will be at whatever FANRPM was set to last.

# Restore default PWM settings on exit:
pwm_default() {
   echo_text "Restoring PWM defaults"
   echo "2" > "$SYSPATH/pwm1_enable"
}
# On exit set default fan controls:
trap "pwm_default" EXIT
if [ $DEBUG = 1 ]; then
   echo_text "Hit ctrl-c to exit..."
fi

cp: cannot stat 'systemd/vega-power-control.service': No such file or directory

I have been looking around for a way to undervolt and overclock my Vega 64 and found this. However, I can't seem to get it installed for some reason.

Went through and added amdgpu.ppfeaturemask=0xffffffff to GRUB and confirmed it's set. Following the short guide on installing, I can copy and chmod the power and fan control, but whenever I get to
sudo cp systemd/vega-power-control.service /etc/systemd/system
I just get the error in the title. I checked the bin folder and both files are there. Is there something I'm missing? I get the same error for the fan control too.

Running Manjaro KDE 5.0 with the ASUS Strix Vega 64 (STRIX-RXVEGA64-O8G-GAMING)

Vega-power-control settings won't apply, script potentionally hanging when trying to set profile

Currently running this on Linux Mint 19.1, but I had the same problem on Ubuntu 18.04, and Kubuntu 18.04. I tried it on both the default kernel and 4.20.

I believe I got the same results on Arch with the 4.20 kernel. Specifically Antergos with the Gnome DE.

I followed all the steps. Made sure to add the amdgpu.ppfeaturemask=0xffffffff to the grub config file.
Made sure the value actually changed. I then followed the install instructions for the vega-power-control.

No problems with any of the commands and the required files were successfully copied to their respective locations.

Typing
SYSPATH=$(awk '{print}' <<< find /sys/devices -name power_dpm_force_performance_level -type f -exec dirname {} \;)
cat $SYSPATH/pp_od_clk_voltage

shows me the default clocks and voltages. So 1630mhz and 1200mv, etc.

Using the
systemctl status vega-power-control.service
watch -n 5 journalctl -n -b -u vega-power-control.service

commands I see

Feb 08 23:56:55 CM6870 systemd[1]: Started AMD Power Control.
Feb 08 23:56:55 CM6870 vega-power-control[3992]: Kernel requirements met, continuing...
Feb 08 23:56:55 CM6870 vega-power-control[3992]: Setting profile to: balanced...

then nothing else. On each reboot it generates that log and no settings actually apply.

Not sure if I did something wrong installing the scripts all those different times and on the different distros.

I'd also like to add that I have a core i7 3770 and an Asus P8H77-M PRO motherboard because that could be relevant to the issue.

"Kernel is too old, exiting..." on Linux 5.0.0

It seems like the script depends on x.xx version numbers (like 4.20), but the newly released kernel uses 5.0.0 as version number and therefore resolves to 50, which is lower than 420.

Replacing the command for getting the kernel version with

KERNELVER=$(awk -F- '{print $1}' <<< `uname -r` | awk -F. '{print $1$2$3}')

seems to work for versions above 4.15 (...for now).

Edit: Never mind, this won't work for version numbers like 4.15.8.

Add more control over fans

Currently, I'm using a simple case statement to set the FANRPM, this works well enough, but we need more curve points for the FANRPM. I'm looking to redo this with an if/then statement to add further refined controls to the fan curve. I'm not 100% sure if this is the most efficient way, since it would be executed in order. I'll do some testing to see if makes sense in this particular application.

ex.

if [$GPUTEMP -ge 20 && $GPUTEMP -le 24] ; then
   $FANRPM=400
elif [$GPUTEMP -ge 25 && $GPUTEMP -le 29] ; then
   $FANRPM=800
elif [$GPUTEMP -ge 30 && $GPUTEMP -le 34] ; then
   $FANRPM=1000
elif [$GPUTEMP -ge 35 && $GPUTEMP -le 39] ; then
   $FANRPM=1300
...

case $GPUTEMP in

[Info] AMD Radeon R9 Nano Stock Clocks

Hey, it would be great if you could extend your script for the AMD R9 Nano series!
I posted all the infos below. Note that the the R9 Nano is only available with the AMD reference design, so there are no different OEM settings (and I can't even find any branding of the OEM on my card).

$ inxi -G
Graphics:  Card-1: Advanced Micro Devices [AMD/ATI] Fiji [Radeon R9 FURY / NANO Series] driver: amdgpu 
           v: kernel 
           Display: x11 server: X.Org 1.20.3 driver: amdgpu resolution: 2560x1440~144Hz 
           OpenGL: renderer: AMD Radeon R9 Fury Series (FIJI DRM 3.27.0 4.19.12-1-CHAKRA LLVM 6.0.0) 
           v: 4.5 Mesa 18.2.6 
$ SYSPATH=$(awk '{print}' <<< `find /sys/devices -name power_dpm_force_performance_level -type f -exec dirname {} \;`)
$ $SYSPATH
bash: /sys/devices/pci0000:00/0000:00:02.1/0000:01:00.0: Is a directory
$ cat $SYSPATH/pp_od_clk_voltage
OD_SCLK:
0:        300MHz        900mV
1:        508MHz        950mV
2:        717MHz        956mV
3:        874MHz       1087mV
4:        911MHz       1125mV
5:        944MHz       1168mV
6:        974MHz       1206mV
7:       1000MHz       1243mV
OD_MCLK:
0:        500MHz        900mV
OD_RANGE:
SCLK:     300MHz       2000MHz
MCLK:     500MHz        500MHz
VDDC:     900mV        1268mV
$ cat $SYSPATH/device
0x7300
$ cat $SYSPATH/subsystem_device
0x0b36
$ cat $SYSPATH/subsystem_vendor
0x1002
$ lspci -knn [snipped]
01:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Fiji [Radeon R9 FURY / NANO Series] [1002:7300] (rev ca)
        Subsystem: Advanced Micro Devices, Inc. [AMD/ATI] Fiji [Radeon R9 FURY / NANO Series] (Radeon R9 FURY X / NANO) [1002:0b36]
        Kernel driver in use: amdgpu
        Kernel modules: amdgpu
$ cat /sys/kernel/debug/dri/0/amdgpu_pm_info
Clock Gating Flags Mask: 0x3ffff
        Graphics Medium Grain Clock Gating: On
        Graphics Medium Grain memory Light Sleep: On
        Graphics Coarse Grain Clock Gating: On
        Graphics Coarse Grain memory Light Sleep: On
        Graphics Coarse Grain Tree Shader Clock Gating: On
        Graphics Coarse Grain Tree Shader Light Sleep: On
        Graphics Command Processor Light Sleep: On
        Graphics Run List Controller Light Sleep: On
        Graphics 3D Coarse Grain Clock Gating: Off
        Graphics 3D Coarse Grain memory Light Sleep: Off
        Memory Controller Light Sleep: On
        Memory Controller Medium Grain Clock Gating: On
        System Direct Memory Access Light Sleep: On
        System Direct Memory Access Medium Grain Clock Gating: On
        Bus Interface Medium Grain Clock Gating: Off
        Bus Interface Light Sleep: On
        Unified Video Decoder Medium Grain Clock Gating: On
        Video Compression Engine Medium Grain Clock Gating: On
        Host Data Path Light Sleep: On
        Host Data Path Medium Grain Clock Gating: On
        Digital Right Management Medium Grain Clock Gating: Off
        Digital Right Management Light Sleep: Off
        Rom Medium Grain Clock Gating: On
        Data Fabric Medium Grain Clock Gating: Off

GFX Clocks and Power:
        500 MHz (MCLK)
        860 MHz (SCLK)
        300 MHz (PSTATE_SCLK)
        500 MHz (PSTATE_MCLK)
        1087 mV (VDDGFX)
        37.108 W (average GPU)

GPU Temperature: 52 C
GPU Load: 34 %

UVD: Disabled
VCE: Disabled

Rewrite to be more CLI friendly

I want to rewrite the scripts with the following in mind:

  • Rename scripts to amd-*, since this will bring the inclusion of other cards into the fold
  • CLI Switches
  • Array to hold custom pstate|clock|voltage values, this will allow for more cards, more easily, without having to store every cards hardware defaults
  • Stop using power_dpm_state, as it's only provided for backwards compatibility. Should only be using power_dpm_force_performance_level going forward

Example idea(s) for amd-power-control:

amd-power-control -h - Function to list out help
amd-power-control -r - Function to reset to default, include c to commit change to default card values
amd-power-control -p - Function to set power_dpm_force_performance_level: auto, low, high, manual
amd-power-control -l - Function to set a custom profile using power_dpm_force_performance_level: profile_standard, profile_min_sclk, profile_min_mclk, profile_peak
amd-power-control -s - Function to set GPU clock pstate/clock/voltage level
amd-power-control -m - Function to set memory clock pstate/clock level
amd-power-control -v - Function to set memory clock pstate/voltage level
amd-power-control -i - Function to get current card settings
amd-power-control -c - Set powercap

On Suspend/Resume, write error: No data available

If script is running and a suspend is done, on resume the following is dumped:

vega-fan-curve[6827]: /usr/local/bin/vega-fan-curve: line 65: echo: write error: No data available

On resume, pwm1_enable is getting reset to 2, which doesn't allow the fans to be controlled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.