Microsoft Announces First Preview Of GPU Support Within WSL2

Last month at the Build 2020 conference, Microsoft demonstrated a few samples of Linux GUI-based apps running on Windows 10 directly from WSL2. Along the same lines, Microsoft also revealed plans to bring GPU device support for Windows Subsystem for Linux 2 (WSL2).

Now, almost a month later, Microsoft has finally announced the first preview of GPU compute inside the Linux environment running on Windows via WSL2. Currently, a preview of this most in-demand feature is only available to users under the Windows Insiders program.

GPU Hardware Acceleration Through NVIDIA CUDA And DirectML

To add support for GPU in WSL2, Microsoft integrated GPU virtualization technology into WDDM (Windows Display Driver Model). If you want to know more technical details, read our article here about DirectX on Linux via WSL2.

As of now, Microsoft has added support only for CUDA-enabled NVIDIA GPU (Graphics Processing Unit) and DirectML API for any DirectX 12 GPU from Intel and AMD. However, support for NVIDIA GPUs with DirectML will come later.

If you’re running Windows Insider Build 20150 or higher, you can now use NVIDIA’s CUDA to optimize your computational task by leveraging GPU hardware acceleration.

NVIDIA CUDA support for WSL2
NVIDIA CUDA support for WSL2

The preview also includes support for existing ML tools, libraries, and popular frameworks, including PyTorch and TensorFlow. Hence, you can use TensorFlow with DirectML package inside the native Linux environment to train your heavy machine learning (ML) models.

How To Try Preview Of New WSL2 Features?

If you’re looking to set up a preview of NVIDIA CUDA or TensorFlow with DirectML in WSL 2, you first need to register for the Windows Insider Program from here. Once you register, you can follow the step-by-step instructions from here to install the latest insider build.

Then, install Windows Subsystem for Linux 2 with any Linux distribution on Windows 10. Lastly, read the getting started documentation here to use WSL2 and set up your system for GPU support.