# Windows Subsystem for Linux (WSL) If you use Windows, [WSL](https://docs.microsoft.com/en-us/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](https://docs.microsoft.com/en-us/windows/wsl/install) #### Method 1: Automatic Installation (Recommended) 1. **Open PowerShell as Administrator**: - Press Windows key, type "PowerShell" - Right-click "Windows PowerShell" and select "Run as administrator" 2. **Run the Installation Command**: ```powershell wsl --install ``` This command installs WSL2 by default with Ubuntu as the default distribution. 3. **Restart Your Computer** when prompted. 4. **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: 1. **Enable WSL Feature**: ```powershell dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart ``` 2. **Enable Virtual Machine Platform**: ```powershell 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**: ```powershell 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](https://apps.microsoft.com): - [**Ubuntu**](https://apps.microsoft.com/detail/9pdxgncfsczv?hl=en-GB&gl=CA): Most popular, great for general development - [**Ubuntu 22.04 LTS**](https://apps.microsoft.com/detail/9pn20msr04dw?hl=en-GB&gl=CA): Long-term support version - [**Debian**](https://apps.microsoft.com/detail/9msvkqc78pk6?hl=en-GB&gl=CA): Lightweight and stable - [**openSUSE**](https://apps.microsoft.com/detail/9mssk2zxxn11?hl=en-GB&gl=CA): Good for enterprise users - [**Fedora**](https://apps.microsoft.com/detail/9n6gdm4k2hnc?hl=en-GB&gl=CA): Cutting-edge features ### Verifying Installation After installation, verify WSL is working: 1. Open PowerShell or Command Prompt 2. Run: ```batch wsl --list --verbose ``` You should see your distribution listed with STATE: Running and VERSION: 2 3. Test Linux commands: ```bash wsl uname -a # Should show Linux kernel info ``` ### Updating WSL Keep WSL updated: ```powershell wsl --update ``` Check for distribution updates: ```bash sudo apt update && sudo apt upgrade ``` ## Configuring WSL After installation: 1. Open the Ubuntu app 2. Set username and password 3. Update the system: ```bash sudo apt update sudo apt upgrade ```