AMD GPU: Difference between revisions
Information about iGPU usage of VRAM/GTT for large amounts of VRAM/GTT for LLM (source: based on a forum comment https://community.frame.work/t/igpu-vram-how-much-can-be-assigned/73081/6 of https://community.frame.work/u/lhl/summary ) |
m fix formatting and syntax highlighting :-) |
||
| (2 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
[ | [[Wikipedia:AMDgpu (Linux kernel module)|AMDGPU]] is an open source graphics driver for AMD Radeon graphics cards. It supports AMD GPUs based on the [[Wikipedia:Graphics Core Next|Graphics Core Next (GCN)]] architecture and later, covering hardware released from approximately 2012 onward. This guide is about configuration of NixOS to correctly use AMD GPUs supported by the AMDGPU driver. | ||
== Basic Setup == | == Basic Setup == | ||
| Line 37: | Line 37: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
boot.kernelParams = [ | boot.kernelParams = [ | ||
# For Southern Islands (SI i.e. GCN 1) cards | |||
"amdgpu.si_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> | ||
| Line 54: | Line 54: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
systemd.tmpfiles.rules = | |||
let | let | ||
rocmEnv = pkgs.symlinkJoin { | rocmEnv = pkgs.symlinkJoin { | ||
| Line 64: | Line 64: | ||
]; | ]; | ||
}; | }; | ||
in [ | in | ||
[ | |||
"L+ /opt/rocm - - - - ${rocmEnv}" | "L+ /opt/rocm - - - - ${rocmEnv}" | ||
]; | ]; | ||
</syntaxhighlight> | |||
=== Enabling ROCm & HIP For Packages === | |||
Whether or not a package is built with ROCm support is controlled by the <code>rocmSupport</code> nixpkgs config variable. As HIP is a component of ROCm, anything that needs HIP support (e.g. Blender) gets that enabled through <code>rocmSupport</code> too. | |||
You can set it globally with this line | |||
<syntaxhighlight lang="nix"> | |||
nixpkgs.config.rocmSupport = true; | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Or override specific packages | |||
<syntaxhighlight lang="nix"> | |||
environment.systemPackages = with pkgs; [ | |||
(ffmpeg-full.override { config.rocmSupport = true; }) | |||
pkgsRocm.ffmpeg-full # equivalent to (ffmpeg-full.override {config.rocmSupport=true;}) for packages in ROCm Release attrPaths | |||
]; | |||
</syntaxhighlight> | |||
While most if not all packages that support ROCm should be in the [https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/rocm-modules/release-attrPaths.json ROCm Release attrPaths], and therefore built by Hydra and cached in cache.nixos.org with <code>rocmSupport</code>, enabling it globally still has a slight chance of pointless compiling on your machine. | |||
For Blender-specific information on setting up HIP support, see: [[Blender#HIP]]. | |||
=== OpenCL === | === OpenCL === | ||
| Line 118: | Line 135: | ||
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: | 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">hardware.graphics.enable = true; | <syntaxhighlight lang="nix"> | ||
hardware.graphics.enable = true; | |||
hardware.graphics.enable32Bit = true; # Replaced 'driSupport32Bit' | hardware.graphics.enable32Bit = true; # Replaced 'driSupport32Bit' | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 170: | Line 188: | ||
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>Simple version is:<syntaxhighlight lang="nix"> | </syntaxhighlight> | ||
Simple version is: | |||
<syntaxhighlight lang="nix"> | |||
services.lact.enable = true; | services.lact.enable = true; | ||
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/hardware/lact.nix | # https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/hardware/lact.nix | ||
| Line 178: | Line 198: | ||
=== Low resolution during initramfs phase === | === 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"> | 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"]; | hardware.amdgpu.initrd.enable = true; # sets boot.initrd.kernelModules = ["amdgpu"]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 199: | Line 220: | ||
To figure out the connector names, execute the following command while your monitors are connected: | To figure out the connector names, execute the following command while your monitors are connected: | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="console"> | ||
head /sys/class/drm/*/status | $ head /sys/class/drm/*/status | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 256: | Line 277: | ||
Solution: | Solution: | ||
<syntaxhighlight lang="nix"> | |||
hardware.firmware = [ pkgs.linux-firmware ]; | |||
</syntaxhighlight> | |||
== See Also == | == See Also == | ||