DEV Community

Cover image for How I Built a Clean Two‑WSL Architecture (One for Dev, One for AI). And Why It Changed Everything
Adam Mawlawi
Adam Mawlawi

Posted on • Edited on

How I Built a Clean Two‑WSL Architecture (One for Dev, One for AI). And Why It Changed Everything

For a long time, I tried to force all my tools into a single WSL Ubuntu environment.

Node, Python, .NET, Docker, PyTorch, CUDA, Jupyter, Transformers, all living together like one big chaotic family.

And like any chaotic family, they fought. A lot.

I kept running into:

  • Conflicting Python versions
  • Node tools breaking AI tools
  • CUDA updates breaking everything
  • Slow environments
  • Dependency hell

Eventually, I realized something important:

I don't need one WSL. I need two.

One for development.

One for AI.

That simple shift changed my entire workflow.

After a lot of deep searching, testing, breaking, and rebuilding, I finally landed on a clean, scalable architecture that I'm now sharing publicly — because it solved problems I know many developers struggle with.

This is the setup I wish I had from day one.

🧠 Why Two WSL Distros Instead of One?

Dev tools and AI tools don't mix well.

  • AI needs CUDA, PyTorch, GPU drivers, heavy Python packages
  • Dev needs Node, .NET, Docker, databases, build tools
  • Updating one often breaks the other
  • Virtual environments help, but they don't isolate system-level dependencies

So I split them:

+------------------+        +------------------+
|   Ubuntu-dev     |        |    Ubuntu-ai     |
|------------------|        |------------------|
| Node.js (NVM)    |        | PyTorch (CUDA)   |
| Python (dev)     |        | Transformers     |
| .NET SDK         |        | JupyterLab       |
| Docker client    |        | AI venv          |
+------------------+        +------------------+
        \                          /
         \________________________/
                 Shared:
        - SSH keys
        - Git identity
        - Base packages
        - Bootstrap folder
Enter fullscreen mode Exit fullscreen mode

This keeps everything consistent while giving each environment its own purpose.

🏗 Step 1 — Export Your Existing Ubuntu

wsl --export Ubuntu ubuntu-base.tar
Enter fullscreen mode Exit fullscreen mode

📁 Step 2 — Create Folders for the New Distros

mkdir C:\WSL\Ubuntu-dev
mkdir C:\WSL\Ubuntu-ai
Enter fullscreen mode Exit fullscreen mode

📦 Step 3 — Import the New Distros

wsl --import Ubuntu-dev C:\WSL\Ubuntu-dev ubuntu-base.tar
wsl --import Ubuntu-ai  C:\WSL\Ubuntu-ai  ubuntu-base.tar
Enter fullscreen mode Exit fullscreen mode

⚡ Step 4 — Add Quick Commands (dev and ai)

notepad $PROFILE
Enter fullscreen mode Exit fullscreen mode

Add:

function dev { wsl -d Ubuntu-dev }
function ai  { wsl -d Ubuntu-ai }
Enter fullscreen mode Exit fullscreen mode

Restart PowerShell.

Now you can jump into each distro instantly:

dev
ai
Enter fullscreen mode Exit fullscreen mode

📂 Step 5 — Create a Shared Bootstrap Folder

mkdir C:\Users\YourName\WSL-bootstrap
Enter fullscreen mode Exit fullscreen mode

🔧 Step 6 — The Common Bootstrap Script

bootstrap-common.sh

#!/usr/bin/env bash
set -euo pipefail

sudo apt update
sudo apt install -y build-essential curl git ca-certificates software-properties-common unzip

if [ -d "/mnt/c/Users/YourName/.ssh" ]; then
  rm -rf "$HOME/.ssh"
  ln -s "/mnt/c/Users/YourName/.ssh" "$HOME/.ssh"
fi

git config --global user.name "YourName"
git config --global user.email "your.email@example.com"

echo "[common] Base packages and SSH/Git configured."
Enter fullscreen mode Exit fullscreen mode

💻 Step 7 — Dev WSL Setup (Ubuntu-dev)

bootstrap-dev.sh

#!/usr/bin/env bash
set -euo pipefail

"$(dirname "$0")/bootstrap-common.sh"

if [ ! -d "$HOME/.nvm" ]; then
  curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
fi

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

nvm install --lts
nvm use --lts

npm install -g yarn pnpm

sudo apt install -y python3 python3-pip python3-venv

wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install -y dotnet-sdk-8.0

echo "[dev] Node, Python, .NET installed."
Enter fullscreen mode Exit fullscreen mode

Run it:

dev
Enter fullscreen mode Exit fullscreen mode

Inside WSL:

cd /mnt/c/Users/YourName/WSL-bootstrap
chmod +x *.sh
./bootstrap-dev.sh
Enter fullscreen mode Exit fullscreen mode

🤖 Step 8 — AI WSL Setup (Ubuntu-ai)

bootstrap-ai.sh

#!/usr/bin/env bash
set -euo pipefail

"$(dirname "$0")/bootstrap-common.sh"

sudo apt install -y python3 python3-pip python3-venv

if [ ! -d "$HOME/venvs/ai" ]; then
  mkdir -p "$HOME/venvs"
  python3 -m venv "$HOME/venvs/ai"
fi

source "$HOME/venvs/ai/bin/activate"

pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
pip install "transformers[torch]" datasets accelerate jupyterlab

echo "[ai] Base AI environment ready (PyTorch, Transformers, Jupyter)."
Enter fullscreen mode Exit fullscreen mode

Run it:

ai
Enter fullscreen mode Exit fullscreen mode

Inside WSL:

cd /mnt/c/Users/YourName/WSL-bootstrap
./bootstrap-ai.sh
Enter fullscreen mode Exit fullscreen mode

🔍 Step 9 — Verify Everything

Git identity:

git config --global --list
Enter fullscreen mode Exit fullscreen mode

SSH linking:

ls -l ~/.ssh
Enter fullscreen mode Exit fullscreen mode

Node (dev):

node -v
npm -v
Enter fullscreen mode Exit fullscreen mode

AI stack:

source ~/venvs/ai/bin/activate
pip list | grep torch
Enter fullscreen mode Exit fullscreen mode

🎯 Final Thoughts

Splitting my workflow into two WSL distros was one of the best decisions I've made for my development setup. It keeps everything clean, organized, and conflict‑free.

  • My Dev WSL stays fast and focused on coding.
  • My AI WSL stays isolated and optimized for machine learning.

If you've been struggling with dependency conflicts, slow environments, or messy setups, this architecture might be exactly what you need.

Top comments (0)