Home Explore Blog Models CI



nixpkgs

3rd chunk of `nixos/doc/manual/configuration/gpu-accel.chapter.md`
cfa90218d8ac87887e170e9cbb5b3aa4ccbb551ee141f29d0000000100000e48
        deviceType     = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
        deviceName     = Unknown AMD GPU
GPU1:
        deviceType     = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
```

A simple graphical application that uses Vulkan is `vkcube` from the
vulkan-tools package.

### AMD {#sec-gpu-accel-vulkan-amd}

Modern AMD [Graphics Core
Next](https://en.wikipedia.org/wiki/Graphics_Core_Next) (GCN) GPUs are
supported through either radv, which is part of mesa, or the amdvlk
package. Adding the amdvlk package to
[](#opt-hardware.graphics.extraPackages)
makes amdvlk the default driver and hides radv and lavapipe from the device list.
A specific driver can be forced as follows:

```nix
{
  hardware.graphics.extraPackages = [ pkgs.amdvlk ];

  # To enable Vulkan support for 32-bit applications, also add:
  hardware.graphics.extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];

  # Force radv
  environment.variables.AMD_VULKAN_ICD = "RADV";
  # Or
  environment.variables.VK_ICD_FILENAMES = "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json";
}
```

## VA-API {#sec-gpu-accel-va-api}

[VA-API (Video Acceleration API)](https://www.intel.com/content/www/us/en/developer/articles/technical/linuxmedia-vaapi.html)
is an open-source library and API specification, which provides access to
graphics hardware acceleration capabilities for video processing.

VA-API drivers are loaded by `libva`. The version in nixpkgs is built to search
the opengl driver path, so drivers can be installed in
[](#opt-hardware.graphics.extraPackages).

VA-API can be tested using:

```ShellSession
$ nix-shell -p libva-utils --run vainfo
```

### Intel {#sec-gpu-accel-va-api-intel}

Modern Intel GPUs use the iHD driver, which can be installed with:

```nix
{ hardware.graphics.extraPackages = [ intel-media-driver ]; }
```

Older Intel GPUs use the i965 driver, which can be installed with:

```nix
{ hardware.graphics.extraPackages = [ intel-vaapi-driver ]; }
```

## Common issues {#sec-gpu-accel-common-issues}

### User permissions {#sec-gpu-accel-common-issues-permissions}

Except where noted explicitly, it should not be necessary to adjust user
permissions to use these acceleration APIs. In the default
configuration, GPU devices have world-read/write permissions
(`/dev/dri/renderD*`) or are tagged as `uaccess` (`/dev/dri/card*`). The
access control lists of devices with the `uaccess` tag will be updated
automatically when a user logs in through `systemd-logind`. For example,
if the user *alice* is logged in, the access control list should look as
follows:

```ShellSession
$ getfacl /dev/dri/card0
# file: dev/dri/card0
# owner: root
# group: video
user::rw-
user:alice:rw-
group::rw-
mask::rw-
other::---
```

If you disabled (this functionality of) `systemd-logind`, you may need
to add the user to the `video` group and log in again.

### Mixing different versions of nixpkgs {#sec-gpu-accel-common-issues-mixing-nixpkgs}

The *Installable Client Driver* (ICD) mechanism used by OpenCL and
Vulkan loads runtimes into its address space using `dlopen`. Mixing an
ICD loader mechanism and runtimes from different version of nixpkgs may
not work. For example, if the ICD loader uses an older version of glibc
than the runtime, the runtime may not be loadable due to missing
symbols. Unfortunately, the loader will generally be quiet about such
issues.

If you suspect that you are running into library version mismatches
between an ICL loader and a runtime, you could run an application with
the `LD_DEBUG` variable set to get more diagnostic information. For
example, OpenCL can be tested with `LD_DEBUG=files clinfo`, which should
report missing symbols.

Title: NixOS GPU Acceleration: AMD Vulkan, VA-API (Intel), and Troubleshooting
Summary
This chunk provides configuration details for AMD Vulkan drivers, including how to enable `amdvlk`, support 32-bit applications, and force specific drivers like `radv`. It then introduces VA-API (Video Acceleration API) for video processing, explaining its driver loading and how to test it, with specific instructions for installing Intel's `iHD` (modern) or `i965` (older) VA-API drivers. Finally, it addresses common GPU acceleration issues, such as user permissions for `/dev/dri` devices (explaining `systemd-logind`'s role and advising adding users to the `video` group if it's disabled) and potential problems caused by mixing different `nixpkgs` versions for ICD loaders (OpenCL, Vulkan), suggesting `LD_DEBUG` for diagnosing library mismatches.