Accessorizing PowerShell, remote debugging Linux (Deep Learning Series Pt 1.5)

Jose M
5 min readFeb 24, 2020

--

This article is part of a series on Deep Learning models on Windows 10 using Python 🐍. Stay tuned for more!

Intro

As with anything else, training DL models requires an established, and hopefully easy-to-use, workflow & IDE. PowerShell is at the core of said IDE.

PowerShell 6+ by itself is a powerful tool, but when coupled with WSL, PS modules and remote debugging, it transforms into an extraordinary, dream all-in-one shell for all your dev needs.

Windows Subsystem for Linux (WSL) & WSL 2 😼

WSL is a native Linux shell that enables you to run Linux commands directly on Windows. You choose a distro, install it, and open up its bash (cli/shell). FAQ here.

  • Installing WSL v1 🧐
  • Upgrading to WSL v2 🐱‍👤

In this section we will be both installing WSL version 1, and later upgrading to version 2. WSL v2 brings: the actual Linux kernel, significantly better I/O performance & full system call compatibility.

Installing WSL v1 🧐

Microsoft offers a few versions of Linux available for download. For the full list, see this page. We will be using Ubuntu 18.04. Let’s get started!

  1. Open PowerShell 6 as Administrator.
  2. Run the following command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

3. Say [Y] Yes To All, and reboot your machine. You will now have WSL v1 installed after reboot!

4. Open up a regular PowerShell. Make a clean directory (folder) to install Linux on.

5. For me, that means the following commands:

cd documents
mkdir work
mkdir ubuntu
cd work/ubuntu

6. I’m now in the work/ubuntu folder. This is where the package will download to.

7. Paste in this command. Note that I’m installing Ubuntu 18.04. If you wish to install another version or distro, you’ll have to change the -Uri parameter.

Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu-1804.appx -UseBasicParsing

It’s a ~200MB package so it shouldn’t take long.You will see something like this.

8. Run this command to actually install the Linux distro:

Add-AppxPackage .\Ubuntu-1804.appx

9. It should now appear as a program on your PC. Search for “Ubuntu 18.04

10. Open it. The first launch will trigger an install of the Linux distro, like so:

11. It will then ask you for an username/password combo. Put it in & press enter.

12. Pin it to your taskbar so it’s easily accessible:

That’s it! You’re done with installing WSL v1 & your first Linux distro. ✅

Upgrading to WSL v2 🐱‍👤

WSL 2 requires Windows 10 build 18917 or higher. “winver” will tell you your OS build.

Win OS build 18917+ is currently only available through the Windows Insiders Program, which requires your telemetry settings to be set to “Full”.

An option is to opt-in to the program, install WSL v2, and then opt-out & revert all telemetry settings. Your installation of WSL 2 will remain.

  1. Open PowerShell as Administrator.

2. Run these commands:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

3. Search for “Windows features”. Click on “Turn on Windows features on or off”:

4. Verify that “Virtual Machine Platform” & “Windows Subsystem for Linux“ are enabled. Press “OK”.

5. You’ll now have to (temporarily) join the Windows Insider Program in order to update to build 18917+. You can search “Insider Settings” and this will pop up. Click Get Started

6. You will now have to link a Microsoft account. An email is sufficient. Click “Link an account”. 🐱‍🚀

7. After you’ve signed in, click “Register” then “Sign Up”. Accept the terms and submit.

8. A loading screen will appear. This can take ~15 minutes. If it is taking too long, press Cancel and click “Get Started” again.

9. Go to Windows Update, click “Check for updates”. You should now see the Insider Preview build installing. It will take around ~1 hour for it to download and install. 😲

10. When it’s ready, it will ask you to Restart your computing device (computer).

11. Once it boots back up, open PowerShell and run:

wsl -l -v

12. It should show you this. If you see anything else, you have failed. The command above only works on WSL 2.

13. Now let’s upgrade our Ubuntu install to WSL 2. It’ll take ~5 min. Run:

wsl --set-version Ubuntu-18.04 2

Congratulations!! 🎉🎉 You’ve upgraded to WSL 2 and also updated your distro to v2! ✅

Remote debugging/development on Linux with VS Code 🥳

Coming soon! Check back for updates.

--

--