AMD GPU: Difference between revisions

From NixOS Wiki
imported>KREYREN
Present in stable
imported>SuperSamus
No edit summary
Line 20: Line 20:
== Enable Southern Islands (SI) and Sea Islands (CIK) support ==
== Enable Southern Islands (SI) and Sea Islands (CIK) 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:
The oldest architectures that AMDGPU supports are [https://en.wikipedia.org/wiki/Radeon_HD_7000_series Southern Islands (SI, i.e. GCN 1)] and [https://en.wikipedia.org/wiki/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:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
# for Southern Islands (SI ie. GCN 1) cards
# for Southern Islands (SI i.e. 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 ie. GCN 2) cards
# for Sea Islands (CIK i.e. 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>
Doing this is required to use [[#Vulkan|Vulkan]] on these cards, as the <code>radeon</code> driver doesn't support it.


== HIP ==
== HIP ==
Most software has the HIP libraries hard-coded. You can work around it on NixOS by using:
Most software has the HIP libraries hard-coded. You can work around it on NixOS by using:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
systemd.tmpfiles.rules = [
systemd.tmpfiles.rules = [
     "L+    /opt/rocm/hip  -    -    -    -    ${pkgs.hip}"
     "L+    /opt/rocm/hip  -    -    -    -    ${pkgs.rocmPackages.clr}"
   ];
   ];
</syntaxhighlight>
</syntaxhighlight>
Line 46: Line 49:
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
hardware.opengl.extraPackages = with pkgs; [
hardware.opengl.extraPackages = with pkgs; [
   rocm-opencl-icd
   rocmPackages.clr.icd
  rocm-opencl-runtime
];
];
</syntaxhighlight>
</syntaxhighlight>


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).
You should also install the <code>clinfo</code> 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 ==


To enable vulkan
Vulkan is already enabled by default (using Mesa RADV) on 64 bit applications. The settings to control it are:
 
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
hardware.opengl.driSupport = true;
hardware.opengl.driSupport = true; # This is already enabled by default
# For 32 bit applications
hardware.opengl.driSupport32Bit = true; # For 32 bit applications
hardware.opengl.driSupport32Bit = true;
</syntaxhighlight>
</syntaxhighlight>


=== AMDVLK ===


{{Note|amdvlk is not needed for vulkan}}
The AMDVLK drivers can be used in addition to the Mesa RADV drivers. The program will choose which one to use:
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:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 75: Line 77:
];
];
</syntaxhighlight>
</syntaxhighlight>
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


== Problems ==
== Problems ==
Line 81: Line 84:
=== Dual Monitors ===
=== 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.
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:
For example:
Line 92: Line 95:
</syntaxhighlight>
</syntaxhighlight>


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


To figure out your connector names, use:
To figure out the connector names, execute the following command while your monitors are connected:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
head /sys/class/drm/*/status
head /sys/class/drm/*/status
</syntaxhighlight>
</syntaxhighlight>
with your monitors connected.
   
   
[[Category:Video]]
[[Category:Video]]

Revision as of 17:20, 1 December 2023

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, i.e. GCN 1) and Sea Islands (CIK, i.e. 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 i.e. GCN 1) cards
boot.kernelParams = [ "radeon.si_support=0" "amdgpu.si_support=1" ];
# for Sea Islands (CIK i.e. GCN 2) cards
boot.kernelParams = [ "radeon.cik_support=0" "amdgpu.cik_support=1" ];

Doing this is required to use Vulkan on these cards, as the radeon driver doesn't support it.

HIP

Most software has the HIP libraries hard-coded. You can work around it on NixOS by using:

systemd.tmpfiles.rules = [
    "L+    /opt/rocm/hip   -    -    -     -    ${pkgs.rocmPackages.clr}"
  ];

Blender

Hardware accelerated rendering can be achieved by using the package blender-hip.

OpenCL

hardware.opengl.extraPackages = with pkgs; [
  rocmPackages.clr.icd
];

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 is already enabled by default (using Mesa RADV) on 64 bit applications. The settings to control it are:

hardware.opengl.driSupport = true; # This is already enabled by default
hardware.opengl.driSupport32Bit = true; # For 32 bit applications

AMDVLK

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 
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"
];

With the connector names (like `DP-1`), the resolution and frame rate adjusted accordingly.

To figure out the connector names, execute the following command while your monitors are connected:

head /sys/class/drm/*/status