如何在 wsl 中开启 gpu 加速?

如何在 wsl 中开启 gpu 加速?

dxdiag告诉我我有 Intel HD Graphics 520 和 AMD Radeon R7 M340

wsl.exe --version返回

WSL version: 1.0.0.0
Kernel version: 5.15.74.2
WSLg version: 1.0.47
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22000.1281

wsl --status

Default Distribution: Ubuntu-22.04
Default Version: 2

从 wsl 内部,uname -a给出

5.19.0-microsoft-standard #2 SMP PREEMPT_DYNAMIC Wed Aug 3 01:11:12 +04 2022 x86_64 x86_64 x86_64 GNU/Linux

glxinfo -B返回

name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Mesa/X.org (0xffffffff)
    Device: llvmpipe (LLVM 15.0.4, 256 bits) (0xffffffff)
    Version: 22.2.4
    Accelerated: no
    Video memory: 5936MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 4.5
    Max compat profile version: 4.5
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
OpenGL vendor string: Mesa/X.org
OpenGL renderer string: llvmpipe (LLVM 15.0.4, 256 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 22.2.4 - kisak-mesa PPA
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.5 (Compatibility Profile) Mesa 22.2.4 - kisak-mesa PPA
OpenGL shading language version string: 4.50
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 22.2.4 - kisak-mesa PPA
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

我的系统上没有/drv/dxg。的内容/usr/lib/x86_64-linux-gnu/dri

crocus_dri.so
iris_dri.so
nouveau_dri.so
r600_dri.so
swrast_dri.so
vmwgfx_dri.so
d3d12_dri.so
kms_swrast_dri.so
r300_dri.so
radeonsi_dri.so
virtio_gpu_dri.so
zink_dri.so

有没有办法让 gpu 加速发挥作用?

答案1

随着最近发布的 WSL 应用程序包(可从 Microsoft Store 或直接下载 AppX/MSIX 包获得),您显然正在运行它,用于运行 Linux 应用程序的 WSLg 的 GPU 加速应该适用于许多系统。我没有 AMD 系统,但我的理解摘自这篇开发博客文章它应该在你的系统上运行。

WSL 下的 GPU 加速渲染至少需要三件事:

  • WSL 的最新版本(您显然已经拥有):
  • dxgkrnl具有支持的WSL2 内核
  • 视窗支持 WDDM v2.9 或更高版本的 GPU 驱动程序

Windows/WSL 先决条件

虽然您似乎已经准备好了,但我会将其包含在其他读者中。您需要:

  • Windows 11:所有 WSL 版本
  • Windows 10:版本号以 2311 或更高结尾。您可以使用(Get-ComputerInfo).WindowsUBRPowerShell 检查此编号(UBR - update-build-number)。请参阅“Windows 10 上的 WSLg:先决条件”部分这个答案了解更多信息。

dxgkrnl具有支持的WSL2 内核

从上面的输出来看,我希望您的问题非常简单——我注意到 报告的内核版本uname -a与 报告的不同wsl --version。我假设您在 中编译并定义了自定义内核%userprofile%\.wslconfig?如果是这样,请尝试删除该行,重新启动 WSL(wsl --shutdown)并再次检查。

视窗支持 WDDM v2.9 或更高版本的 GPU 驱动程序

最后,确保您的 Radeon 的 Windows 驱动程序支持 WDDM 2.9 或更高版本。这可以通过dxdiagWindows 中的命令来确认展示标签。

如果您的版本低于 2.9,请确保您运行的是最新的 Catalyst 驱动程序。我无法肯定地告诉您,您的卡是否能使用最新的驱动程序支持 2.9,但我相信应该可以。


其他背景阅读材料: DirectX ❤ Linux来自微软 DevBlog

相关内容