AMD GPU: Difference between revisions

New section: System Hang with Vega Graphics
Kokada (talk | contribs)
Add note about AMDVLK being discontinued.
 
(14 intermediate revisions by 8 users not shown)
Line 3: Line 3:
== Basic Setup ==
== Basic Setup ==
For ordinary desktop / gaming usage, AMD GPUs are expected to work out of the box. As with any desktop configuration though, graphics acceleration does need to be enabled.
For ordinary desktop / gaming usage, AMD GPUs are expected to work out of the box. As with any desktop configuration though, graphics acceleration does need to be enabled.
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">hardware.graphics = {
# as of 24.11
hardware.graphics = {
   enable = true;
   enable = true;
   enable32Bit = true;
   enable32Bit = true;
};
};</syntaxhighlight>
 
# pre 24.11
hardware.opengl = {
  enable = true;
  driSupport = true;
  driSupport32Bit = true;
};
 
</syntaxhighlight>


== Problems ==
== Problems ==
Line 43: Line 32:


=== System Hang with Vega Graphics (and select GPUs) ===
=== System Hang with Vega Graphics (and select GPUs) ===
Currently on the latest kernel/mesa (currently 6.13 and 24.3.4 respectively), Vega integrated graphics (and other GPUs like the RX 6600<ref>https://bbs.archlinux.org/viewtopic.php?pid=2224147#p2224147</ref>) will have a possibility to hang due to context-switching between Graphics and Compute.<ref>https://bbs.archlinux.org/viewtopic.php?id=301798</ref> There are currently two sets of patches to choose between stability or speed that can be applied: [https://github.com/SeryogaBrigada/linux/commits/v6.13-amdgpu amdgpu-stable] and [https://github.com/SeryogaBrigada/linux/commits/v6.13-amdgpu-testing amdgpu-testing].
Currently on the latest kernel/mesa (currently 6.13 and 24.3.4 respectively), Vega integrated graphics (and other GPUs like the RX 6600<ref>https://bbs.archlinux.org/viewtopic.php?pid=2224147#p2224147</ref>) will have a possibility to hang due to context-switching between Graphics and Compute.<ref>https://bbs.archlinux.org/viewtopic.php?id=301798</ref> There are currently two sets of patches to choose between stability or speed that can be applied: [https://github.com/SeryogaBrigada/linux/commits/v6.13-amdgpu amdgpu-stable] and [https://github.com/SeryogaBrigada/linux/commits/v6.13-amdgpu-testing amdgpu-testing].


Line 52: Line 42:
     kernel = config.boot.kernelPackages.kernel;
     kernel = config.boot.kernelPackages.kernel;
   };
   };
   # linuxPackages_latest 6.13
   # linuxPackages_latest 6.13 (or linuxPackages_zen 6.13)
   amdgpu-stability-patch = pkgs.fetchpatch {
   amdgpu-stability-patch = pkgs.fetchpatch {
     name = "amdgpu-stability-patch";
     name = "amdgpu-stability-patch";
Line 62: Line 52:
   amdgpu-stability-patch = pkgs.fetchpatch {
   amdgpu-stability-patch = pkgs.fetchpatch {
     name = "amdgpu-stability-patch-zen";
     name = "amdgpu-stability-patch-zen";
     url = "https://github.com/zen-kernel/zen-kernel/compare/fd00d197bb0a82b25e28d26d4937f917969012aa...WhiteHusky:zen-kernel:bd7822bb10068aaec994773824d20c7ea0fcff94.diff";
     url = "https://github.com/zen-kernel/zen-kernel/compare/fd00d197bb0a82b25e28d26d4937f917969012aa...WhiteHusky:zen-kernel:f4c32ca166ad55d7e2bbf9adf121113500f3b42b.diff";
     hash = "sha256-bMT5OqBCyILwspWJyZk0j0c8gbxtcsEI53cQMbhbkL8=";
     hash = "sha256-bMT5OqBCyILwspWJyZk0j0c8gbxtcsEI53cQMbhbkL8=";
  };
  */
  /*
  # linuxPackages_zen 6.13
  amdgpu-stability-patch = pkgs.fetchpatch {
    name = "amdgpu-stability-patch-zen";
    url = "https://github.com/zen-kernel/zen-kernel/compare/acf7be8d0b380ee50c857967fdfc487b9e373ea8...WhiteHusky:zen-kernel:472a5b899b6859618d74020ec07985565ebb8a8c.diff";
    hash = "sha256-q/gWUPmKHFBHp7V15BW4ixfUn1kaeJhgDs0okeOGG9c=";
   };
   };
   */
   */
Line 77: Line 59:
{
{
   # amdgpu instability with context switching between compute and graphics
   # amdgpu instability with context switching between compute and graphics
   # https://bbs.archlinux.org/viewtopic.php?id=301798&p=16
   # https://bbs.archlinux.org/viewtopic.php?id=301798
  # side-effects: plymouth fails to show at boot, but does not interfere with booting
   boot.extraModulePackages = [
   boot.extraModulePackages = [
     (amdgpu-kernel-module.overrideAttrs (_: {
     (amdgpu-kernel-module.overrideAttrs (_: {
Line 87: Line 70:
}
}
</syntaxhighlight>
</syntaxhighlight>
=== Sporadic Crashes ===
If getting error messages in <code>dmesg</code> with <code>page fault</code> or <code>GCVM_L2_PROTECTION_FAULT_STATUS</code> it might be from AMD GPU boosting too high without enough voltage
Use a tool like LACT to increase power usage limit to 15%, undervolt by moderate amount (e.g. -50mV for 7900 XTX) and optionally decrease maximum GPU clock.
* https://wiki.gentoo.org/wiki/AMDGPU#Frequent_and_Sporadic_Crashes
* https://gitlab.freedesktop.org/mesa/mesa/-/issues/11532
* https://gitlab.freedesktop.org/drm/amd/-/issues/3067


== Special Configuration ==
== Special Configuration ==
Line 169: Line 163:


=== Vulkan ===
=== Vulkan ===
Vulkan is already enabled by default (using Mesa RADV) on 64 bit applications. The settings to control it are:
Vulkan is already enabled by default (using Mesa RADV) on 64 bit applications. The settings to control it are now the same as those shown in the basic setup:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">hardware.graphics.enable = true;
hardware.opengl.driSupport = true; # This is already enabled by default
hardware.graphics.enable32Bit = true; # Replaced 'driSupport32Bit'
hardware.opengl.driSupport32Bit = true; # For 32 bit applications
</syntaxhighlight>
</syntaxhighlight>


==== AMDVLK ====
==== AMDVLK ====
The AMDVLK drivers can be used in addition to the Mesa RADV drivers. The program will choose which one to use:
 
{{Warning|1=AMDVLK is being discontinued, so the only reason you may want to use it is if you have issues with RADV. See: https://github.com/GPUOpen-Drivers/AMDVLK/discussions/416.}}
 
The AMDVLK drivers can be used in addition to the Mesa RADV drivers. The program will choose which one to use (mostly defaulting to AMDVLK):


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 200: Line 196:


More information can be found here: https://nixos.org/manual/nixos/unstable/index.html#sec-gpu-accel-vulkan
More information can be found here: https://nixos.org/manual/nixos/unstable/index.html#sec-gpu-accel-vulkan
One way to avoid installing it system-wide, is creating a wrapper like this:
<syntaxhighlight lang="nix">
with pkgs; writeShellScriptBin "amdvlk-run" ''
  export VK_DRIVER_FILES="${amdvlk}/share/vulkan/icd.d/amd_icd64.json:${pkgsi686Linux.amdvlk}/share/vulkan/icd.d/amd_icd32.json"
  exec "$@"
'';
</syntaxhighlight>
This wrapper can be used per-game inside Steam (<syntaxhighlight lang="sh" inline>amdvlk-run %command%</syntaxhighlight>) and lets RADV to be the system's default.
===== Performance Issues with AMDVLK =====
Some games choose AMDVLK over RADV, which can cause noticeable performance issues (e.g. <50% less FPS in games)
To force RADV<syntaxhighlight lang="nix">
environment.variables.AMD_VULKAN_ICD = "RADV";
</syntaxhighlight>


=== GUI tools ===
=== GUI tools ===


==== LACT - Linux AMDGPU Controller ====
==== LACT - Linux AMDGPU Controller ====
This application allows you to overclock, undervolt, set fans curves of AMD GPUs on a Linux system.
This application allows you to overclock, undervolt, set fans curves of AMD GPUs on a Linux system.


In order to install the daemon service you need to add the package to <code>systemd.packages</code>. Also the <code>wantedBy</code> field should be set to <code>multi-user.target</code> to start the service during boot.
In order to install the daemon service you need to add the package to <code>systemd.packages</code>. Also the <code>wantedBy</code> field should be set to <code>multi-user.target</code> to start the service during boot.
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
environment.systemPackages = with pkgs; [ lact ];
environment.systemPackages = with pkgs; [ lact ];
systemd.packages = with pkgs; [ lact ];
systemd.packages = with pkgs; [ lact ];
systemd.services.lactd.wantedBy = ["multi-user.target"];
systemd.services.lactd.wantedBy = ["multi-user.target"];
</syntaxhighlight>
</syntaxhighlight>Simple version is:<syntaxhighlight lang="nix">
services.lact.enable = true;
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/hardware/lact.nix
</syntaxhighlight>
 
=== Links ===
 
* https://wiki.archlinux.org/title/AMDGPU
* https://wiki.gentoo.org/wiki/AMDGPU
 
=== References ===
 
[[Category:Video]]
[[Category:Video]]