#1868·btop

[BUG] NVIDIA GPU not detected on WSL2 when native nvidia-utils is installed (NVML Driver Not Loaded)

Author: raylei50653Created Sep 29, 2026Updated Sep 29, 2026

Describe the bug On WSL2 with the native nvidia-utils package installed, btop doesn't show the NVIDIA GPU, even though nvidia-smi works. The debug log says:

DEBUG: Failed to initialize NVML, NVIDIA GPUs will not be detected: Driver Not Loaded

In this setup there are two NVML libraries, and both have the SONAME libnvidia-ml.so.1:

  • /usr/lib/libnvidia-ml.so -> libnvidia-ml.so.615.71.09 (native Linux driver, from nvidia-utils)
  • /usr/lib/wsl/lib/libnvidia-ml.so.1 (WSL library, listed first in the ld.so cache for libnvidia-ml.so.1)

Gpu::Nvml::init() tries libnvidia-ml.so first. That resolves to the native library, so dlopen() succeeds and the search stops. Then nvmlInit() fails with NVML_ERROR_DRIVER_NOT_LOADED, and libnvidia-ml.so.1 (which would work) is never tried.

If you set LD_LIBRARY_PATH to point at the WSL library, the problem goes away for an unprivileged binary. It doesn't help when btop has file capabilities (cap_perfmon, etc.), because secure execution makes the loader ignore LD_LIBRARY_PATH.

To Reproduce

  1. Use WSL2 with the Windows NVIDIA driver, and install the distro's nvidia-utils (Arch in my case).
  2. Run btop, built with GPU support, with gpu0 in shown_boxes.
  3. The GPU box is missing, and /proc/<pid>/maps shows /usr/lib/libnvidia-ml.so.615.71.09 loaded.

Expected behavior If nvmlInit() fails for one library candidate, btop should try the next one.

Info

  • btop++ version: 1.4.7 (also reproduced on current main)
  • Platform: Arch Linux on WSL2
  • GPU: NVIDIA RTX 5070 Ti Laptop GPU