From 135a4583cd4416460c8c5bee1a4d9badb6709614 Mon Sep 17 00:00:00 2001 From: Matt Wojciakowski Date: Tue, 9 Jun 2020 16:41:12 -0700 Subject: [PATCH 1/4] Draft GPU Compute doc --- WSL/tutorials/gpu-compute.md | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 WSL/tutorials/gpu-compute.md diff --git a/WSL/tutorials/gpu-compute.md b/WSL/tutorials/gpu-compute.md new file mode 100644 index 00000000..ece6cd3b --- /dev/null +++ b/WSL/tutorials/gpu-compute.md @@ -0,0 +1,79 @@ +--- +title: GPU accelerated Machine Learning training in the Windows Subsystem for Linux +description: Learn how to set up Git for version control on the Windows Subsystem for Linux. +keywords: wsl, windows, windowssubsystem, gnu, linux, bash, git, github, version control +ms.date: 06/04/2020 +ms.topic: article +ms.localizationpriority: medium +--- + +# GPU accelerated Machine Learning training in the Windows Subsystem for Linux + +Support for GPU compute, the #1 most requested WSL feature, is now available for preview via the Windows Insider program. + +## What is GPU Compute? + +GPU computing is the use of a GPU (graphics processing unit) as a co-processor to accelerate CPUs (central processing units). GPUs typically handle only computation for graphics. GPU computing instead uses those powerful video cards or graphics chips to establish a parallel processing with the CPU to analyze data as if it were an image. The process migrates data into graphical form and uses the GPU to offload some of the compute-intensive and time consuming portions of the code, while the rest of the code continues to run on the CPU. This typically creates significant processing speed improvements. + +## Support for Machine Learning tools like PyTorch and TensorFlow + +Training machine learning models is a time-consuming computational task even when using small datasets. You can now experience the familiarity of using Windows for personal and productivity tools side by side with all the tools you use for these heavy machine learning tasks on native Linux. Thanks to a partnership with NVIDIA, WSL will now support these GPU compute tools, libraries, frameworks, and workflows. + +### NVIDIA CUDA + +To speed-up training, many machine learning tools utilize [CUDA compute platform from NVIDIA](https://developer.nvidia.com/about-cuda) as the default backend for hardware acceleration, including PyTorch and TensorFlow. + +### NVIDIA Container Toolkit + +The [NVIDIA Container Toolkit](https://github.com/NVIDIA/nvidia-docker) allows users to build and run GPU accelerated Docker containers. + +### DirectML + +Windows 10, version 1903, introduced [Direct Machine Learning (DirectML)](https://docs.microsoft.com/windows/win32/direct3d12/dml). DirectML enables hardware accelerated training across the breadth of Windows hardware. It is a low-level API for machine learning with a familiar (native C++, nano-COM) programming interface and enables accelerated inference for machine learning models on any DirectX 12 based GPU. DirectML support has now been extended to WSL with AMD, Intel, and NVIDIA all releasing preview drivers that enable the DirectML TensorFlow package to run both directly on Windows and inside WSL. Read more on the [DirectX Developer blog](https://devblogs.microsoft.com/directx/directx-heart-linux/). + +## Sign up for Windows Insider + +1. Register for the [Windows Insider program](https://insider.windows.com/). + +2. Install the latest build from the Fast ring (Build 20145 or higher) as these newer builds are the only ones that currently supports the GPU Compute functionality. + +3. Install the preview driver for your GPU’s hardware vendor: + - [AMD Driver](.) + - [Intel Driver](.) + - [NVIDIA Driver](.) + +## Prerequisites + +1. Ensure the latest kernel for WSL 2 is installed by hitting “Check for Updates” in Windows Update. + +2. Ensure that your Linux distribution is set to use WSL 2 by opening PowerShell or Windows Command Prompt and entering the command `wsl -l -v`, this will display each Linux distribution you have installed and whether it is set to use WSL 1 or WSL 2. To [update to WSL 2](../install-win10.md#set-your-distribution-version-to-wsl-1-or-wsl-2), use the command: `wsl --set-version 2` + +## Enable DirectML preview + +1. Download [DirectML] and extract the folder to a known location. (We should suggest a place here as an example.) + +2. Install the [tensorflow-directml package]() via pip into your Python environment of choice, using the following command: + + ```bash + pip install ... + ``` + +3. Set an environment variable to the location where you extracted DirectML, using the command: + + ```bash + $env:TF_DIRECTML_PATH= + ``` + +4. Check out the [TensorFlow tutorials](https://www.tensorflow.org/tutorials) or the [PyTorch SqueezeNet sample](https://pytorch.org/hub/pytorch_vision_squeezenet/) to get started training! + +### Install NVIDIA CUDA preview + +1. Install [NVIDIA’s preview driver for WSL](.) + +2. Start using your Linux workflows with NVIDIA Docker or by installing PyTorch or TensorFlow natively inside WSL to start training. **We should show how to install PyTorch and TensorFlow.* + +## Additional resources + +- [CUDA on Windows Subsystem for Linux - Public Preview](https://developer.nvidia.com/cuda/wsl) + +- [DirectML Samples](https://github.com/Microsoft/DirectML-Samples) From 245841f551e357535a831ba6ad0926a91702c593 Mon Sep 17 00:00:00 2001 From: Matt Wojciakowski Date: Mon, 15 Jun 2020 16:46:09 -0700 Subject: [PATCH 2/4] GPU acceleration tutorial link --- WSL/toc.yml | 2 + WSL/tutorials/gpu-compute.md | 83 ++++++++---------------------------- 2 files changed, 20 insertions(+), 65 deletions(-) diff --git a/WSL/toc.yml b/WSL/toc.yml index a847cc43..2ea822da 100644 --- a/WSL/toc.yml +++ b/WSL/toc.yml @@ -22,6 +22,8 @@ href: tutorials/wsl-vscode.md - name: Get started with Git href: tutorials/wsl-git.md + - name: Set up GPU acceleration (NVIDIA CUDA/DirectML) + href: tutorials/gpu-compute.md - name: How-to items: - name: Interoperability commands diff --git a/WSL/tutorials/gpu-compute.md b/WSL/tutorials/gpu-compute.md index ece6cd3b..e7a771a5 100644 --- a/WSL/tutorials/gpu-compute.md +++ b/WSL/tutorials/gpu-compute.md @@ -1,79 +1,32 @@ --- title: GPU accelerated Machine Learning training in the Windows Subsystem for Linux -description: Learn how to set up Git for version control on the Windows Subsystem for Linux. -keywords: wsl, windows, windowssubsystem, gnu, linux, bash, git, github, version control -ms.date: 06/04/2020 +description: Learn more about WSL 2 support for NVIDIA CUDA, DirectML, Tensorflow, and PyTorch. +keywords: wsl, windows, windowssubsystem, gpu compute, gpu acceleratin, NVIDIA, CUDA, DirectML, Tensorflow, PyTorch, NVIDIA CUDA preview, GPU driver, NVIDIA Container Toolkit, Docker +ms.date: 06/17/2020 ms.topic: article ms.localizationpriority: medium --- # GPU accelerated Machine Learning training in the Windows Subsystem for Linux -Support for GPU compute, the #1 most requested WSL feature, is now available for preview via the Windows Insider program. +Support for GPU compute, the #1 most requested WSL feature, is now available for preview via the Windows Insider program. [Learn more.](https://docs.microsoft.com/windows/win32/direct3d12/gpu-accelerated-training) ## What is GPU Compute? -GPU computing is the use of a GPU (graphics processing unit) as a co-processor to accelerate CPUs (central processing units). GPUs typically handle only computation for graphics. GPU computing instead uses those powerful video cards or graphics chips to establish a parallel processing with the CPU to analyze data as if it were an image. The process migrates data into graphical form and uses the GPU to offload some of the compute-intensive and time consuming portions of the code, while the rest of the code continues to run on the CPU. This typically creates significant processing speed improvements. +GPU acceleration is also sometimes referred to as "GPU Compute." GPU computing is the use of a GPU (graphics processing unit) as a co-processor to accelerate CPUs (central processing units). GPUs typically handle only computation for graphics. GPU computing instead uses those powerful video cards or graphics chips to establish a parallel processing with the CPU to analyze data as if it were an image. The process migrates data into graphical form and uses the GPU to offload some of the compute-intensive and time consuming portions of the code, while the rest of the code continues to run on the CPU. This typically creates significant processing speed improvements. Training machine learning models is a great example in which GPU compute can significantly accelerate the time to complete a computational task. -## Support for Machine Learning tools like PyTorch and TensorFlow +## Install and set up -Training machine learning models is a time-consuming computational task even when using small datasets. You can now experience the familiarity of using Windows for personal and productivity tools side by side with all the tools you use for these heavy machine learning tasks on native Linux. Thanks to a partnership with NVIDIA, WSL will now support these GPU compute tools, libraries, frameworks, and workflows. +Learn more about WSL 2 support and how to start training machine learning models in the [GPU Accelerated Training guide](https://docs.microsoft.com/windows/win32/direct3d12/gpu-accelerated-training) inside the Direct Machine Learning docs. This guide covers: -### NVIDIA CUDA - -To speed-up training, many machine learning tools utilize [CUDA compute platform from NVIDIA](https://developer.nvidia.com/about-cuda) as the default backend for hardware acceleration, including PyTorch and TensorFlow. - -### NVIDIA Container Toolkit - -The [NVIDIA Container Toolkit](https://github.com/NVIDIA/nvidia-docker) allows users to build and run GPU accelerated Docker containers. - -### DirectML - -Windows 10, version 1903, introduced [Direct Machine Learning (DirectML)](https://docs.microsoft.com/windows/win32/direct3d12/dml). DirectML enables hardware accelerated training across the breadth of Windows hardware. It is a low-level API for machine learning with a familiar (native C++, nano-COM) programming interface and enables accelerated inference for machine learning models on any DirectX 12 based GPU. DirectML support has now been extended to WSL with AMD, Intel, and NVIDIA all releasing preview drivers that enable the DirectML TensorFlow package to run both directly on Windows and inside WSL. Read more on the [DirectX Developer blog](https://devblogs.microsoft.com/directx/directx-heart-linux/). - -## Sign up for Windows Insider - -1. Register for the [Windows Insider program](https://insider.windows.com/). - -2. Install the latest build from the Fast ring (Build 20145 or higher) as these newer builds are the only ones that currently supports the GPU Compute functionality. - -3. Install the preview driver for your GPU’s hardware vendor: - - [AMD Driver](.) - - [Intel Driver](.) - - [NVIDIA Driver](.) - -## Prerequisites - -1. Ensure the latest kernel for WSL 2 is installed by hitting “Check for Updates” in Windows Update. - -2. Ensure that your Linux distribution is set to use WSL 2 by opening PowerShell or Windows Command Prompt and entering the command `wsl -l -v`, this will display each Linux distribution you have installed and whether it is set to use WSL 1 or WSL 2. To [update to WSL 2](../install-win10.md#set-your-distribution-version-to-wsl-1-or-wsl-2), use the command: `wsl --set-version 2` - -## Enable DirectML preview - -1. Download [DirectML] and extract the folder to a known location. (We should suggest a place here as an example.) - -2. Install the [tensorflow-directml package]() via pip into your Python environment of choice, using the following command: - - ```bash - pip install ... - ``` - -3. Set an environment variable to the location where you extracted DirectML, using the command: - - ```bash - $env:TF_DIRECTML_PATH= - ``` - -4. Check out the [TensorFlow tutorials](https://www.tensorflow.org/tutorials) or the [PyTorch SqueezeNet sample](https://pytorch.org/hub/pytorch_vision_squeezenet/) to get started training! - -### Install NVIDIA CUDA preview - -1. Install [NVIDIA’s preview driver for WSL](.) - -2. Start using your Linux workflows with NVIDIA Docker or by installing PyTorch or TensorFlow natively inside WSL to start training. **We should show how to install PyTorch and TensorFlow.* - -## Additional resources - -- [CUDA on Windows Subsystem for Linux - Public Preview](https://developer.nvidia.com/cuda/wsl) - -- [DirectML Samples](https://github.com/Microsoft/DirectML-Samples) +* Enabling the NVIDIA CUDA preview +* Installing the correct GPU driver, which might include: + * AMD Radeon™ RX series and Radeon™ VII graphics + * AMD Radeon™ Pro series graphics + * AMD Ryzen™ and Ryzen™ PRO Processors with Radeon™ Vega graphics + * AMD Ryzen™ and Ryzen™ PRO Mobile Processors with Radeon™ Vega graphics + * Intel DirectML preview driver + * NVIDIA CUDA-enabled driver +* Guidance for beginners or students to set up TensorFlow with a DirectML backend +* Guidance for professionals to start using your existing Linux workflows through NVIDIA Docker or by installing PyTorch or TensorFlow +* Support for NVIDIA Container Toolkit From 127fd02b6b1f4eb9b8c3e7b488e4ef6b416f1db8 Mon Sep 17 00:00:00 2001 From: Matt Wojciakowski Date: Tue, 16 Jun 2020 11:10:11 -0700 Subject: [PATCH 3/4] update intro link --- WSL/tutorials/gpu-compute.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WSL/tutorials/gpu-compute.md b/WSL/tutorials/gpu-compute.md index e7a771a5..f7f6c4bf 100644 --- a/WSL/tutorials/gpu-compute.md +++ b/WSL/tutorials/gpu-compute.md @@ -1,7 +1,7 @@ --- title: GPU accelerated Machine Learning training in the Windows Subsystem for Linux description: Learn more about WSL 2 support for NVIDIA CUDA, DirectML, Tensorflow, and PyTorch. -keywords: wsl, windows, windowssubsystem, gpu compute, gpu acceleratin, NVIDIA, CUDA, DirectML, Tensorflow, PyTorch, NVIDIA CUDA preview, GPU driver, NVIDIA Container Toolkit, Docker +keywords: wsl, windows, windows subsystem, gpu compute, gpu acceleration, NVIDIA, CUDA, DirectML, Tensorflow, PyTorch, NVIDIA CUDA preview, GPU driver, NVIDIA Container Toolkit, Docker ms.date: 06/17/2020 ms.topic: article ms.localizationpriority: medium @@ -9,7 +9,7 @@ ms.localizationpriority: medium # GPU accelerated Machine Learning training in the Windows Subsystem for Linux -Support for GPU compute, the #1 most requested WSL feature, is now available for preview via the Windows Insider program. [Learn more.](https://docs.microsoft.com/windows/win32/direct3d12/gpu-accelerated-training) +Support for GPU compute, the #1 most requested WSL feature, is now available for preview via the Windows Insider program. [Read the blog post](https://devblogs.microsoft.com/commandline/). ## What is GPU Compute? From 045af616f24f4a3e37a9d54261deb1da65c0f8cf Mon Sep 17 00:00:00 2001 From: Clarke Rahrig Date: Tue, 16 Jun 2020 18:47:36 -0700 Subject: [PATCH 4/4] GPU compute and install section edits Simplified the GPU compute section to emphasize the parallelization of math as the big win with a GPU. Removed some of the content in the install section as the high level workflows makes the most sense to call out IMO. --- WSL/tutorials/gpu-compute.md | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/WSL/tutorials/gpu-compute.md b/WSL/tutorials/gpu-compute.md index f7f6c4bf..ecebee08 100644 --- a/WSL/tutorials/gpu-compute.md +++ b/WSL/tutorials/gpu-compute.md @@ -7,26 +7,17 @@ ms.topic: article ms.localizationpriority: medium --- -# GPU accelerated Machine Learning training in the Windows Subsystem for Linux +# GPU accelerated machine learning training in the Windows Subsystem for Linux -Support for GPU compute, the #1 most requested WSL feature, is now available for preview via the Windows Insider program. [Read the blog post](https://devblogs.microsoft.com/commandline/). +Support for GPU compute, the #1 most requested WSL feature, is now available for preview via the Windows Insider program. [Read the blog post](https://blogs.windows.com/windowsdeveloper/?p=55781). -## What is GPU Compute? +## What is GPU compute? -GPU acceleration is also sometimes referred to as "GPU Compute." GPU computing is the use of a GPU (graphics processing unit) as a co-processor to accelerate CPUs (central processing units). GPUs typically handle only computation for graphics. GPU computing instead uses those powerful video cards or graphics chips to establish a parallel processing with the CPU to analyze data as if it were an image. The process migrates data into graphical form and uses the GPU to offload some of the compute-intensive and time consuming portions of the code, while the rest of the code continues to run on the CPU. This typically creates significant processing speed improvements. Training machine learning models is a great example in which GPU compute can significantly accelerate the time to complete a computational task. +Leveraging GPU acceleration for compute-intensive tasks is generally referred to as "GPU compute". GPU computing leverages the GPU (graphics processing unit) to accelerate math heavy workloads and uses its parallel processing to complete the required calculations faster, in many cases, than utilizing only a CPU. This parallelization enables significant processing speed improvements for these math heavy workloads then when running on a CPU. Training machine learning models is a great example in which GPU compute can significantly accelerate the time to complete this computationally expensive task. ## Install and set up -Learn more about WSL 2 support and how to start training machine learning models in the [GPU Accelerated Training guide](https://docs.microsoft.com/windows/win32/direct3d12/gpu-accelerated-training) inside the Direct Machine Learning docs. This guide covers: +Learn more about WSL 2 support and how to start training machine learning models in the [GPU Accelerated Training guide](https://docs.microsoft.com/windows/win32/direct3d12/gpu-accelerated-training) inside the DirectML docs. This guide covers: -* Enabling the NVIDIA CUDA preview -* Installing the correct GPU driver, which might include: - * AMD Radeon™ RX series and Radeon™ VII graphics - * AMD Radeon™ Pro series graphics - * AMD Ryzen™ and Ryzen™ PRO Processors with Radeon™ Vega graphics - * AMD Ryzen™ and Ryzen™ PRO Mobile Processors with Radeon™ Vega graphics - * Intel DirectML preview driver - * NVIDIA CUDA-enabled driver -* Guidance for beginners or students to set up TensorFlow with a DirectML backend -* Guidance for professionals to start using your existing Linux workflows through NVIDIA Docker or by installing PyTorch or TensorFlow -* Support for NVIDIA Container Toolkit +* Guidance for beginners or students to set up TensorFlow with DirectML +* Guidance for professionals to start running their exisiting CUDA ML workflows