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

  1. Open Task Manager (Ctrl+Shift+Esc)

  2. Go to Performance tab

  3. 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 2: Manual Installation (if automatic fails)

If the automatic method doesn’t work:

  1. Enable WSL Feature:

    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    
  2. Enable Virtual Machine Platform:

    dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
    
  3. Restart your computer

  4. Download and Install Linux Kernel Update Package:

    • Visit: https://aka.ms/wsl2kernel

    • Install the package

  5. Set WSL2 as Default:

    wsl --set-default-version 2
    
  6. 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:

Verifying Installation

After installation, verify WSL is working:

  1. Open PowerShell or Command Prompt

  2. Run:

    wsl --list --verbose
    

    You should see your distribution listed with STATE: Running and VERSION: 2

  3. 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:

  1. Open the Ubuntu app

  2. Set username and password

  3. Update the system:

    sudo apt update
    sudo apt upgrade