Pages

Friday, January 24, 2025

Windows Subsytem - Ubuntu

Install latest NVIDIA Driver for GPU Support. 
Do not install any Linux display driver in WSL.

PS C:\> nvidia-smi

Turn Windows features on or off
Check the boxes for Virtual Machine Platform and Windows Subsystem for Linux
Click OK and restart computer.

Ensure you have the latest WSL kernel.
PS C:\> wsl --update

PS C:\> wsl --version

Display a list of available distributions
PS C:\> wsl --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl.exe --install <Distro>'.

NAME                            FRIENDLY NAME
Ubuntu                          Ubuntu
Debian                          Debian GNU/Linux
kali-linux                      Kali Linux Rolling
Ubuntu-18.04                    Ubuntu 18.04 LTS
Ubuntu-20.04                    Ubuntu 20.04 LTS
Ubuntu-22.04                    Ubuntu 22.04 LTS
Ubuntu-24.04                    Ubuntu 24.04 LTS
OracleLinux_7_9                 Oracle Linux 7.9
OracleLinux_8_7                 Oracle Linux 8.7
OracleLinux_9_1                 Oracle Linux 9.1
openSUSE-Leap-15.6              openSUSE Leap 15.6
SUSE-Linux-Enterprise-15-SP5    SUSE Linux Enterprise 15 SP5
SUSE-Linux-Enterprise-15-SP6    SUSE Linux Enterprise 15 SP6
openSUSE-Tumbleweed             openSUSE Tumbleweed

Increase swap space. Remove .txt extension.
PS C:\> type .wslconfig
[wsl2]
memory=4GB
swap=16GB
networkingMode=mirrored   # Use same Windows IP

Install a Windows Subsystem for Linux distribution.
PS C:\> wsl --install -d Ubuntu
Create a default Unix user account: 
New password:
Retype new password:
passwd: password updated successfully

$ cat /etc/os-release
NAME="Ubuntu"
VERSION_ID="24.04"

Update and Upgrade packages
$ sudo apt update
$ sudo apt list --upgradable
$ sudo apt ugrade

Enable systemd in /etc/wsl.conf
[boot]
systemd=true

$ free -m
               total        used        free      shared  buff/cache   available
Mem:            3920         456        3500           2         156        3464
Swap:          16384           0       16384

Show the status of Windows Subsystem for Linux
PS C:\> wsl --status
Default Distribution: Ubuntu
Default Version: 2

PS C:\> wsl -l -v
  NAME      STATE           VERSION
* Ubuntu    Running         2

Set the distribution as the default
PS C:\> wsl -s <distro>

WSL2 instance IP
C:\> wsl hostname -I

ComfyUI Port Forwarding from Windows host to WSL2 instance.
C:\> netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=<ComfyUI_Port> connectaddress=<WSL2_IP> connectport=<ComfyUI_Port>

Inbound Rule
C:\> netsh advfirewall firewall add rule name="ComfyUI" dir=in protocol=TCP localport=<ComfyUI_Port> action=allow

Terminate the distribution
PS C:\Users\nbitra> wsl -t <distro>

Terminate the distribution and VM
PS C:\> wsl --shutdown -d Ubuntu

Launch the distribution
PS C:\> wsl -d Ubuntu

The VHDX file location
$HOME\AppData\Local\wsl\

Uninstall the distribution and delete the root filesystem
PS C:\> wsl --unregister <distro>
Unregistering...

$ sudo apt install python3-venv

No comments:

Post a Comment