Skip to content

Your GeForce runs AI at half speed. This fixes it for 20/30/40 series cards. Up to 2× FP16 / BF16 / TF32 tensor throughput

C

Rebuild the initramfs on install and removal for RPM and Debian

Zagitta258f38ad4efc
diff --git a/README.md b/README.md
index 8bf8eec..d69fdd1 100644
--- a/README.md
+++ b/README.md
@@ -88,6 +88,11 @@ before `nvidia` in that config's `MODULES` yourself.
- **initramfs-tools:** `/usr/share/initramfs-tools/modules.d/gpu-unlock.conf`.
- **dracut:** `/usr/lib/dracut/dracut.conf.d/gpu-unlock.conf`.
+With initramfs-tools and dracut, the module is built for every installed
+kernel that has headers, and those kernels' images are rebuilt on install
+and again on removal. Kernels installed later get the module and a new
+image from the kernel's own install hooks.
+
There is no `softdep nvidia pre:` rule: kmod honours only the first
`softdep nvidia` line it reads, so other packages' rules (`nvidia-utils`,
`gddr6_hwmon`) would silently override it, or it would override theirs.
diff --git a/debian/gpu-unlock-dkms.postinst b/debian/gpu-unlock-dkms.postinst
new file mode 100644
index 0000000..73cc724
--- /dev/null
+++ b/debian/gpu-unlock-dkms.postinst
@@ -0,0 +1,11 @@
+#!/bin/sh
+set -e
+
+#DEBHELPER#
+
+# dkms has built gpu_unlock for every kernel with headers. Put it and its
+# firmware into their initramfs so that it runs before nvidia; kernels
+# installed later get both from the dkms and initramfs-tools kernel hooks.
+if [ "$1" = configure ] && command -v update-initramfs >/dev/null; then
+ update-initramfs -u -k all
+fi
diff --git a/debian/gpu-unlock-dkms.postrm b/debian/gpu-unlock-dkms.postrm
new file mode 100644
index 0000000..c54a236
--- /dev/null
+++ b/debian/gpu-unlock-dkms.postrm
@@ -0,0 +1,10 @@
+#!/bin/sh
+set -e
+
+#DEBHELPER#
+
+# Drop gpu_unlock from every initramfs now that the module and the
+# initramfs-tools drop-in are gone.
+if [ "$1" = remove ] && command -v update-initramfs >/dev/null; then
+ update-initramfs -u -k all
+fi
diff --git a/kernel/gpu_unlock/dkms.conf b/kernel/gpu_unlock/dkms.conf
index f44ec11..8ac6e9a 100644
--- a/kernel/gpu_unlock/dkms.conf
+++ b/kernel/gpu_unlock/dkms.conf
@@ -4,5 +4,9 @@ PACKAGE_VERSION="1.0.0"
BUILT_MODULE_NAME[0]="gpu_unlock"
DEST_MODULE_LOCATION[0]="/updates/dkms"
AUTOINSTALL="yes"
+# Build for each kernel instead of letting RHEL's weak-modules link one
+# kernel's build into the others: removing the package then leaves links
+# behind that break dracut for those kernels.
+NO_WEAK_MODULES="yes"
BUILD_EXCLUSIVE_CONFIG="CONFIG_PCI CONFIG_FW_LOADER"
MAKE[0]="make KDIR=${kernel_source_dir}"
diff --git a/packaging/rpm/gpu-unlock.spec b/packaging/rpm/gpu-unlock.spec
index a17273d..108fad1 100644
--- a/packaging/rpm/gpu-unlock.spec
+++ b/packaging/rpm/gpu-unlock.spec
@@ -24,6 +24,8 @@ NVIDIA driver binds, opted in on the kernel command line.
%package dkms
Summary: RTX 3090 BF16 unlock kernel source
Requires: dkms
+Requires(post): dkms
+Requires(preun): dkms
Requires: gpu-unlock-firmware = %{version}-%{release}
%description dkms
@@ -66,13 +68,68 @@ make DESTDIR=%{buildroot} ASSETS="$PWD/assets" \
%{_prefix}/lib/firmware/gpu-unlock
%post dkms
+# Before 1.0.1 the old package kept its DKMS entry on upgrade; drop any
+# other version while its source is still on disk.
+for d in /var/lib/dkms/gpu-unlock/[0-9]*; do
+ [ -d "$d" ] && [ "${d##*/}" != %{version} ] &&
+ dkms remove -m gpu-unlock -v "${d##*/}" --all || :
+done
dkms add -m gpu-unlock -v %{version} --rpm_safe_upgrade || :
%preun dkms
-if [ "$1" -eq 0 ] && [ -d /var/lib/dkms/gpu-unlock/%{version} ]; then
+# On an upgrade to the same version --rpm_safe_upgrade keeps the entry;
+# on any other upgrade the old version must go too.
+if [ -d /var/lib/dkms/gpu-unlock/%{version} ]; then
dkms remove -m gpu-unlock -v %{version} --all --rpm_safe_upgrade || :
fi
+%posttrans dkms
+# Build for every kernel that has headers, not just the running one: a
+# kernel updated but not yet booted would otherwise boot without the
+# module. Kernels installed later get it from the dkms kernel-install hook.
+kernels=
+for b in /lib/modules/*/build; do
+ [ -d "$b" ] || continue
+ k=${b%/build}; k=${k##*/}
+ dkms build -m gpu-unlock -v %{version} -k "$k" --force && kernels="$kernels -k $k"
+done
+[ -n "$kernels" ] && dkms install -m gpu-unlock -v %{version} $kernels --force || :
+# The initramfs has to carry gpu_unlock and its firmware so that it runs
+# before nvidia. Fedora's and EPEL's dkms regenerate every image after an
+# install (post_transaction in framework.conf); otherwise rebuild those of
+# the kernels that can load it.
+if command -v dracut >/dev/null &&
+ ! grep -qs '^post_transaction=.*dracut' /etc/dkms/framework.conf \
+ /etc/dkms/framework.conf.d/*.conf; then
+ for d in /lib/modules/*/; do
+ k=${d%/}; k=${k##*/}
+ modinfo -k "$k" gpu_unlock >/dev/null 2>&1 &&
+ dracut --force --kver "$k" || :
+ done
+fi
+
+%postun dkms
+if [ "$1" -eq 0 ]; then
+ # A kernel package's weak-modules run can still have linked another
+ # kernel's build into its weak-updates; such a link now dangles and
+ # makes dracut fail for that kernel.
+ for l in /lib/modules/*/weak-updates/gpu_unlock.ko*; do
+ [ -L "$l" ] || continue
+ rm -f "$l"
+ k=${l%/weak-updates/*}; depmod -a "${k##*/}" || :
+ done
+ # Rebuild every initramfs that still loads the removed module. dkms
+ # remove may already have regenerated them, but only while the dracut
+ # drop-in was still there.
+ if command -v lsinitrd >/dev/null; then
+ for d in /lib/modules/*/; do
+ k=${d%/}; k=${k##*/}
+ lsinitrd --kver "$k" 2>/dev/null | grep -q gpu_unlock &&
+ dracut --force --kver "$k" || :
+ done
+ fi
+fi
+
%changelog
* Mon Sep 28 2026 Zagitta <[email protected]> - 1.0.0-1
- Initial release.