mirror of
https://github.com/Zagitta/gpu-unlock.git
synced 2026-12-03 19:44:49 +07:00
[GH-ISSUE #11] Ubuntu/initramfs-tools: nvidia.ko in the initramfs binds the card before gpu_unlock loads (unlock fails with -EBUSY) #7
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Zagitta/gpu-unlock#7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @daleaag2020 on GitHub (Oct 23, 2026).
Original GitHub issue: https://github.com/Zagitta/gpu-unlock/issues/11
Environment
make deb(gpu-unlock-dkms + gpu-unlock-firmware installed)gpu_unlock.targets=allSymptom
After installing and cold-booting, the unlock fails and nvidia binds normally (no unlock):
(-16 = -EBUSY, from the
pdev->drivercheck inunlock_one().)Root cause
Ubuntu's nvidia driver packages place
nvidia.ko(and GSP firmware) inside the initramfs (usr/lib/modules/<kver>/updates/dkms/nvidia.ko). In initramfs-tools'/init, the execution order is:run_scripts /scripts/init-toprunsscripts/init-top/udev, whose coldplug trigger autoplugs the PCI device and loads nvidia immediately./conf/modules(where/usr/share/initramfs-tools/modules.d/gpu-unlock.confends up) is only processed afterwards byload_modules, so gpu_unlock's init runs with the card already bound and correctly refuses with -EBUSY.The module's own design is fine (
async_synchronize_full_domain()before returning guarantees nvidia loads after it when it is loaded first); the problem is purely that on Ubuntu, modules.d entries are loaded after the init-top coldplug. This does not show up when nvidia.ko is not in the initramfs (nothing binds the card until after the root pivot, long afterload_modules).Precise timeline from the failure (
journalctl -k -b -o short-precise):The WPR2 "card already initialised" check did not fire (the card was genuinely cold, prior boot ended with a full power-off), and the
request_firmware()loads succeeded, so the only problem is the load order.Workaround that works
An initramfs init-top hook that loads the module before the udev coldplug script; init-top scripts run in filename order, so
gpu-unlocksorts beforeudev:/etc/initramfs-tools/scripts/init-top/gpu-unlock(0755):then
update-initramfs -u -k alland a full power cycle. The module init blocks until the unlock completes, so nvidia binds afterwards. Verified with the same cold-boot procedure - now logspci 0000:01:00.0: gpu_unlock: unlocked, and an FP16/BF16 GEMM on this 3090 measures ~120 TFLOPS (stock GA102 tops out around 71).Suggestion
For the initramfs-tools path, the deb could ship this init-top script (in addition to, or instead of, the modules.d entry) so Ubuntu systems with nvidia.ko in the initramfs work out of the box - or the ordering caveat could be documented in the README. Happy to test any fix on this machine.
@yeungyim commented on GitHub (Oct 23, 2026):
A different failure shape on Ubuntu 26.04, plus a workaround that works there. Not the same root cause as this report (no
-EBUSYhere —nvidiais not in the initramfs at all on this host).Environment
7.0.0-38-generic, NVIDIA 595.91.07 (open module, Ubuntu packages), 2x GA102 RTX 3090 (0000:01:00.0,0000:02:00.0)make install-> bothgpu-unlock-dkmsandgpu-unlock-firmwareatiigpu_unlock.targets=0000:01:00.0,0000:02:00.0Symptom: the module is never placed, so nothing runs
The install itself is fine:
sudo update-initramfs -u -k allregenerates both images, but:This initramfs carries no kernel modules at all — it is a host-only image, and
nvidiais not in it either (udev loads it from the root filesystem after the switch). So there is nothing for eithermodules.d/gpu-unlock.confor an added line in/etc/initramfs-tools/modulesto attach to: the module cannot be placed before the driver because it cannot be placed in the initramfs at all.After a cold boot,
dmesg | grep gpu_unlockshows only the kernel command line and nothing from the module — it never executed. Measured on Strata (IQ3_S,--resident-experts, 2x3090, 250 W), prefill over 4 runs: 2432.7 before, 2428.3 / 2419.3 across two attempts — no change, as expected if the unlock never happened.Workaround that works here:
softdep nvidia pre:Since
nvidiais not in the initramfs on this host, it only has to load aftergpu_unlockat normal boot, and kmod can do that:After the cold boot:
lsmod | grep gpu_unlock-> loaded (no holders), both cards present innvidia-smi, and the module ran.Measured effect on Strata (Qwen3.8-Flash-Next IQ3_S,
--resident-experts, 2x3090 at 250 W, 32K cold prompt), 8 runs after vs 4 before:The two ranges do not overlap (the after-run minimum is above the before-run maximum), and two independent measurements of four runs each agree.
That is +5.4% rather than the +13-16% reported for UD-Q4_K_XL, which I would guess is the quant's different prompt kernel path plus the lower GPU share in a resident-experts split, but I have not separated those.
Why this may be worth a doc line
The README only describes the initramfs route. Where the initramfs is host-only (no
.koat all), that route cannot work no matter what goes inmodules.dor/etc/initramfs-tools/modules, and the failure is silent: the package installs cleanly,update-initramfssucceeds, and the module simply never runs. Checkinglsinitramfs ... | grep -c '\.ko'first tells you which route applies.@Zagitta commented on GitHub (Oct 23, 2026):
Hey guys, thanks for the reports and suggestions.
Could you please try out https://github.com/Zagitta/gpu-unlock/tree/fix-ubuntu-load-order and see if that works for you?
@Gazoo commented on GitHub (Oct 23, 2026):
@Zagitta That branch fixed it for me on Ubuntu 26.04. Thanks!
@isenlink commented on GitHub (Oct 24, 2026):
Same kernel here (7.0.0-38-generic, single RTX 3090, driver 615.71.09) — can confirm the host-only initramfs trap and how we routed around it:
nvidia.kois not in it (only unrelated modules like hid-nvidia-shield/forcedeth). nvidia loads via udev from the rootfs after boot, so gpu_unlock from the initramfs always binds first — the standard dkms+initramfs install just works, no softdep workaround needed in this configuration.lsinitramfs /boot/initrd.img-$(uname -r) | grep -c '\.ko'(and grep for nvidia specifically). If your initramfs is truly host-only/empty, the softdep workaround stays the right call.@galvani commented on GitHub (Oct 25, 2026):
Another data point for the case where
nvidia.koIS in the initramfs, on Ubuntu 26.04.1 / 7.0.0-38 / 580.178.04 open, single RTX 3090. (I have not tried thefix-ubuntu-load-orderbranch; this is on mainaf28cbb.)nvidia.kois pulled into the image by theframebuffer-nvidiainitramfs hook fromnvidia-kernel-common-580(it comes withnvidia-drm.fbdev=1), so I hit the originalunlock failed (-16).gpu_unlockin/etc/initramfs-tools/modules(above any nvidia line) did not help. As described above,/conf/modulesis processed after the init-top udev coldplug.softdep nvidia pre: gpu_unlockin/etc/modprobe.d/gpu-unlock.confwas enough on its own, with no init-top script needed. initramfs-tools copies/etc/modprobe.dinto the image, so the softdep also applies when udev autoloads nvidia inside the initramfs:The steps were
update-initramfs -u -k alland a cold power cycle.I know the README rules out shipping a softdep (kmod honours only the first
softdep nvidialine), so this is only a local workaround for the case where nothing else declaressoftdep nvidia; the init-top script onfix-ubuntu-load-orderlooks like the right fix. Full numbers in #107.(Diagnosis and write-up done with an AI assistant, Claude Code; the box and the boot tests are mine.)