Windows Subsystem for Linux (WSL)¶
If you use Windows, WSL allows you to run Linux on Windows without a virtual machine.
Why Use WSL?¶
WSL provides several advantages over traditional dual-booting or virtual machines:
Seamless Integration: Run Linux commands and tools directly on Windows without rebooting
Performance: Better performance than traditional virtual machines for file operations
Resource Sharing: Access Windows files from Linux and vice versa
Development Continuity: Use familiar Windows applications alongside Linux tools
Easy Setup: Simple installation compared to setting up virtual machines or dual systems
Advantages for Machine Learning Development¶
WSL is particularly beneficial for machine learning projects:
Native Linux Tools: Access to Linux-specific ML frameworks and libraries that may not work well on Windows
GPU Support: Direct access to NVIDIA GPUs for CUDA acceleration
Package Management: Use apt, conda, and pip seamlessly for managing ML dependencies
Docker Integration: Run Docker containers natively for reproducible ML environments
Large Ecosystem: Full access to Linux ML tools like TensorFlow, PyTorch, Jupyter, etc.
File System Performance: Faster file operations compared to virtual machines, crucial for large datasets
Installing WSL¶
System Requirements¶
Before installing WSL, ensure your system meets these requirements:
Windows Version: Windows 10 version 2004 (Build 19041) or higher, or Windows 11
Architecture: 64-bit processor
Virtualization: Virtualization must be enabled in BIOS/UEFI
Storage: At least 2GB free disk space
Memory: At least 4GB RAM (8GB recommended for development)
Check Virtualization¶
Open Task Manager (Ctrl+Shift+Esc)
Go to Performance tab
Check if “Virtualization” shows “Enabled”
If disabled, restart your computer and enter BIOS (usually Del, F2, or F10 key) to enable virtualization.
Installation Steps¶
Follow documentation from Microsoft for the latest instructions: Install WSL
Method 1: Automatic Installation (Recommended)¶
Open PowerShell as Administrator:
Press Windows key, type “PowerShell”
Right-click “Windows PowerShell” and select “Run as administrator”
Run the Installation Command:
wsl --install
This command installs WSL2 by default with Ubuntu as the default distribution.
Restart Your Computer when prompted.
Complete Setup:
After restart, Ubuntu will open automatically
Set up your Linux username and password
The installation is complete!
Method 2: Manual Installation (if automatic fails)¶
If the automatic method doesn’t work:
Enable WSL Feature:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Enable Virtual Machine Platform:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart your computer
Download and Install Linux Kernel Update Package:
Visit: https://aka.ms/wsl2kernel
Install the package
Set WSL2 as Default:
wsl --set-default-version 2
Install Ubuntu from Microsoft Store:
Open Microsoft Store
Search for “Ubuntu” (or other distributions like “Ubuntu 22.04 LTS”)
Click “Get” to install
Choosing a Linux Distribution¶
Popular options in Microsoft Store:
Ubuntu: Most popular, great for general development
Ubuntu 22.04 LTS: Long-term support version
Debian: Lightweight and stable
openSUSE: Good for enterprise users
Fedora: Cutting-edge features
Verifying Installation¶
After installation, verify WSL is working:
Open PowerShell or Command Prompt
Run:
wsl --list --verbose
You should see your distribution listed with STATE: Running and VERSION: 2
Test Linux commands:
wsl uname -a # Should show Linux kernel info
Updating WSL¶
Keep WSL updated:
wsl --update
Check for distribution updates:
sudo apt update && sudo apt upgrade
Configuring WSL¶
After installation:
Open the Ubuntu app
Set username and password
Update the system:
sudo apt update sudo apt upgrade