WSL 2 on Windows

Anh-Thi Dinh

Installation

1# Eanble Windows Subsystem for Linux
2# PowerShell as Admin
3dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
4
5# Enable Virtual Machine Platform (for WSL2)
6dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
7
8# restart required
1# Download and install WSL2 Linux kernel update package for x64 machines
2<https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi>
1# Set WSL2 as default version
2# PowerShell as Admin
3wsl --set-default-version 2
1# Go to Windows Store
2# Choose a Linux Distro and install it
3
4# After installing, run Ubuntu app from Start menu
5# Follow the instruction on screen
6
7# Update system
8sudo apt update
9sudo apt upgrade # be careful, it takes time!
10
11# Install dependencies (it takes time)
12sudo apt-get install git-core curl wget fontconfig zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev
👉 Note: Linux
👉 Note:
Fresh Ubuntu / Pop!_OS Installation
👉 Note:
Bash (Unix Shell)

Location

  • The C drive is located in /mnt/c/.
  • The Download folder is located in /mnt/c/Users/dinha/Downloads/.
  • Open current folder (in WSL2) with Windows Explorer: explorer.exe ..
  • If you wanna create a drive (eg. Z): click on Linux icon in Explorer > Right click on Ubuntu folder > "Map network drive.."

Terminal?

I use cmder. Read more in this note.

Docker + GPU + WSL

  1. Make WSL2 recognize GPU on Windows 10 👉 Check this tut with some remarks:
  1. Microsoft's: Enable TensorFlow with DirectML in WSL 2. Note that, you have to use the version of python look like exactly in the guide (mine, it's 3.6), otherwise, it won't work!
1# check if gpu available with docker on wsl2
2docker run --rm -it --gpus=all nvcr.io/nvidia/k8s/cuda-sample:nbody nbody -gpu -benchmark
3
4# should see something like this
5> Windowed mode
6> Simulation data stored in video memory
7> Single precision floating point simulation
8> 1 Devices used for simulation
9GPU Device 0: "GeForce GTX 1070" with compute capability 6.1
10
11> Compute 6.1 CUDA device: [GeForce GTX 1070]
1215360 bodies, total time for 10 iterations: 11.949 ms
13= 197.446 billion interactions per second
14= 3948.925 single-precision GFLOP/s at 20 flops per interaction
👉 Check some tests in this section.

Jekyll on WSL2

Remark: We should clone a new version from Github to the local (inside wsl) machine.
1sudo apt-get install -y ruby-full build-essential zlib1g-dev
2which ruby
3
4# Make sure we don't use gem on Windows system
5which gem # /usr/bin/ruby
6
7source ~/.zshrc
8# restart Windows Terminal
9
10sudo gem install bundler
11
12# cd to jekyll theme folder
13bundle install
14
15# continue as usual
16bundle exec jekyll build # 1st time after installing
17bundle exec jekyll serve
18bundle exec jekyll serve -I
1# Troubleshoot: Could not find a JavaScript runtime
2sudo apt-get install libv8-dev
3bundle update
4# install nodejs
5curl -sL <https://deb.nodesource.com/setup_14.x> | bash -
6sudo apt-get install -y nodejs
1# Troubleshoot: wsl2 jekyll auto generation windows
2# Clone a repo to wsl local, not clone by git on Windows!

VSCode + WSL2 + jekyll

  1. Install extension Remote-WSL
  1. Connect via Debian instead! (><SWL: Debian)

WSL with cmder

Settings > Startup > Tasks > +
1# for debian
2set PATH="%ConEmuBaseDirShort%\\wsl";%PATH% & wsl -d debian
3# for ubuntu
4set PATH="%ConEmuBaseDirShort%\\wsl";%PATH% & wsl -d ubuntu
Choose font Cascadia Code in General > Fonts.
Loading comments...