AMD GPU: Difference between revisions

DHCP (talk | contribs)
m fix formatting and syntax highlighting :-)
Artturin (talk | contribs)
amdgpu.ids
 
(2 intermediate revisions by one other user not shown)
Line 11: Line 11:
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.


=== AMD iGPU with high amount of RAM (usecase: large language models) ===
=== AMD iGPU with high amount of RAM ===
The iGPU uses system RAM and has no dedicated VRAM. It can use up to the full available system RAM for example for large LLM models. On many systems its possible to set the amount of VRAM in BIOS: „Auto“ or the lowest amount is enough. The driver knows, to expand with GTT.
The iGPU uses system RAM and has no dedicated VRAM. On many systems its possible to set the amount of VRAM in BIOS: "Auto" or the lowest amount is enough. To set the maximum RAM that the iGPU use, you can add <code>ttm pages_limit</code> and <code>ttm page_pool_size</code> in <code>boot.extraModprobeConfig</code> option.<syntaxhighlight lang="nix"># Sets a high amount of GTT size for LLM usage.
boot.extraModprobeConfig = ''
  # Specified as 4KiB pages: 120 GB GTT.
  options ttm pages_limit=31457280


Documentation:
  # Specified as 4KiB pages: 60 GB pre-allocated.
* [https://docs.kernel.org/gpu/amdgpu/module-parameters.html amdgpu gttsize]
   options ttm page_pool_size=15728640
* [https://www.kernel.org/doc/html/v4.14/gpu/drm-mm.html#the-translation-table-manager-ttm ttm pages_limit and ttm pages_pool]
Example for 128GB system RAM, in this example the LLM can use 120 GB „VRAM/GTT“:
<syntaxhighlight lang="nix">
boot.kernelParams = [
  # The kernel module parameter gttsize is a is deprecated and will be removed in the future.
   options amdgpu gttsize=120000


   # specified as 4KiB pages: 120 GB GTT
   # `amdgpu gttsize' is deprecated and should not be used.
  options ttm pages_limit=31457280
   # options amdgpu gttsize=120000
   # specified as 4KiB pages: 60 GB pre-allocated
'';</syntaxhighlight>
  options ttm page_pool_size=15728640
];</syntaxhighlight>


=== Enable Southern Islands (SI) and Sea Islands (CIK) support (eg. HD 7000/8000) ===
=== Enable Southern Islands (SI) and Sea Islands (CIK) support (eg. HD 7000/8000) ===
Line 70: Line 64:
</syntaxhighlight>
</syntaxhighlight>


=== Enabling ROCm & HIP For Packages ===
=== 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.
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.


Line 280: Line 274:
hardware.firmware = [ pkgs.linux-firmware ];
hardware.firmware = [ pkgs.linux-firmware ];
</syntaxhighlight>
</syntaxhighlight>
=== PyTorch does not show the the GPU model and prints <code>(null): No such file or directory</code> ===
<syntaxhighlight lang="shell">$ python -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0))"
(null): No such file or directory
(null): No such file or directory
True AMD Radeon Graphics</syntaxhighlight>It happens because torch cannot find <code>amdgpu.ids</code><syntaxhighlight lang="nix">systemd.tmpfiles.rules = [
  "L+    /opt/amdgpu/share/libdrm/amdgpu.ids  -    -    -    -    ${pkgs.libdrm}/share/libdrm/amdgpu.ids"
];</syntaxhighlight><code>True AMD Radeon RX 9060 XT</code>


== See Also ==
== See Also ==