User Tools

Site Tools


ubuntu:gpu:amd_gpu:overclocking:increase_power_on_amd_gpus

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ubuntu:gpu:amd_gpu:overclocking:increase_power_on_amd_gpus [2023/06/27 10:04] – created peterubuntu:gpu:amd_gpu:overclocking:increase_power_on_amd_gpus [2023/06/27 13:45] (current) – [Set the Voltage] peter
Line 4: Line 4:
  
   * This should increase performance.   * This should increase performance.
 +
 +
 +<WRAP alert>
 +**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!
 +
 +</WRAP>
 +
 +<WRAP info>
 +**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.
 +
 +</WRAP>
 +
 +<WRAP info>
 +**NOTE:**  Voltages are not shared between GPU and Memory Clocks; both are set independently.
 +</WRAP>
  
 ---- ----
  
-Append **amdgpu.ppfeaturemask=0xffffffff** to the GRUB configuration file.+===== Edit GRUB Config =====
  
-Appending this parameter will also allow us to have “full control” of the GPU; we’ll have more advanced options to choose from in CoreCtrl as far as voltage, GPU min/max frequency, and memory speed.+==== Make a Backup of GRUB ==== 
 + 
 +<code bash> 
 +sudo cp /etc/default/grub /etc/default/grub.bak 
 +</code> 
 + 
 +<WRAP info> 
 +**NOTE:**  If the system somehow breaks, this can be used to restore the backup file. 
 +</WRAP> 
 + 
 +---- 
 + 
 +==== Edit GRUB Configuration ==== 
 + 
 +Edit **/etc/default/grub**. 
 + 
 +Change: 
 + 
 +<file bash /etc/default/grub> 
 +... 
 +GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" 
 +... 
 +</file> 
 + 
 +to 
 + 
 +<file bash /etc/default/grub> 
 +... 
 +GRUB_CMDLINE_LINUX_DEFAULT="quiet splash amdgpu.ppfeaturemask=0xffffffff" 
 +... 
 +</file> 
 + 
 +<WRAP info> 
 +**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. 
 + 
 +</WRAP> 
 + 
 +---- 
 + 
 +==== Regenerate Bootloader Configuration ==== 
 + 
 +<code bash> 
 +sudo update-grub 
 + 
 +or 
 + 
 +sudo grub-mkconfig -o /boot/grub/grub.cfg 
 +</code> 
 + 
 +<WRAP info> 
 +**NOTE:**  On a Fedora or openSUSE distro use: 
 + 
 +<code bash> 
 +sudo grub2-mkconfig -o /boot/grub2/grub.cfg 
 +</code> 
 + 
 +</WRAP> 
 + 
 +---- 
 + 
 +==== Reboot ==== 
 + 
 +After rebooting, check the Changes. 
 + 
 +Verify the current featuremask after reboot by checking here: 
 + 
 +<code bash> 
 +printf "0x%08x\n" $(cat /sys/module/amdgpu/parameters/ppfeaturemask) 
 +</code> 
 + 
 +---- 
 + 
 +===== Check the current performance levels ===== 
 + 
 +<code bash> 
 +cat /sys/class/drm/card0/device/power_dpm_force_performance_level 
 +</code> 
 + 
 +returns: 
 + 
 +<code bash> 
 +auto 
 +</code> 
 + 
 +<WRAP info> 
 +**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.** 
 + 
 +</WRAP> 
 + 
 +---- 
 + 
 +===== Set manual control ===== 
 + 
 +<code bash> 
 +echo "manual" > /sys/class/drm/card0/device/power_dpm_force_performance_level 
 +</code> 
 + 
 +<WRAP info> 
 +**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. 
 +</WRAP> 
 + 
 +---- 
 + 
 +===== Find the GPU device location ===== 
 + 
 +<code bash> 
 +readlink -f /sys/class/drm/card0/device 
 +</code> 
 + 
 +returns: 
 + 
 +<code bash> 
 +/sys/devices/pci0000:00/0000:00:03.1/0000:0a:00.0/0000:0b:00.0/0000:0c:00.0 
 +</code> 
 + 
 +---- 
 + 
 +===== Set the Voltage ===== 
 + 
 +<WRAP info> 
 +**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. 
 + 
 +</WRAP> 
 + 
 +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**: 
 + 
 +<file bash /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" 
 +</file> 
 + 
 +<WRAP info> 
 +**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/ 
 +</WRAP> 
 + 
 +---- 
 + 
 +===== Apply the changes =====
  
 <WRAP alert> <WRAP alert>
-**ALERT**  This will effectively overclock the GPU.+**WARNING:** Double check the entered values, as mistakes might instantly cause fatal hardware damage! 
 +</WRAP>
  
-  * This may result in erratic behavior being seen on the system (i.e. frequent crashing). +<code bash> 
-  * If so, restore the GRUB file back to what it was before!+echo "c" > /sys/class/drm/card0/device/pp_od_clk_voltage 
 +</code>
  
 +To check if it worked out, read out clocks and voltage under 3D load:
 +
 +<code bash>
 +sudo watch -n 0.5  cat /sys/kernel/debug/dri/0/amdgpu_pm_info
 +</code>
 +
 +
 +<WRAP info>
 +**NOTE:**  The default values can be reset:
 +
 +<code bash>
 +echo "r" > /sys/class/drm/card0/device/pp_od_clk_voltage
 +</code>
 </WRAP> </WRAP>
  
 +----
 +
 +===== 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:
 +
 +<code bash>
 +echo "manual" > /sys/class/drm/card0/device/power_dpm_force_performance_level
 +echo "2" >  /sys/class/drm/card0/device/pp_dpm_mclk
 +</code>
 +
 +Allow only the three highest GPU P-states:
 +
 +<code bash>
 +echo "5 6 7" >  /sys/class/drm/card0/device/pp_dpm_sclk
 +</code>
 +
 +To set the allowed maximum power consumption of the GPU to e.g. 50 Watts:
 +
 +<code bash>
 +echo 50000000 > /sys/class/drm/card0/device/hwmon/hwmon0/power1_cap
 +</code>
 +
 +----
 +
 +===== 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 ====
 +
 +<code bash>
 +#!/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"
 +</code>
 +
 +  * Save this script in **/usr/bin/** or a safe place for systemwide scripts.
 +
 +
 +Create a file in **/etc/systemd/system/** like **undervolt.service**:
 +
 +<file bash undervolt.service>
 +[Unit]
 +Description=Undervolting GPU
 +
 +[Service]
 +Type=oneshot
 +ExecStart=/Path/To/Script.sh
 +
 +[Install]
 +WantedBy=multi-user.target
 +</file>
 +
 +----
 +
 +==== Enable the service ====
 +
 +<code bash>
 +sudo systemctl enable undervolt.service
 +</code>
 +
 +----
 +
 +==== Reboot ====
 +
 +----
 +
 +==== Verify ====
 +
 +<code bash>
 +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
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  It is recommended to make a similar script to revert things to default values.
 +</WRAP>
 +
 +----
  
ubuntu/gpu/amd_gpu/overclocking/increase_power_on_amd_gpus.1687860261.txt.gz · Last modified: 2023/06/27 10:04 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki