AMD GPU: Difference between revisions

Abowen (talk | contribs)
m Added performance issues with AMDVLK
Updated page to reflect the amdgpu module in nixos 25.05 and unstable. I tried to retain useful information such as what these settings actually do, since they are kind of educational in of themselves.
 
(5 intermediate revisions by 5 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 = {
hardware.graphics = {
   enable = true;
   enable = true;
   enable32Bit = true;
   enable32Bit = true;
};
};</syntaxhighlight>There is also the [https://search.nixos.org/options?channel=unstable&query=hardware.amdgpu amdgpu nixos module available for common configuration options], such as enabling opencl, legacy support, overdrive/overclocking and loading during initrd.
</syntaxhighlight>


== Problems ==
== Problems ==
=== Low resolution during initramfs phase ===
If you encounter a low resolution output during early boot phases, you can load the amdgpu module in the initial ramdisk<syntaxhighlight lang="nix">
hardware.amdgpu.initrd.enable = true; # sets boot.initrd.kernelModules = ["amdgpu"];
</syntaxhighlight>


=== Dual Monitors ===
=== Dual Monitors ===
Line 87: Line 90:
The following configurations are only required if you have a specific reason for needing them. They are not expected to be necessary for a typical desktop / gaming setup.
The following configurations are only required if you have a specific reason for needing them. They are not expected to be necessary for a typical desktop / gaming setup.


=== Enable Southern Islands (SI) and Sea Islands (CIK) support ===
=== Enable Southern Islands (SI) and Sea Islands (CIK) support (eg. HD 7000/8000) ===
The oldest architectures that AMDGPU supports are [[wikipedia:Radeon_HD_7000_series|Southern Islands (SI, i.e. GCN 1)]] and [[wikipedia:Radeon_HD_8000_series|Sea Islands (CIK, i.e. GCN 2)]], but support for them is disabled by default. To use AMDGPU instead of the <code>radeon</code> driver, you can set the kernel parameters:
The oldest architectures that AMDGPU supports are [[wikipedia:Radeon_HD_7000_series|Southern Islands (SI, i.e. GCN 1)]] and [[wikipedia:Radeon_HD_8000_series|Sea Islands (CIK, i.e. GCN 2)]], but support for them is disabled by default. To use AMDGPU instead of the <code>radeon</code> driver, you can set the legacySupport option in the amdgpu module.<syntaxhighlight lang="nix">
hardware.amdgpu.legacySupport.enable = true;
</syntaxhighlight>This will set the kernel parameters as follows (this is redundant if you set the above option)


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
# For Southern Islands (SI i.e. GCN 1) cards
boot.kernelParams = [
boot.kernelParams = [ "radeon.si_support=0" "amdgpu.si_support=1" ];
    # For Southern Islands (SI i.e. GCN 1) cards
# For Sea Islands (CIK i.e. GCN 2) cards
    "amdgpu.si_support=1"
boot.kernelParams = [ "radeon.cik_support=0" "amdgpu.cik_support=1" ];
    "radeon.si_support=0"
    # For Sea Islands (CIK i.e. GCN 2) cards
    "amdgpu.cik_support=1"
    "radeon.cik_support=0"
];
</syntaxhighlight>
</syntaxhighlight>


Doing this is required to use [[#Vulkan|Vulkan]] on these cards, as the <code>radeon</code> driver doesn't support it.
Doing this is required to use [[#Vulkan|Vulkan]] on these cards, as the <code>radeon</code> driver doesn't support it.
Please note this also removes support for analog video outputs, which is only available with the <code>radeon</code> driver.


=== HIP ===
=== HIP ===
Line 125: Line 136:


=== OpenCL ===
=== OpenCL ===
<syntaxhighlight lang="nix">
OpenCL support using the ROCM runtime library can be enabled via the amdgpu module.<syntaxhighlight lang="nix">
hardware.graphics.extraPackages = with pkgs; [ rocmPackages.clr.icd ];
hardware.amdgpu.opencl.enable = true;
</syntaxhighlight>
</syntaxhighlight>


Line 165: Line 176:


=== 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 196: Line 209:


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 =====
===== Performance Issues with AMDVLK =====
Line 216: Line 240:
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>
 
== Troubleshooting ==
 
==== Error: <code>amdgpu: Failed to get gpu_info firmware</code> ====
Solution:
hardware.firmware = [ pkgs.linux-firmware ];


=== Links ===
=== Links ===