NVENC/NVDEC userspace path + nvidia-smi shortcut

- systemd-user environment generator and appsandbox-gpu wrapper both
  append /usr/lib/wsl/lib to LD_LIBRARY_PATH. ldconfig has the .so.1
  entries cached, but the 9P mount is read-only so the unversioned
  symlinks ldconfig wants to create can't be written. dlopen() of
  unversioned names (libcuda.so, libnvidia-encode.so, libnvcuvid.so)
  needs the path on LD_LIBRARY_PATH — without it ffmpeg's h264_nvenc /
  h264_cuvid plugins fail with 'Cannot load libcuda.so.1'.

- setup.sh: symlink /usr/lib/wsl/lib/nvidia-smi to /usr/local/bin so
  the bare command works without env tweaks. Created unconditionally
  because the symlink target is resolved at exec time — the file
  appears under the agent's 9P mount on first boot regardless of when
  the symlink was created.
This commit is contained in:
James Stringer committed 2026-05-19 22:09:52 -04:00
1 parent 2309cec029
commit 194cadeaa6
3 files changed
+27 -3

No files matched your search

+9
View File
@@ -2762,6 +2762,15 @@ static BOOL generate_ubuntu_setup_sh(const wchar_t *path, BOOL ssh_enabled)
"fi\n"
"ldconfig\n"
"\n"
"# --- 7b. nvidia-smi on PATH ---\n"
"# WSL/GPU-PV ships nvidia-smi via the host 9P mount at\n"
"# /usr/lib/wsl/lib/nvidia-smi (only present when the VM has a\n"
"# GPU partition + the agent has mounted the share). The symlink\n"
"# is created unconditionally — symlink target is resolved at\n"
"# exec time, so it 'comes alive' once the agent mounts the share\n"
"# at first boot, with or without the file existing now.\n"
"ln -sf /usr/lib/wsl/lib/nvidia-smi /usr/local/bin/nvidia-smi\n"
"\n"
"# --- 8. daemon-reload, enable the helper services, set graphical ---\n"
"# (Helper binaries + service files are already installed by section 3.\n"
"# Clipboard has no system service — agent spawns it as a child.)\n"
+9 -1
View File
@@ -19,9 +19,17 @@
WSL_MESA=/opt/wsl-mesa
WSL_MESA_LIB="$WSL_MESA/lib/x86_64-linux-gnu"
WSL_LIB=/usr/lib/wsl/lib
if [ -e /dev/dxg ] && [ -d "$WSL_MESA_LIB" ]; then
echo "LD_LIBRARY_PATH=$WSL_MESA_LIB"
# LD_LIBRARY_PATH covers two needs:
# - $WSL_MESA_LIB picks Mesa's d3d12 gallium + dzn Vulkan over stock.
# - $WSL_LIB lets apps that dlopen the WSL NVIDIA userspace libs by
# unversioned SONAME (libcuda.so, libnvidia-encode.so, libnvcuvid.so)
# find them. ldconfig caches only the .so.1 entries — the 9P mount
# is read-only so the unversioned symlinks can't be created.
# NVENC (h264_nvenc, hevc_nvenc) + NVDEC (h264_cuvid, etc.) need this.
echo "LD_LIBRARY_PATH=$WSL_MESA_LIB:$WSL_LIB"
echo "GALLIUM_DRIVER=d3d12"
echo "MESA_LOADER_DRIVER_OVERRIDE=d3d12"
echo "__GLX_VENDOR_LIBRARY_NAME=mesa"
+9 -2
View File
@@ -22,10 +22,17 @@ set -e
WSL_MESA=/opt/wsl-mesa
WSL_MESA_LIB="$WSL_MESA/lib/x86_64-linux-gnu"
WSL_MESA_VK_ICD="$WSL_MESA/share/vulkan/icd.d/dzn_icd.x86_64.json"
WSL_LIB=/usr/lib/wsl/lib
if [ -e /dev/dxg ] && [ -d "$WSL_MESA_LIB" ]; then
# Pick Mesa from /opt/wsl-mesa over stock Ubuntu libGL.
export LD_LIBRARY_PATH="$WSL_MESA_LIB${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
# LD_LIBRARY_PATH covers two needs:
# - $WSL_MESA_LIB picks Mesa's d3d12 gallium + dzn Vulkan over stock.
# - $WSL_LIB lets apps that dlopen the WSL NVIDIA userspace libs by
# unversioned SONAME (libcuda.so, libnvidia-encode.so, libnvcuvid.so)
# find them. ldconfig caches only the .so.1 entries — the 9P mount
# is read-only so the unversioned symlinks can't be created.
# NVENC (h264_nvenc, hevc_nvenc) + NVDEC (h264_cuvid, etc.) need this.
export LD_LIBRARY_PATH="$WSL_MESA_LIB:$WSL_LIB${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export __GLX_VENDOR_LIBRARY_NAME=mesa
# Both env vars are needed: