An Ultimate Guide to Setup a CUDA-enabled Linux System on Windows11

Xinzhe Li, PhD in Language Intelligence
Level Up Coding
Published in
3 min readOct 31, 2021

--

The Linux OS with a Bash shell provides a familiar and highly controllable workflow for programmers. However, we always need the Windows system to offer other common software for our daily work and amusement activities. To seamlessly transfer between the Linux/Bash interface and Windows interface, we provide two options in this post.

This is a practical guide. Therefore, I would explain each command for an in-depth understanding and note the caveats (I would assume that readers are qualified programmers who are familiar with common bash commands). In addition, since the code snippets are embedded in this post, the change would reflect on this post to ensure that it would not be outdated every time I update the original code snippets.

Again, this is a practical guide. I would list the pros and cons of each solution at the beginning so that you can choose the one fitting into you case and go that section. I only list the pros of each solution, since the pros of one solution would become the cons of the other. For the second solution, although there are many cloud providers offering Virtual Machines, I find that Azure is mostly compatible with some common Microsoft software on Windows. For example, you can get almost native experience of VS code with the extensions and high-speed network.

WSL2

  • provides a totally native experience (as far as I have experienced)
  • can be used offline without Internet
  • has no network delay

Azure Virtual Machine

  • can enable multiple GPUs
  • provides a complete Python environment, even common data science libraries and machine learning frameworks

Windows Subsystem for Linux

Microsoft now uses Windows Subsystem for Linux (WSL). More amazingly deep learning practitioners, WSL2 now supports Nvidia GPUs with CUDA since the underlying Linux Kernel is now based on Microsoft Hyper-V.

However, there are some caveats if you only follows the official guidelines from Microsoft and Nvidia. Therefore, this article provides a very concise guideline to avoid these caveats.

One More Caveat In Use

Another Solution: Using Azure Linux Virtual Machine on Windows

The script performs automated creation and setup of Data Science Virtual Machine. I also elaborate the details for each command. So read it once you use it.

(Optional) Setup the Python Environment on Linux

This snippet is not necessary if you use the Azure DSVM, but would be helpful if you use WSL2, where you need setup the environment by yourself.

--

--