/nvidia

Fedora variants with built-in Nvidia drivers

Primary LanguageShellApache License 2.0Apache-2.0

Nvidia

build-ublue

The purpose of these images is to provide community Fedora images with Nvidia drivers built-in. This approach can lead to greater reliability as failures can be caught at the build level instead of the client machine. This also allows for individual sets of images for each series of Nvidia drivers, allowing users to remain current with their OS but on an older, known working driver. Performance regression with a recent driver update? Reboot into a known-working driver after one command. That's the goal!

These images are based on the experimental ostree native container images hosted at quay.io (repo).

Note: This project is a work-in-progress. You should at a minimum be familiar with the Fedora documentation on how to administer an ostree system.

Core image features:

Setup

  1. Rebase onto the image

    Any system running rpm-ostree should be able to rebase onto one of the images built in this project:

    Note: The image previously titled "nvidia" will not be updated anymore. If you wish to retain the same functionality, switch to "silverblue-nvidia".

    Silverblue (GNOME):

    rpm-ostree rebase ostree-unverified-registry:ghcr.io/ublue-os/silverblue-nvidia:latest
    

    Kinoite (KDE):

    rpm-ostree rebase ostree-unverified-registry:ghcr.io/ublue-os/kinoite-nvidia:latest
    

    LXQt (unofficial):

    rpm-ostree rebase ostree-unverified-registry:ghcr.io/ublue-os/lxqt-nvidia:latest
    

    MATE (unofficial):

    rpm-ostree rebase ostree-unverified-registry:ghcr.io/ublue-os/mate-nvidia:latest
    

    Vauxite (XFCE, unofficial):

    rpm-ostree rebase ostree-unverified-registry:ghcr.io/ublue-os/vauxite-nvidia:latest
    

    Sericea (Sway, unofficial as of Fedora 38):

    Note: The Sway session has some custom configuration options set to improve stability on Nvidia GPUs

    rpm-ostree rebase ostree-unverified-registry:ghcr.io/ublue-os/sericea-nvidia:38
    

    Base (no DE preinstalled):

    rpm-ostree rebase ostree-unverified-registry:ghcr.io/ublue-os/base-nvidia:latest
    

    And then reboot.

  2. Set kargs after rebasing

    Setting kargs to disable nouveau and enabling nvidia early at boot is currently not supported within container builds. They must be set after rebasing:

rpm-ostree kargs \
    --append=rd.driver.blacklist=nouveau \
    --append=modprobe.blacklist=nouveau \
    --append=nvidia-drm.modeset=1

And then reboot one more time!

  1. Enable Secure Boot support

    Secure Boot support for the nvidia kernel modules can be enabled by enrolling the signing key:

sudo mokutil --import /etc/pki/akmods/certs/akmods-nvidia.der

Alternatively, the key can be enrolled from within this repo:

sudo mokutil --import ./certs/public_key.der

Rolling back and rebasing

Generally you can perform a rollback with the following:

   rpm-ostree rollback

To rebase onto a specific date, use a date tag:

   rpm-ostree rebase ostree-unverified-registry:ghcr.io/ublue-os/silverblue-nvidia:20230128

Or to rebase onto a specific release, driver, and date:

   rpm-ostree rebase ostree-unverified-registry:ghcr.io/ublue-os/silverblue-nvidia:37-525-20230128

More options for image tags can be found on the container catalog.

Support

Note: The Fedora release and Nvidia version can be set with the image tag as well:

530xx series (latest, best supported) 525xx series (deprecated) 520xx series (deprecated) 470xx series (Kepler 2012-2014 support)
F37 :latest / :37 / :37-530 / :37-current :37-525 :37-520 :37-470
F38 :38 / :38-530 / :38-current :38-525

It is strongly encouraged for you to subscribe to the Nvidia driver announcements section of the forums to keep up with the latest changes and news.

  • Drivers are provided by Nvidia and packaged by RPMFusion, therefore we cannot make any guarantees on support outside of the support these two organizations provide.
  • Due to the nature of third party kernel modules, support for older versions is best effort.
  • TLDR, we do the best we can but sometimes need to drop support depending on what's going with Nvidia, RPMFusion, Fedora, and the Linux kernel.

Verification

These images are signed with sisgstore's cosign. You can verify the signature by downloading the cosign.pub key from this repo and running the following command:

cosign verify --key cosign.pub ghcr.io/ublue-os/base

If you're forking this repo you should read the docs on keeping secrets in github. You need to generate a new keypair with cosign. The public key can be in your public repo (your users need it to check the signatures), and you can paste the private key in Settings -> Secrets -> Actions with the name SIGNING_SECRET.

Building locally

  1. Build container

A container build can be invoked by simply running:

$ podman build \
    --file build.Containerfile \
    --tag build-test:latest
$ podman build \
    --file install.Containerfile \
    --tag install-test:latest

Or to specify the version of Fedora and/or Nvidia driver:

$ podman build \
    --build-arg IMAGE_NAME=silverblue \
    --build-arg FEDORA_MAJOR_VERSION=37 \
    --build-arg NVIDIA_MAJOR_VERSION=525 \
    --file build.Containerfile \
    --tag build-test:37-525

$ podman build \
    --build-arg IMAGE_NAME=silverblue \
    --build-arg FEDORA_MAJOR_VERSION=37 \
    --build-arg NVIDIA_MAJOR_VERSION=525 \
    --build-arg AKMODS_CACHE=build-test \
    --build-arg AKMODS_VERSION=37 \
    --file install.Containerfile \
    --tag build-test:latest
  1. Generate signing keys

If you are forking this repo, then you should add a private key to the repository secrets:

$ ./generate-akmod-key
$ gh secret set AKMOD_PRIVKEY < certs/private_key.priv.prod
$ cp certs/public_key.der.prod certs/public_key.der

Using Nvidia GPUs in containers

There is support for enabling Nvidia GPUs in containers. This can can be verified by running the following:

$ podman run \
    --user 1000:1000 \
    --security-opt=no-new-privileges \
    --cap-drop=ALL \
    --security-opt label=type:nvidia_container_t  \
    docker.io/mirrorgooglecontainers/cuda-vector-add:v0.1

Video playback

Additional runtime packages are added for enabling hardware-accelerated video playback. This can the enabled in Firefox (RPM or flatpak) by setting the following options to true in about:config:

  • gfx.webrender.all
  • media.ffmpeg.vaapi.enabled

Extensive host access and reduced sandboxing is needed for Firefox flatpak to use /usr/lib64/dri/nvidia_drv_video.so:

$ flatpak override \
    --user \
    --filesystem=host-os \
    --env=LIBVA_DRIVER_NAME=nvidia \
    --env=LIBVA_DRIVERS_PATH=/run/host/usr/lib64/dri \
    --env=LIBVA_MESSAGING_LEVEL=1 \
    --env=MOZ_DISABLE_RDD_SANDBOX=1 \
    --env=NVD_BACKEND=direct \
    --env=MOZ_ENABLE_WAYLAND=1 \
    org.mozilla.firefox

Acknowledgements

Thanks to Alex Diaz for advice, and who got this working first, check out this repo:

Repography logo / Recent activity Time period

Timeline graph Issue status graph Pull request status graph Trending topics Top contributors Activity map