Diego Barros Araya
All notes

Linux vs Windows for AI, Scripts, and Automation

Practical tradeoffs between native Linux and Windows+WSL2 for AI/ML development, scripting, and automation: GPU support, filesystem performance, and packaging.

Updated · linux, windows, ai

Linux and Windows with WSL2 are now close for AI/ML and scripting work. In 2026 the right choice depends on the workload, not on a general claim that Linux is better.

Decision flow

Yes

No, single NVIDIA GPU

Assess GPU / workload needs

Multi-GPU training,
AMD GPU, or 24/7
bare-metal inference?

Prefer native Linux

WSL2 is production-ready

Evaluate Windows app
dependencies (Office, VPN, Hyper-V)

Set up package ecosystem
inside WSL, not on Windows

Keep code on the WSL ext4
filesystem, never /mnt/c/

Install NVIDIA Windows driver once
(covers CUDA in WSL automatically)

Configure Docker Desktop
WSL2 backend + verify nvidia-smi

Steps

  1. Assess GPU and workload requirements. Multi-GPU training, AMD GPUs, or 24/7 bare-metal inference favor native Linux. A single NVIDIA GPU on Windows works under WSL2. Use the WSL3 preview if you need near-native GPU numbers.
  2. Check Windows application dependencies. If you need Windows-only tools (Office, Hyper-V, a corporate VPN client), start with WSL2 on Windows instead of bare Linux.
  3. Choose your WSL tier. Use WSL2 stable for development and containers. WSL3 (preview as of August 2026) gets CUDA/PyTorch within ~3-5% of bare metal. Do not use it in production yet.
  4. Set up the package ecosystem in the right place. apt/conda/pip inside WSL (or native Linux), not on Windows itself. On native Windows, winget/Scoop cover CLI tools only.
  5. Keep the project filesystem inside WSL’s ext4, not under /mnt/c/Users/.... Crossing that boundary costs 7-60x on I/O and metadata operations.
  6. Install GPU drivers once, correctly. On WSL2, install the NVIDIA Windows driver. It exposes CUDA to WSL automatically. On native Linux: install the driver per distro/GPU. Verify either way with nvidia-smi.
  7. Set up containers and confirm GPU passthrough. Docker Desktop with the WSL2 backend needs Windows 10 build 19045+ or Windows 11 23H2+ and WSL 2.1.5+. Confirm nvidia-smi and CUDA libraries are visible inside the container, not just on the host.
  8. Pick your scripting shell deliberately. Bash on WSL2/Linux for portable automation; PowerShell 7+ only when you’re specifically automating Windows infrastructure.

Tips

  • Clone all repos into the WSL filesystem. Cloning onto the Windows side is the most common WSL2 performance mistake.
  • Use VS Code Remote-SSH into WSL2: edit on Windows, run/compile on Linux, no path-translation overhead.
  • Create conda environments only inside WSL. A Windows-created environment and a WSL-created one are separate ecosystems, even though they share NTFS.
  • Winget ships with Windows 11, so you rarely need Chocolatey or Scoop for basic CLI tools.
  • Use NixOS if you control the infrastructure and want declarative, reproducible builds. Otherwise, plain apt/dnf is simpler.

Common pitfalls

  • Windows paths baked into .bashrc/.gitconfig (e.g. USERPROFILE=/mnt/c/Users/...) quietly keeps even pure-Linux operations on slow Windows filesystem performance.
  • inotify-based file watching from /mnt/c (nodemon, pytest --watch, webpack, cargo watch) is unreliable. Keep watched files on the WSL filesystem.
  • GPU driver version mismatch: WSL2 CUDA support uses the Windows NVIDIA driver, not a Linux one. A mismatched driver version breaks GPU access completely.
  • Assuming WSL3 is generally available: as of August 2026, it is preview only. Use WSL2 for production.
  • Docker Desktop WSL2 integration failing silently on WSL below 2.1.5 with a cryptic “distro not registered” error: run wsl --update first.
  • Switching between WSL2 and native Linux mid-project causes git config confusion (/mnt/c paths vs /home paths). Commit to one platform per project.

Sources