WSL Subsystem Installation

1. WSL pre-installation setup

1.1 Check if CPU Virtualization is enabled

Open Task Manager, click [Performance], and in the pop-up window, check if virtualization is enabled.

1.2 Enable Virtual Machine and Windows Subsystem

As shown in the image above, Open the Control Panel, go to Programs and Features, click "Turn Windows Features on or off," and check the relevant features in the pop-up window. Restart the computer to apply the changes.

2. WSL Installation of Ubuntu

2.1 WSL installation and version update

In Windows Powershell (run as administrator), enter wsl --update to start installing wsl or a newer version.

2.2 WSL Install Ubuntu Subsystem

In Windows Powershell (run by the administrator), enter the following command to install:

# View available versions online
wsl --list --online

# Install Ubuntu 22.04
wsl --install -d Ubuntu-22.04

Enter your username and password to create an Ubuntu user account.

As shown in the above figure, the Ubuntu 22.04 subsystem has been successfully installed.

2.3 Install Docker In The Ubuntu subsystem.

Enter docker info to check if the subsystem already has a docker service.

If it is already present, installation is not needed. Otherwise, use the following command in Ubuntu to install:

sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install docker.io 

2.4 Install Graphics Driver For Ubuntu Subsystem

View graphics card information

If the results match the image above, no further action is required.

NVIDIA Container Runtime Installation and Usage

With NVIDIA Container Runtime, registers a new runtime during container creation to expose the NVIDIA GPU to applications in the container.

# Add Library

curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
    sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
    sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
    
sudo apt-get update

# Install nvidia-container-runtime

sudo apt-get install nvidia-container-runtime
systemctl restart docker

#Verify if the installation was successful.

sudo docker run --gpus all --rm nvidia/cuda:12.0.1-base-ubuntu22.04 nvidia-smi

Note:The above command should match your Ubuntu version; for details, refer to: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/cuda

At this point, the WSL installation and Ubuntu subsystem setup are complete.

Last updated