Table of Contents
Ubuntu - GPU - AMD GPU - Overclocking - Increase Power on AMD GPUs
It is possible to increase the number of watts supplied to the GPU.
- This should increase performance.
ALERT: This will effectively overclock the GPU.
- This may result in erratic behavior being seen on the system (i.e. frequent crashing).
- If so, restore the GRUB file back to what it was before!
NOTE: It is a best practice to increase voltage in small increments and then test for stability.
- This can be done by running your 3D games/applications at your preferred settings.
- If the adjustments made above causes stability issues, then restore factory default settings.
NOTE: Voltages are not shared between GPU and Memory Clocks; both are set independently.
Edit GRUB Config
Make a Backup of GRUB
sudo cp /etc/default/grub /etc/default/grub.bak
NOTE: If the system somehow breaks, this can be used to restore the backup file.
Edit GRUB Configuration
Edit /etc/default/grub.
Change:
- /etc/default/grub
... GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" ...
to
- /etc/default/grub
... GRUB_CMDLINE_LINUX_DEFAULT="quiet splash amdgpu.ppfeaturemask=0xffffffff" ...
NOTE: Appending this parameter will give “full control” of the GPU.
- This will allow more advanced options to be chosen for Voltage, GPU min/max frequency, and Memory speed.
Regenerate Bootloader Configuration
sudo update-grub or sudo grub-mkconfig -o /boot/grub/grub.cfg
NOTE: On a Fedora or openSUSE distro use:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Reboot
After rebooting, check the Changes.
Verify the current featuremask after reboot by checking here:
printf "0x%08x\n" $(cat /sys/module/amdgpu/parameters/ppfeaturemask)
Check the current performance levels
cat /sys/class/drm/card0/device/power_dpm_force_performance_level
returns:
auto
NOTE: To allow changing the performance, this has to be set to manual control.
- If not, then the following error will be seen: Invalid argument errors when writing clock values of you don't.
Set manual control
echo "manual" > /sys/class/drm/card0/device/power_dpm_force_performance_level
NOTE: Other available power_dpm_force_performance_level settings are:
- auto: Drivers chooses automatically.
- low: Forces the lowest possible clock and locks the GPU there.
- high: Forces the highest possible clock and locks the GPU there.
- profile_standard, profile_min_sclk, profile_min_mclk, profile_peak: When the profiling modes are selected, clock and power gating are disabled and the clocks are set for different profiling cases.
- This mode is recommended for profiling specific work loads where you do not want clock or power gating for clock fluctuation to interfere with your results.
- profile_standard sets the clocks to a fixed clock level which varies from asic to asic.
- profile_min_sclk forces the sclk to the lowest level.
- profile_min_mclk forces the mclk to the lowest level.
- profile_peak sets all clocks (mclk, sclk, pcie) to the highest levels.
Find the GPU device location
readlink -f /sys/class/drm/card0/device
returns:
/sys/devices/pci0000:00/0000:00:03.1/0000:0a:00.0/0000:0b:00.0/0000:0c:00.0
Set the Voltage
NOTE: P-states (Power States) are levels, L0 to L7. that indicate the frequency and voltage of the GPU processor at that state.
- P0 is the lowest, when the system is idle, as normally do not need higher voltage and frequency.
- P6/P7 are what are used when gaming,
- P7 is the highest, when very heavy GPU usage is used.
- But note that P7 uses more voltage and higher frequency; which results in more heat.
- Often P7 is not needed.
To edit the P-state #7 for the core and #2 for the VRAM, as those are the values that our GPU is going to run at while under load.
Edit /sys/class/drm/card0/device/pp_od_clk_voltage:
- /sys/class/drm/card0/device/pp_od_clk_voltage
sudo sh -c "echo 's 7 1450 1150' > /sys/devices/pci0000:00/0000:00:03.1/0000:0a:00.0/0000:0b:00.0/0000:0c:00.0/pp_od_clk_voltage" sudo sh -c "echo 'm 2 2065 950' > /sys/devices/pci0000:00/0000:00:03.1/0000:0a:00.0/0000:0b:00.0/0000:0c:00.0/pp_od_clk_voltage"
NOTE: Ensure that the file path is correct per the previous command to discover the path.
- The values for the clock speeds and voltages will also be different for each GPU.
- To undervolt, change each P-State voltage for core and VRAM to be less than the default values.
- The clock speeds might be able to be kept the same, but in some cases this will also have to be reduced.
- This is where stability testing and benchmarking the GPU comes into play/
Apply the changes
WARNING: Double check the entered values, as mistakes might instantly cause fatal hardware damage!
echo "c" > /sys/class/drm/card0/device/pp_od_clk_voltage
To check if it worked out, read out clocks and voltage under 3D load:
sudo watch -n 0.5 cat /sys/kernel/debug/dri/0/amdgpu_pm_info
NOTE: The default values can be reset:
echo "r" > /sys/class/drm/card0/device/pp_od_clk_voltage
Forbid the driver to switch to certain P-states
This can be used to workaround problems with deep powersaving P-states like flickering artifacts or stutter.
To force the highest VRAM P-state on a Polaris RX 5xx card, while still allowing the GPU itself to run with lower clocks:
echo "manual" > /sys/class/drm/card0/device/power_dpm_force_performance_level echo "2" > /sys/class/drm/card0/device/pp_dpm_mclk
Allow only the three highest GPU P-states:
echo "5 6 7" > /sys/class/drm/card0/device/pp_dpm_sclk
To set the allowed maximum power consumption of the GPU to e.g. 50 Watts:
echo 50000000 > /sys/class/drm/card0/device/hwmon/hwmon0/power1_cap
Across boots
To enable these changes to carry over across boots create a script and systemd service.
- Use the values that have been tested to work and the file path to the GPU.
Create a script
#!/bin/sh sudo sh -c "echo 's 7 <Your desired values here>' > /sys/devices/pci0000:00/0000:00:03.1/0000:0a:00.0/0000:0b:00.0/0000:0c:00.0/pp_od_clk_voltage" sudo sh -c "echo 'm 2 <Your desired values here' > /sys/devices/pci0000:00/0000:00:03.1/0000:0a:00.0/0000:0b:00.0/0000:0c:00.0/pp_od_clk_voltage" sudo sh -c "echo 'c' > /sys/devices/pci0000:00/0000:00:03.1/0000:0a:00.0/0000:0b:00.0/0000:0c:00.0/pp_od_clk_voltage"
- Save this script in /usr/bin/ or a safe place for systemwide scripts.
Create a file in /etc/systemd/system/ like undervolt.service:
- undervolt.service
[Unit] Description=Undervolting GPU [Service] Type=oneshot ExecStart=/Path/To/Script.sh [Install] WantedBy=multi-user.target
Enable the service
sudo systemctl enable undervolt.service
Reboot
Verify
cat /sys/devices/pci0000:00/0000:00:03.1/0000:0a:00.0/0000:0b:00.0/0000:0c:00.0/pp_od_clk_voltage
NOTE: It is recommended to make a similar script to revert things to default values.