From d5fac4bcce7dcd5a71e433b71da55462ebfe13fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ryan4yin=20=7C=20=E4=BA=8C=E8=8A=B1?= Date: Mon, 19 Oct 2026 01:15:54 +0800 Subject: [PATCH] fix(ai): bound niri's NVIDIA free-buffer pool (#477) * fix(ai): bound niri's NVIDIA free-buffer pool Assisted-by: DeepSeek Harness 0.2.1-rc.2 (deepseek-flash) * docs(ai): trim the niri VRAM workaround comment Assisted-by: DeepSeek Harness 0.2.1-rc.2 (deepseek-flash) --- WORKAROUNDS.md | 1 + hosts/idols-ai/hardware-nvidia.nix | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/WORKAROUNDS.md b/WORKAROUNDS.md index 274b4528..c786bb46 100644 --- a/WORKAROUNDS.md +++ b/WORKAROUNDS.md @@ -51,6 +51,7 @@ A setting that works around a bug or a hardware quirk. | WA-031 | `iommu=pt` kernel parameter — `hosts/idols-aquamarine/hardware-amd-gpu.nix` | ROCm's system requirements warn that multi-GPU systems may need IOMMU passthrough to prevent application hangs, and this host has two Radeon AI PRO R9700 cards. Added before the first inference run; not yet observed on gfx1201. | Drop once a ROCm release states that the default IOMMU mode is safe for multi-GPU gfx1201, or when the host runs a single GPU | 2026-10-13 | on a ROCm bump, or on the first hang report | active | | WA-032 | `amdgpu.runpm=0` kernel parameter — `hosts/idols-aquamarine/hardware-amd-gpu.nix` | this board's DSDT advertises ATPX power control (`\_SB.PC00.GFX0.ATPX`) but never defines the `PEG0.PEGP._OFF`/`_ON` symbols its body calls, so the first idle resume of the headless R9700 leaves it in `runtime_status = error` (`resume of IP block failed -62`) until reboot, and amdgpu discards the ACPI error. Root cause, kernel-source trail and the measured field comparison: `hosts/idols-aquamarine/ROCM.md`. | Drop once a BIOS update defines those ACPI methods (upstream releases 1023/1066 exist for this board; a flash changes PCR7, so re-enroll TPM2), or a kernel release stops trusting ATPX when its power methods are missing | 2026-10-14 | on a BIOS update or kernel bump | active | | WA-036 | catppuccin eval-time ports kept in the home closure (`home.extraDependencies`) — `home/base/core/theme.nix` | catppuccin/nix reads some ports at eval time (`lib.importTOML "${sources.starship}/.toml"`) and inlines the result, so the built port, catppuccin's build/install hooks and the fetched port source stay unreachable: every gc deletes them, and the deploy after it rebuilds them (build logs: 2026-10-16). `home.extraDependencies` records the port in the generation, which is a gc root. Also read at eval time upstream: `bottom`, `element` (option `element-desktop`), `firefox`, `rio`, `palette` (options `skim`, `tty`), `spotify-player`. | Drop once catppuccin/nix stops reading port files at eval time, or those ports come from a binary cache | 2026-10-16 | on a catppuccin bump | active | +| WA-039 | niri's NVIDIA free-buffer pool bounded (`GLVidHeapReuseRatio` 0) — `hosts/idols-ai/hardware-nvidia.nix` | the driver does not return freed vidmem buffers to its free pool, so niri's VRAM grows to ~1.1 GiB instead of the ~100 MiB its NVIDIA notes expect (measured 1137 MiB after 24 h uptime; [NVIDIA/egl-wayland#126](https://github.com/NVIDIA/egl-wayland/issues/126)) | Drop once a driver stops growing niri's VRAM without the profile, or niri ships its own default | 2026-10-19 | on an nvidia driver bump | active | If WA-008 freezes recur, the fallback is to restore the parameters commented out in `hosts/idols-ai/hardware-configuration.nix` — diff --git a/hosts/idols-ai/hardware-nvidia.nix b/hosts/idols-ai/hardware-nvidia.nix index adc1ed04..ec7b2e78 100644 --- a/hosts/idols-ai/hardware-nvidia.nix +++ b/hosts/idols-ai/hardware-nvidia.nix @@ -35,6 +35,33 @@ powerManagement.enable = true; }; + # Bound the driver's free-buffer pool for niri only: it never returns freed + # vidmem, so niri's VRAM grows past 1 GiB (WA-039). Applies at niri's next start. + # https://github.com/niri-wm/niri/wiki/Nvidia#high-vram-usage-fix + environment.etc."nvidia/nvidia-application-profiles-rc.d/50-limit-free-buffer-pool-in-wayland-compositors.json".text = + builtins.toJSON { + rules = [ + { + pattern = { + feature = "procname"; + matches = "niri"; + }; + profile = "Limit Free Buffer Pool On Wayland Compositors"; + } + ]; + profiles = [ + { + name = "Limit Free Buffer Pool On Wayland Compositors"; + settings = [ + { + key = "GLVidHeapReuseRatio"; + value = 0; + } + ]; + } + ]; + }; + hardware.nvidia-container-toolkit.enable = true; hardware.graphics = { enable = true;