Zed 2i in WSL ubuntu20.04

I want to use ZED 2i in wsl2.0 ubuntu20.04 system, but after install the sdk in wsl and connect the camera, the world viewer app can not work.
could you plz help me.

Hi @zed_for_sam
Welcome to the Stereolabs community.

Did you install CUDA on WSL? (see here)
Can you please run ZED_Diagnostic and send me the report file that it generates?

I read the report file, it says the camera is not connected to computer.
I follow the tips provide by microsoft that how can connect the usb device from window to WSL ubuntu(the link is 连接 USB 设备 | Microsoft Learn), but it seems not work.
This is the report file:

{
    "AI Models": {
        "info": [
            "MULTI CLASS DETECTION is not optimized",
            "MULTI CLASS MEDIUM DETECTION is not optimized",
            "MULTI CLASS ACCURATE DETECTION is not optimized",
            "HUMAN BODY FAST DETECTION is not optimized",
            "HUMAN BODY MEDIUM DETECTION is not optimized",
            "HUMAN BODY ACCURATE DETECTION is not optimized",
            "HUMAN BODY 38 FAST DETECTION is not optimized",
            "HUMAN BODY 38 MEDIUM DETECTION is not optimized",
            "HUMAN BODY 38 ACCURATE DETECTION is not optimized",
            "HUMAN BODY 70 FAST DETECTION is not optimized",
            "HUMAN BODY 70 MEDIUM DETECTION is not optimized",
            "HUMAN BODY 70 ACCURATE DETECTION is not optimized",
            "PERSON HEAD DETECTION is not optimized",
            "PERSON HEAD ACCURATE DETECTION is not optimized",
            "REID ASSOCIATION is not optimized",
            "NEURAL DEPTH is not optimized"
        ]
    },
    "Camera Test": {
        "InternalDevicesCount": 1,
        "ZEDCount": 0,
        "error": [
            "<b>Camera not detected</b> <br/> Make sure the camera is plugged in or try another USB 3.0 port."
        ]
    },
    "Devices": {
        "CorruptedFirmware": false,
        "USBList": [
            {
                "USBMode": 3,
                "USB_path": "/1",
                "bDescriptorType": 1,
                "bDeviceProtocol": 1,
                "bLength": 18,
                "bMaxPacketSize0": 9,
                "bNumConfigurations": 1,
                "bcdDevice": "1.0",
                "bcdUSB": "3.0",
                "bcdUSBClass": 239,
                "bcdUSBSubClass": 2,
                "busNumber": 2,
                "device": "ZED2i",
                "iManufacturer": 1,
                "iProduct": 2,
                "iSerial": 4,
                "idProduct": "0xf880",
                "idVendor": "0x2b03"
            }
        ],
        "USBMode": 3,
        "ZED Camera Module Detected": 63616,
        "ZEDDetected": true,
        "notTested": [
            "Please connect a camera to test the USB connection."
        ]
    },
    "Graphics Card": {
        "deviceCount": 1,
        "deviceDriverVersion": 11080,
        "devices": [
            {
                "arch": "Ampere",
                "computeCapability": "8.6",
                "cores": 6144,
                "name": "NVIDIA GeForce RTX 3080 Laptop GPU",
                "totalMemoryBytes": "17179344896",
                "totalMemoryMB": 16383.5
            }
        ],
        "initResult": 0,
        "valid": [
            "<b>Graphics card: </b> NVIDIA GeForce RTX 3080 Laptop GPU"
        ]
    },
    "Processor": {
        "OS": "Ubuntu 20.04.6 LTS ",
        "avxSupported": true,
        "coreCount": "16",
        "cpu": " AMD Ryzen 9 5900HX with Radeon Graphics",
        "datetime": "2023-06-20 03:26:38 PM",
        "hyperThreading": "1",
        "motherboard": ", ",
        "ramCapacity": "16.695714",
        "ramUsage": "",
        "ramUsed": "3.714306",
        "threadCount": "32",
        "valid": [
            "<b>Processor: </b>  AMD Ryzen 9 5900HX with Radeon Graphics"
        ]
    },
    "ZED SDK": {
        "CUDA Toolkit version": "V11.8.89 -->located in /usr/local/cuda-11.8/bin/nvcc",
        "CUDA loading": false,
        "GPU Driver Version": "Driver Version                            : 522.25",
        "GPU Performance": "    Performance State                     : P8",
        "ZED SDK Version (Diag)": "4.0.3",
        "ZED SDK Version (RT)": "4.0.3",
        "ai": {
            "checkAI": true,
            "cudaVersion": 11080,
            "cudnnCudartVersion": 11080,
            "cudnnVersion": 8600,
            "cudnnVersionExpected": 8600,
            "tensorVersion": 8501
        },
        "binFiles": [
            "libsl_ai.so",
            "libsl_zed.so",
            "libsl_zed_static.a"
        ],
        "resourcesFiles": [
        ],
        "resourcesFilesExpected": [
            "objects_performance_3.0"
        ],
        "valid": [
            "<b>ZED SDK version:</b> 4.0.3",
            "<b>CUDA version:</b> V11.8.89"
        ]
    }
}

It seems that it can detect the UVC module (video) correctly, but not the HID module (sensors).
This can be a permissions problem normally handles by udev on Ubuntu.
Can you try to run the Diagnostic with sudo too see if it solves?

Thank you Myzhar, I run the Diagnostic with sudo, but the problem seems still there.

Can you copy and paste the output of the commands:
$ lsusb -d 2b03:
$ lsusb -d 2b03: -t
$ lsusb -d 2b03: -t -v

Thank you

hi, the output of the commands is :

sam@DESKTOP-OT529I6:~$ lsusb -d 2b03:
Bus 002 Device 005: ID 2b03:f880 Technologies, Inc. ZED 2i
sam@DESKTOP-OT529I6:~$ lsusb -d 2b03: -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=vhci_hcd/8p, 5000M
    |__ Port 1: Dev 5, If 0, Class=Video, Driver=, 5000M
    |__ Port 1: Dev 5, If 1, Class=Video, Driver=, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=vhci_hcd/8p, 480M
sam@DESKTOP-OT529I6:~$ lsusb -d 2b03: -t -v
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=vhci_hcd/8p, 5000M
    ID 1d6b:0003 Linux Foundation 3.0 root hub
    |__ Port 1: Dev 5, If 0, Class=Video, Driver=, 5000M
        ID 2b03:f880  
    |__ Port 1: Dev 5, If 1, Class=Video, Driver=, 5000M
        ID 2b03:f880  
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=vhci_hcd/8p, 480M
    ID 1d6b:0002 Linux Foundation 2.0 root hub

Good, this confirms that the HID module is not initialized.
You should get something like this:

$ lsusb -d 2b03:
Bus 002 Device 004: ID 2b03:f880 STEREOLABS ZED 2i
Bus 001 Device 013: ID 2b03:f881 STEREOLABS ZED-2i HID INTERFACE

Can you please confirm that the camera is correctly working by using it with Windows (no WSL) or Ubuntu?
If it works correctly than you must understand why the HID module (that is over USB2) is not correctly enumerated under WSL.

the camera works very well in windows, thank you for your help, I will try to check the reason.

That’s a good starting point. Please keep this thread updated so other WSL users can contribute.

Hi there, its been a while, but I have the same issue,
@zed_for_sam did you managed this issue, if so, how exactly?

I added it in Power shell

and this I got on ubuntu20.04

But, no camera conected in any ZED app, here is diagnostic log file
ZED_Diagnostic_Results.json (5.4 KB)
Here is log from nvidia-smi from WSL ubuntu 20.04

@Myzhar would you please look at it, might be you have a fix solution

Can you check the udev configuration?
Have you tried to run the apps with “sudo”?
If that works it means that there is a permission problem

I can’t find it in /dev,
At least I am not sure which from the list was assigned to the zed usb camera.
How do I know what is the path for the device so I can check with udevadm?

The ZED cameras create two devices:

  • UVC → Camera frame streaming over USB3
  • HID → Sensors data streaming over USB2

If the udev permissions are not correctly set the access to HID data is blocked.
That’s why the ZED SDK normally installs the file /etc/udev/rules.d/99-slabs.rules to get the right permissions (and other features).
You should understand how udev works in WSL and how to get the correct access permissions.

Has anyone reported being able to get the zed cameras to work in wsl? cameras in wsl do seem problematic.

bb

So, I am not having any luck using a zed in wsl. In my case I am using the zed docker image stereolabs/zed:4.0-devel-cuda12.1-ubuntu20.04, and have the same issue of not seeing the HID, if I follow the comments above.

But, in my case, usbipd wsl attach is failing to attach the HID device (so not surprising that it doesn’t show up in wsl either.)

Any help would be appreciated since the alternative is dual boot.

usbipd wsl list
1-5 2b03:f681 USB Input Device Not attached
1-9 0db0:62a4 Realtek USB Audio, USB Input Device Not attached
1-13 1462:7e03 USB Input Device Not attached
1-14 8087:0033 Intel(R) Wireless Bluetooth(R) Not attached
1-21 2b03:f682 ZED-M Not attached
3-4 046d:c534 USB Input Device Not attached

PS C:\Windows\System32> usbipd wsl attach --busid 1-5
usbipd: info: Using default WSL distribution ‘Ubuntu-22.04’; specify the ‘–distribution’ option to select a different one.
usbip: error: Attach Request for 1-5 failed - Device busy (exported)

usbipd: error: Failed to attach device with busid ‘1-5’.

Nosing around on the web it seems that something on the windows side is “using” the device but no clue which one, and I don’t have zed installed on the windows side.

Another issue as part of getting the zed to work on WSL. Because of warnings about updating CUDA on wsl, unless you are using a special version for wsl, I downloaded CUDA 12. 2 for wsl from nvidia. The zed installer finds it, and continues with the install without installing 12.1. BUT, when I bring up the ZED_Diagnostic, it complains about CUDA 12.1 not being present.

It looks like part of the problem is that the WSL2 kernels don’t have usb camera support compiled in – which means that /dev/video* isn’t available. This video shows pretty good instructions, but I haven’t tried it yet: https://www.youtube.com/watch?v=t_YnACEPmrM

So I did build the WSL2 kernel with usb camera support (following the instructions above), and now after attaching the two usb devices using usbipd I see /dev/video0 and video1 and can get guvcview to work… but not ZED_Sensors or ZED_Depth_Viewer (though in the gui they both seem to detect the ZED camera’s serial number). For example:

$ lsusb
Bus 002 Device 004: ID 2b03:f880 STEREOLABS ZED 2i
Bus 001 Device 004: ID 2b03:f881 STEREOLABS ZED-2i HID INTERFACE

$ ls /dev/video*
/dev/video0  /dev/video1

$ ZED_Depth_Viewer
[ZED Depth Viewer] Failed to create directory to save images: /home/than/Documents/ZED
in bool ImageHandler::initialize(sl::Mat&) : Err [999]: unknown error.
in bool ImageHandler::initialize(sl::Mat&) : Err [400]: invalid resource handle.
in bool ImageHandler::initialize(sl::Mat&) : Err [400]: invalid resource handle.
in bool ImageHandler::initialize(sl::Mat&) : Err [400]: invalid resource handle.
in bool ImageHandler::initialize(sl::Mat&) : Err [999]: unknown error.
in bool ImageHandler::initialize(sl::Mat&) : Err [400]: invalid resource handle.
in bool ImageHandler::initialize(sl::Mat&) : Err [400]: invalid resource handle.
in bool ImageHandler::initialize(sl::Mat&) : Err [400]: invalid resource handle.

$ ZED_Sensor_Viewer
can't claim interface 0: -6
can't claim interface 0: -6
can't claim interface 0: -6