Webcam mode on Windows 11 using WSL2 Ubuntu
If you want to use WSL2 on Windows 11 you will notice, that Ubuntu WSL2 doesn't come with USB-Webcam support in the Kernel. You need to do two things: Compile the Kernel with the right modules integrated and forward your USB Webcam from Windows to Ubuntu with the usbipd app. Here are detailed Steps:
This tutorial will guide you through the process of setting up WSL2 Ubuntu with USB webcam support, rebuilding the kernel, and preparing the environment for the Deep-Live-Cam project.
1. Install WSL2 Ubuntu
Install WSL2 Ubuntu from the Microsoft Store or using PowerShell:
2. Enable USB Support in WSL2
-
Install the USB/IP tool for Windows:
https://learn.microsoft.com/en-us/windows/wsl/connect-usb
-
In Windows PowerShell (as Administrator), connect your webcam to WSL:
You need to redo the above every time you reboot wsl or re-connect your webcam/usb device.
3. Rebuild WSL2 Ubuntu Kernel with USB and Webcam Modules
Follow these steps to rebuild the kernel:
guide
- After rebuilding, restart WSL with the new kernel.
4. Set Up Deep-Live-Cam Project
Within Ubuntu:
- Clone the repository:
- Follow the installation instructions in the repository, including cuda toolkit
5. Verify Kernel Module for Webcam is available
- Check if USB and webcam modules are built into the kernel:
- Verify video devices:
6. Set Up Permissions
- Add user to video group and set permissions:
- Create a udev rule for permanent permissions:
Add this content:
- Reload udev rules:
-
Log out and log back into your WSL session.
-
Start Deep-Live-Cam with python run.py --execution-provider cuda --max-memory 8
where 8 can be changed to the number of GB VRAM of your GPU has, minus 1-2GB. If you have a RTX3080 with 10GB I suggest adding 8GB. Leave some left for Windows.
Troubleshooting CUDA Issues
If you encounter this error:
Follow these steps:
- Install CUDA Toolkit 11.8 (ONNX 1.16.3 requires CUDA 11.x, not 12.x):
https://developer.nvidia.com/cuda-11-8-0-download-archive
select: Linux, x86_64, WSL-Ubuntu, 2.0, deb (local)
- Check CUDA version:
-
If the wrong version is installed, remove it completely:
https://askubuntu.com/questions/530043/removing-nvidia-cuda-toolkit-and-installing-new-one
-
Install CUDA Toolkit 11.8 again https://developer.nvidia.com/cuda-11-8-0-download-archive, select: Linux, x86_64, WSL-Ubuntu, 2.0, deb (local)