Skip to main content
DevTools
June 17, 2020

GPU accelerated ML training inside the Windows Subsystem for Linux

The Windows Subsystem for Linux (WSL) enables Windows users to run native, unmodified Linux command-line tools directly on Windows. WSL usage has grown a lot since it was first announced 4 years ago, at Microsoft Build 2016, and now runs on more than 3.5 million monthly active devices!

Adding GPU compute support to WSL has been our #1 most requested feature since the first release. Over the last few years, the WSL, Virtualization, DirectX, Windows Driver, Windows AI teams, and our silicon partners have been working hard to deliver this capability. At Microsoft Build 2020, we announced that the results of all this work would be coming soon as a preview to Windows Insiders.

Today, we are excited to let you know that the preview of GPU compute is now available within WSL 2 to Windows Insiders (Build 20150 or higher)! This preview will initially support artificial intelligence (AI) and machine learning (ML) workflows, enabling professionals and students alike to run ML training workloads across the breadth of GPUs in the Windows ecosystem.

Read on for more details regarding supported scenarios, and how-to setup your system to get started with the preview.

Enabling professionals through NVIDIA CUDA support

Professional data scientists use their local machines for inner-loop development and experimentation. These users experiment with different training algorithms on small batches of training data, often tweaking parameters and architectures until certain accuracy criteria are met. When a promising configuration is found, it is common to push the entire workload into a hosted environment for full scale training on larger datasets.

Inside this inner-loop development on the local device, there are popular Linux-based tools, libraries, and frameworks which these users leverage in their day-to-day workflow. Training ML models is a time-consuming computational task even when using small datasets. To speed-up training, many of these tools use NVIDIA’s CUDA as the optimized path for GPU hardware acceleration, enabling data scientists to hardware-accelerate their training scripts on NVIDIA GPUs.

NVIDIA CUDA support has been present on Windows for years. However, there is a variety of CUDA compute applications that only run in a native Linux environment. In support of meeting professional data scientists where they’re at we’re adding support for CUDA inside WSL 2.

Today, in partnership with NVIDIA, we are releasing an initial preview of CUDA for WSL 2. This preview includes support for existing ML tools, libraries, and popular frameworks, including PyTorch and TensorFlow. As well as all the Docker and NVIDIA Container Toolkit support available in a native Linux environment, allowing containerized GPU workloads built to run on Linux to run as-is inside WSL 2.

“Accelerated computing is essential for modern AI and data science, while users want the flexibility to wield this power wherever their work takes them. With CUDA on NVIDIA GPUs in the Public Preview of the Windows Subsystem for Linux 2, a new class of proven, accelerated workloads is available to Windows users.” – Chris Lamb, VP of Computing Software Platforms, NVIDIA

Computer screen with an image of code.

Empowering students and beginners through DirectML

Over the past few years, there has been an increasing demand for introductory coursework in AI and ML, with online learning platforms playing a key role in educating the workforce and students. These courses empower existing software engineers and students alike to build the foundation for their new skills by working with common model architectures.

We want to make sure the Windows devices these users have can fully support their learning. This starts by providing hardware accelerated training on the breadth of Windows hardware, across AMD, Intel and NVIDIA GPUs, via DirectML. The DirectML API enables accelerated inference for machine learning models on any DirectX 12 based GPU, and we are extending its capabilities to support training. In addition, we intend to integrate DirectML with popular machine learning tools, libraries, and frameworks so that they can automatically use it as a hardware-acceleration backend on Windows.

We understand, however, that some of the tools these users leverage work best within a Linux environment. Therefore, we are invested in ensuring DirectML works well in WSL too. By doing so, our intent is to fully empower students and beginners to learn in the environment that works for them, on the hardware they already have.

Today, we are taking the first step in enabling these future professionals to leverage the breadth of hardware in the Windows ecosystem, by releasing a preview package of TensorFlow with a DirectML backend. Students and beginners can start with the TensorFlow tutorial models or our examples to start building the foundation for their future. In line with this, we are also engaging with the TensorFlow community through their RFC process. We plan to open source our extension of the TensorFlow code base that works with DirectML in the coming months. We’ll also continue engaging with the community and determine the best path for upstreaming our changes into TensorFlow as it evolves.

“We’re excited to work with Microsoft on these new capabilities and empower students and beginners alike to use their existing AMD hardware and expand their skills in machine learning.” – Andrej Zdravkovic, Senior Vice President of Software Development, AMD

Enabling this preview would not have been possible without the hard work from AMD, Intel, and NVIDIA who are releasing preview drivers that enable this DirectML TensorFlow package to run on Windows and inside WSL.

“Through working with Microsoft we’re excited that millions of students, researchers and experimenters can now train models leveraging Intel’s GPU hardware acceleration on hundreds of millions of PCs in the world.” – Lisa Pearce, VP Graphics SW Engineering, Intel

Computer screen showing tensorflow text.

Try out the preview

We hope you’re excited about these investments and encourage you to try out the preview! In order to get your system setup please use our getting started documentation.

Stay involved

If you have feedback on the NVIDIA CUDA path for WSL, please share it via the Community Forum for CUDA on WSL. For feedback on the TensorFlow with DirectML package, please use the DirectML GitHub repo. We look forward to your feedback!

To stay in the loop on our latest news and future updates, stay tuned to the Windows Command Line blog and follow @crahrig on Twitter!

TensorFlow, the TensorFlow logo and any related marks are trademarks of Google Inc.