GPU 解锁:Nvidia 3000 系列显卡的 FP/BF16 指令发射率
GPU-unlock: FP/BF16 instruction issue rate on Nvidia 3000's cards

原始链接: https://github.com/Zagitta/gpu-unlock

本项目是一个 Linux 内核模块,可将消费级 Nvidia 3000 系列(GA102–GA106)的 FP/BF16 指令速率解锁至专业级水平,FP/BF16 FMA 吞吐量大约翻倍。它将 CMP 式解锁与早期预驱动时序结合:在未修改的 NVIDIA 驱动绑定之前执行解锁、设置速度选择器并进行 FLR,因此无需针对每个驱动进行补丁。用户通过 make install 安装,将 gpu_unlock.targets(all 或特定 PCI 地址)添加到内核命令行,并通过 initramfs 集成在 nvidia 之前加载它。它支持针对性显卡、并发解锁以及从挂起到内存后的恢复,但不支持休眠。它会忽略已绑定或不支持的显卡并记录结果。内核模块与打包遵循 GPL-2.0-only;生成的负载源自固定的 CMP 参考,NVIDIA 固件仍受其自身条款约束。

Hacker News 上的一篇帖子讨论了“gpu-unlock”,它利用固件缓冲区溢出和 ROP 来解锁 Nvidia RTX 3000 系列 GPU 上更高的 FP/BF16 指令发射速率。用户报告了真实性能提升,但注意事项包括温度更高、功耗最高可达 450W 以及原装散热限制;该 mod 还可与 p2p mod 叠加。评论者争论是否需要提高功耗限制,部分人报告在功耗限制不变时也有提升。已有多个 3000 系列型号及相关的 Ada(40 系列)仓库的报告。一位评论者对标题提出异议,称其解锁的是 FP32 而非 16 位运算,且可能主要适用于 3090/3090 Ti,但其他人引用了更广泛的支持。一些人指出,训练等工作负载可能受内存带宽限制,从而限制收益。
相关文章

原文

Unlock FP/BF16 instruction issue rate on Nvidia 3000's cards to their professional equivalents

This Linux kernel module combines the CMP unlocker's V67/PLM technique with the pre-driver timing of the UEFI approach. It runs the unlock, writes the speed selectors (SS0 0x88888888, which selects the full BF16 rate, and the 4-bit SS1 0x8 IMLA4) and performs FLR before the unmodified NVIDIA driver binds the card. It is neither a UEFI application nor a patched NVIDIA driver.

The benefit of this early kmod driver is that it does not require manual patching each time nvidia releases a new driver version.

The effect of this unlock is that it doubles the instruction issuing speed of FP/BF16 FMA into FP32 operations on GA102, GA103, GA104 and GA106 cards.

3090 Ti dense 8192³ GEMM at 450 W, five-sample medians with FP32 accumulation:

Input Before After
FP16 87.46 TFLOPS 118.39 TFLOPS
BF16 87.50 TFLOPS 157.41 TFLOPS
TF32 42.58 TFLOPS 82.61 TFLOPS

First run:

git clone https://github.com/Zagitta/gpu-unlock
cd gpu-unlock
make install

Then append gpu_unlock.targets=all to your kernel command line, keeping existing options:

  • GRUB (Debian/Ubuntu/Mint): add it inside GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub, then run sudo update-grub.
  • GRUB (Arch/CachyOS): same edit, then run sudo grub-mkconfig -o /boot/grub/grub.cfg.
  • Fedora/RHEL: run sudo grubby --update-kernel=ALL --args="gpu_unlock.targets=all".
  • systemd-boot: append it to the options line in your boot entry (bootctl status shows its location).
  • UKI / generated entries: add it to /etc/kernel/cmdline and regenerate your boot images/entries (e.g. sudo mkinitcpio -P for mkinitcpio UKIs).

Every build downloads the pinned NVIDIA/CachyOS inputs over HTTPS, checks their SHA-256, and generates firmware only in the build directory and the binary package. All three formats install through the same make install-* targets. Packages are built from the committed HEAD.

Build, install build dependencies, and install the packages in one step (asks for your sudo password):

make install        # detect the distribution and select an installer
make install-arch   # makepkg -sif
make install-deb    # apt-get build-dep, dpkg-buildpackage, apt-get install
make install-rpm    # dnf builddep, rpmbuild, dnf install

make install uses /etc/os-release (ID, then ID_LIKE) to detect Arch, Debian/Ubuntu, or Fedora/RHEL/CentOS families. The RPM installer requires DNF. For other distributions, select a compatible explicit target above.

make arch, make deb and make rpm only build. Debian and RPM packages go to build/deb and build/rpm. The NVIDIA inputs are cached in ~/.cache/gpu-unlock/inputs (make inputs; override with INPUTS=). dpkg-buildpackage itself never uses the network, so a clean-chroot build (sbuild or pbuilder) needs GPU_UNLOCK_INPUTS pointing at that cache. The make dist archive, the Debian source package and the .nosrc.rpm contain no NVIDIA archives or generated firmware.

The packages put gpu_unlock and its firmware in the initramfs and load it there, before nvidia can bind a card:

  • mkinitcpio: /etc/mkinitcpio.conf.d/zz-gpu-unlock.conf inserts gpu_unlock right before nvidia in MODULES, so a display card is blank for as short a time as possible. Without nvidia in the image, it goes last and still runs before an nvidia loaded from the root filesystem. Images are rebuilt on install. mkinitcpio ignores drop-ins for an image built with -c <config> or a preset _config; put gpu_unlock right 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.

The module does nothing unless the kernel command line opts in:

gpu_unlock.targets=all                          # every unbound GA102/GA103/GA104/GA106 card
gpu_unlock.targets=0000:21:00.0                 # only these cards
gpu_unlock.targets=0000:21:00.0,0000:22:00.0    # comma-separated

Addresses are full PCI names as lspci -D prints them (hex digits in either case), independent of GPU numbering and display role. An entry that is not a GA102/GA103/GA104/GA106 card, including all mixed with addresses, is logged and ignored. The cards are unlocked concurrently, about a second in all however many there are, and each on its own: a card that is already bound or powered down is skipped. Bus mastering that the board firmware left on (Supermicro X11 does this whatever its option ROM and bus master settings) is cleared first; a card some driver already initialised is still refused. Then nvidia loads and binds every card as usual.

The display card works too. Its firmware framebuffer (the boot console and Plymouth) keeps running while the unlock's firmware steps run, and is removed just before the card's reset, as nvidia-drm would do a moment later anyway. Its screen is blank from that reset until nvidia-drm takes over.

Loading the module by hand after boot does nothing to a card that nvidia has bound.

Suspend to RAM powers the cards off, which resets the speed selectors. After resume the module unlocks every card it unlocked at boot again, before nvidia resumes it: its suspend notifier runs just ahead of the one nvidia resumes its cards from (NVreg_UseKernelSuspendNotifiers=1, the default in current drivers; nvidia-resume.service runs later still). This adds about a second to resume. A card that kept power, as in suspend to idle, is still unlocked and is only read. A card that nvidia has already resumed, or that is bound to another driver, is left as it is, and the log says why. Add gpu_unlock.resume=0 to the kernel command line, or write 0 to /sys/module/gpu_unlock/parameters/resume, to turn this off. Hibernation is not covered.

Check the result with:

journalctl -k -b | grep gpu_unlock
lspci -nnk -s 0000:21:00.0

To stop unlocking, remove gpu_unlock.targets= from the kernel command line; for a one-off boot, delete it in the bootloader's edit screen. Removing the packages also removes the module and the initramfs drop-ins.

If the firmware on a card never stops, the module logs it and keeps the DMA buffers that firmware may still use until the next power off. Power off before trying again.

The kernel module and local packaging are GPL-2.0-only. The generated payload derives from the pinned CMP reference; NVIDIA firmware remains under its own terms. See firmware/NOTICE.md and licenses/ for attribution and notices.

Help me buy more GPUs <3

https://buymeacoffee.com/zagitta

ETH: 0xf4eee937937f92038D70B16AbD7736D8a53a1c5c

BTC: bc1qwpkwp70fn76z3s4kg2l9y3j4kst95twcznuugf

SOL: 8Rih6HY7V4LcdjYHz4iSffT4fTniqw5CACaBigSVxNYu

联系我们 contact @ memedata.com