Skip to content

A GPU task manager for Windows, Linux, and WSL: per-process VRAM, GPU activity, and LLM model/KV-cache insights (Windows AMD and NVIDIA).

Python

Support WSL2 NVML library path in the Nix flake

jihoo2b55453a1cde
diff --git a/README.md b/README.md
index 844aee8..133214f 100644
--- a/README.md
+++ b/README.md
@@ -289,11 +289,11 @@ guess unless their sizes match.
### NixOS
-With flakes enabled, run directly from this checkout:
+With flakes enabled, run the published flake or a checkout:
```bash
-nix run path:.
-nix run path:. -- --list-gpus
+nix run github:shanselman/gputaskman
+nix run github:shanselman/gputaskman -- --list-gpus
nix run path:. -- --once
nix run path:. -- --json
```
@@ -303,7 +303,9 @@ Build both `gputaskman` and its `gtm` alias with `nix build path:.` (executables
pins nixpkgs. Dependencies come from nixpkgs, independently of `uv.lock`. No pip installation,
virtual environment, CUDA Toolkit, or ROCm installation is needed. GPU drivers remain supplied by
the host, never bundled with the package. NVIDIA's nixpkgs Python binding finds NVML through
-`/run/opengl-driver/lib`; AMD uses kernel sysfs and DRM fdinfo interfaces directly.
+`/run/opengl-driver/lib`; AMD uses kernel sysfs and DRM fdinfo interfaces directly. On WSL2 the
+host driver lives in `/usr/lib/wsl/lib` instead, and the wrappers add that directory to
+`LD_LIBRARY_PATH` (it is ignored when absent, so NixOS is unaffected).
For source development and tests:
diff --git a/flake.nix b/flake.nix
index 44e9aa3..b2b73e6 100644
--- a/flake.nix
+++ b/flake.nix
@@ -27,6 +27,7 @@
(pythonSource ./src) (pythonSource ./tests) (pythonSource ./tools)
];
};
+ nativeBuildInputs = [ pkgs.makeWrapper ];
build-system = [ pkgs.python3Packages.uv-build ];
# Nixpkgs supplies the backend; accept its newer release only in
# this build. The resulting wheel and the full test suite are checked.
@@ -41,6 +42,15 @@
runHook postCheck
'';
pythonImportsCheck = [ "gputaskman.cli" "gputaskman.app" ];
+ # WSL2 exposes the host driver's NVML in /usr/lib/wsl/lib (not in
+ # /run/opengl-driver/lib or the loader's default path), so a
+ # Nix-built Python cannot find libnvidia-ml.so.1 and reports no
+ # GPU. Put that directory on the wrapper's loader path; the path
+ # does not exist on NixOS or native Linux, where it is ignored.
+ postFixup = ''
+ wrapProgram $out/bin/gputaskman --suffix LD_LIBRARY_PATH : /usr/lib/wsl/lib
+ wrapProgram $out/bin/gtm --suffix LD_LIBRARY_PATH : /usr/lib/wsl/lib
+ '';
meta = {
inherit (project) description;
homepage = project.urls.Repository;
@@ -69,6 +79,10 @@
];
shellHook = ''
export PYTHONPATH="$PWD/src''${PYTHONPATH:+:$PYTHONPATH}"
+ # WSL2 keeps NVML outside the loader's default path; see postFixup above.
+ if [ -d /usr/lib/wsl/lib ]; then
+ export LD_LIBRARY_PATH="/usr/lib/wsl/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
+ fi
'';
};
});