AMD GPU: Difference between revisions

From NixOS Wiki
imported>Artturin
mNo edit summary
imported>SuperSamus
No edit summary
Line 1: Line 1:
This guide is about setting up NixOS to correctly use your Amd Graphics card if it is relatively new (aka, after the GCN architecture).
This guide is about setting up NixOS to correctly use your AMD Graphics card if it is relatively new (aka, after the GCN architecture).


== Make the kernel use the correct driver early ==
== Make the kernel use the correct driver early ==
Line 20: Line 20:
== Enable Southern Islands (SI) and Sea Islands (CIK) support ==
== Enable Southern Islands (SI) and Sea Islands (CIK) support ==


The linux package enables AMDGPU support [https://en.wikipedia.org/wiki/Radeon_HD_7000_series Southern Island (si)] and [https://en.wikipedia.org/wiki/Radeon_HD_8000_series Sea Island(cik)]. You can set kernel params to enable support
The oldest architectures that AMDGPU supports are [https://en.wikipedia.org/wiki/Radeon_HD_7000_series Southern Islands (SI, ie. GCN 1)] and [https://en.wikipedia.org/wiki/Radeon_HD_8000_series Sea Islands (CIK, ie. GCN 2)], but support for them is disabled by default. To use AMDGPU instead of the radeon driver, you can set the kernel parameters:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
# for Southern Islands (SI) cards
# for Southern Islands (SI ie. GCN 1) cards
boot.kernelParams = [ "radeon.si_support=0" "amdgpu.si_support=1" ];
boot.kernelParams = [ "radeon.si_support=0" "amdgpu.si_support=1" ];
# for Sea Islands (CIK) cards
# for Sea Islands (CIK ie. GCN 2) cards
boot.kernelParams = [ "radeon.cik_support=0" "amdgpu.cik_support=1" ];
boot.kernelParams = [ "radeon.cik_support=0" "amdgpu.cik_support=1" ];
</syntaxhighlight>
</syntaxhighlight>
Line 38: Line 38:
</syntaxhighlight>
</syntaxhighlight>


You should also install the clinfo package to verify that Open CL is correctly setup (or check in the program you use to see if it is now available, such as in Darktable).
You should also install the clinfo package to verify that OpenCL is correctly setup (or check in the program you use to see if it is now available, such as in Darktable).


== Vulkan ==
== Vulkan ==

Revision as of 11:14, 1 December 2021

This guide is about setting up NixOS to correctly use your AMD Graphics card if it is relatively new (aka, after the GCN architecture).

Make the kernel use the correct driver early

The kernel can load the correct driver right away:

boot.initrd.kernelModules = [ "amdgpu" ];

XServer

Make sure Xserver uses the `amdgpu` driver in your configuration.nix:

services.xserver.enable = true;
services.xserver.videoDrivers = [ "amdgpu" ];

Enable Southern Islands (SI) and Sea Islands (CIK) support

The oldest architectures that AMDGPU supports are Southern Islands (SI, ie. GCN 1) and Sea Islands (CIK, ie. GCN 2), but support for them is disabled by default. To use AMDGPU instead of the radeon driver, you can set the kernel parameters:

# for Southern Islands (SI ie. GCN 1) cards
boot.kernelParams = [ "radeon.si_support=0" "amdgpu.si_support=1" ];
# for Sea Islands (CIK ie. GCN 2) cards
boot.kernelParams = [ "radeon.cik_support=0" "amdgpu.cik_support=1" ];

OpenCL

hardware.opengl.extraPackages = with pkgs; [
   rocm-opencl-icd
   rocm-opencl-runtime
];

You should also install the clinfo package to verify that OpenCL is correctly setup (or check in the program you use to see if it is now available, such as in Darktable).

Vulkan

To enable vulkan

hardware.opengl.driSupport = true;
# For 32 bit applications
hardware.opengl.driSupport32Bit = true;


Note: amdvlk is not needed for vulkan

Starting from 20.09, the amdvlk drivers can be used in addition to the mesa radv drivers, the program will choose which one to use:

hardware.opengl.extraPackages = with pkgs; [
   amdvlk
];
# For 32 bit applications 
# Only available on unstable
hardware.opengl.extraPackages32 = with pkgs; [
  driversi686Linux.amdvlk
];

more information can be found here https://nixos.org/manual/nixos/unstable/index.html#sec-gpu-accel-vulkan

Problems

Dual Monitors

If you encounter problems having multiple monitors connected to your gpu, adding `video` parameters for each connector to the kernel command line sometimes helps.

For example:

boot.kernelParams = [
    "video=DP-1:2560x1440@144"
    "video=DP-2:2560x1440@144"
];

Of course you have to adjust the connector names (like `DP-1`), the resolution and frame rate accordingly.

To figure out your connector names, use:

head /sys/class/drm/*/status

with your monitors connected.