diff --git a/src/backend_win/disk_util.c b/src/backend_win/disk_util.c index 57464f3..469f1fe 100644 --- a/src/backend_win/disk_util.c +++ b/src/backend_win/disk_util.c @@ -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" diff --git a/tools/linux/wsl-mesa/50-appsandbox-gpu b/tools/linux/wsl-mesa/50-appsandbox-gpu index 894c4b9..cb12090 100644 --- a/tools/linux/wsl-mesa/50-appsandbox-gpu +++ b/tools/linux/wsl-mesa/50-appsandbox-gpu @@ -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" diff --git a/tools/linux/wsl-mesa/appsandbox-gpu b/tools/linux/wsl-mesa/appsandbox-gpu index e96dcc7..55551db 100644 --- a/tools/linux/wsl-mesa/appsandbox-gpu +++ b/tools/linux/wsl-mesa/appsandbox-gpu @@ -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: