- In WSL2 run:
sudo apt update
sudo apt install qemu qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils cpu-checker network-manager
sudo apt install virt-manager
sudo addgroup kvm
sudo adduser `id -un` libvirt
sudo adduser `id -un` kvm
newgrp libvirt
https://medium.com/codemonday/setup-virt-manager-qemu-libvert-and-kvm-on-ubuntu-20-04-fa448bdecde3
- Change the default group of
/dev/kvm:
sudo nano /etc/wsl.conf
In the file /etc/wsl.conf add these lines:
[boot]
command = /bin/bash -c 'chown -v root:kvm /dev/kvm && chmod 660 /dev/kvm'
-
Enable nested virtualization. Create .wslcongfig.
-
Add this section to the
.wslconfigfile
[wsl2]
nestedVirtualization=true
- Restart WSL:
wsl.exe --shutdown
- Got an error:
Setting up udev (252.22-1~deb12u1) ...
addgroup: The group `kvm' already exists and is not a system group. Exiting.
dpkg: error processing package udev (--configure):
installed udev package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mdevctl:
mdevctl depends on udev; however:
Package udev is not configured yet.
- It can be fixed with:
sudo mv /var/lib/dpkg/info/udev.postinst /var/lib/dpkg/info/udev.postinst.backup
- If you get:
/sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link
- Then, in WSL the primary fix seems to be to delete
libcuda.soandlibcuda.so.1fromC:\Windows\System32\lxss\libas anAdministratorin Windows (not fromWSL):
cd C:\Windows\System32\lxss\lib && del libcuda.so && del libcuda.so.1 && mklink libcuda.so libcuda.so.1.1 && mklink libcuda.so.1 libcuda.so.1.1
-
Install Nvidia CUDA WSL drivers
-
If xfce4 is giving error run:
export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
export LIBGL_ALWAYS_INDIRECT=1
Thanks!