Skip to content

Commit

Permalink
chore(just): merge nvidia recipes into configure-nvidia
Browse files Browse the repository at this point in the history
  • Loading branch information
HikariKnight committed Jan 3, 2024
1 parent bcf22fd commit 44e7d4c
Showing 1 changed file with 44 additions and 43 deletions.
87 changes: 44 additions & 43 deletions build/ublue-os-just/40-nvidia.just
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
# vim: set ft=make :

# Set needed kernel arguments for Nvidia GPUs
nvidia-set-kargs:
# Configure the Nvidia driver
configure-nvidia:
#!/usr/bin/env bash
if command -v nvidia-smi; then
rpm-ostree kargs \
--append-if-missing=rd.driver.blacklist=nouveau \
--append-if-missing=modprobe.blacklist=nouveau \
--append-if-missing=nvidia-drm.modeset=1 \
--delete-if-present=nomodeset
else
echo 'You do not appear to be on a Nvidia image, please refer to the README for your uBlue-OS image.'
fi

# Test CUDA support for Nvidia GPUs
nvidia-test-cuda:
#!/usr/bin/env bash
if lsmod | grep -wq "nvidia"; then
podman run \
--user 1000:1000 \
--security-opt=no-new-privileges \
--cap-drop=ALL \
--security-opt label=type:nvidia_container_t \
--device=nvidia.com/gpu=all \
docker.io/nvidia/samples:vectoradd-cuda11.2.1
else
echo 'The Nvidia kernel module is not loaded. You may be using secure boot without the needed signing key, lacking the needed kargs, or may not be on a Nvidia image. See "just enroll-secure-boot-key" and "just nvidia-set-kargs".'
fi

# Enable VAAPI in Firefox Flatpak for Nvidia GPUs
nvidia-setup-firefox-vaapi:
#!/usr/bin/env bash
if lsmod | grep -wq "nvidia"; then
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
else
echo 'The Nvidia kernel module is not loaded. You may be using secure boot without the needed signing key, lacking the needed kargs, or may not be on a Nvidia image. See "just enroll-secure-boot-key" and "just nvidia-set-kargs".'
bold=$(tput bold)
normal=$(tput sgr0)
echo "${bold}Configuring Nvidia drivers${normal}"
echo 'What would you like to do?'
OPTION=$(ugum choose "Set needed kernel arguments" "Test CUDA support" "Enable Nvidia VAAPI in Firefox Flatpak")
if [ "$OPTION" == "Set needed kernel arguments" ]; then
if command -v nvidia-smi; then
rpm-ostree kargs \
--append-if-missing=rd.driver.blacklist=nouveau \
--append-if-missing=modprobe.blacklist=nouveau \
--append-if-missing=nvidia-drm.modeset=1 \
--delete-if-present=nomodeset
else
echo 'You do not appear to be on a Nvidia image, please refer to the README for your uBlue-OS image.'
fi
elif [ "$OPTION" == "Test CUDA support" ]; then
if lsmod | grep -wq "nvidia"; then
podman run \
--user 1000:1000 \
--security-opt=no-new-privileges \
--cap-drop=ALL \
--security-opt label=type:nvidia_container_t \
--device=nvidia.com/gpu=all \
docker.io/nvidia/samples:vectoradd-cuda11.2.1
else
echo 'The Nvidia kernel module is not loaded. You may be using secure boot without the needed signing key, lacking the needed kargs, or may not be on a Nvidia image. See "just enroll-secure-boot-key" and "just nvidia-set-kargs".'
fi
elif [ "$OPTION" == "Enable Nvidia VAAPI in Firefox Flatpak" ]; then
if lsmod | grep -wq "nvidia"; then
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
else
echo 'The Nvidia kernel module is not loaded. You may be using secure boot without the needed signing key, lacking the needed kargs, or may not be on a Nvidia image. See "just enroll-secure-boot-key" and "just nvidia-set-kargs".'
fi
fi

0 comments on commit 44e7d4c

Please sign in to comment.