D435 in LXD container
Is it possible to use RealSense D435 camera inside LXD container?
Host - Ubuntu 18.04, LXD 4.0.5. Container OS - Ubuntu 18.04.
librealsense2-dkms and librealsense2-utils are installed both on host and in container. The camera is connected to USB3.0 port via optical USB3.0 extender (may be it's important).
The camera works successfully on host, for example with rs-distance command. And it absolutely doesn't work in container.
Commands on host:
$ lsusb
Bus 002 Device 002: ID 8087:8002 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 009 Device 002: ID 258a:0001
Bus 009 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 010 Device 003: ID 8086:0b07 Intel Corp.
Bus 010 Device 002: ID 2109:8110 VIA Labs, Inc. Hub - it is USB extender
Bus 010 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
...
$ udevadm info --name /dev/bus/usb/010/003
P: /devices/pci0000:00/0000:00:1c.4/0000:06:00.0/usb10/10-2/10-2.1
N: bus/usb/010/003
E: BUSNUM=010
E: DEVNAME=/dev/bus/usb/010/003
E: DEVNUM=003
E: DEVPATH=/devices/pci0000:00/0000:00:1c.4/0000:06:00.0/usb10/10-2/10-2.1
E: DEVTYPE=usb_device
E: DRIVER=usb
E: ID_BUS=usb
E: ID_MODEL=Intel_R__RealSense_TM__Depth_Camera_435
E: ID_MODEL_ENC=Intel\x28R\x29\x20RealSense\x28TM\x29\x20Depth\x20Camera\x20435\x20
E: ID_MODEL_ID=0b07
E: ID_REVISION=50c8
E: ID_SERIAL=Intel_R__RealSense_TM__Depth_Camera_435_Intel_R__RealSense_TM__Depth_Camera_435_923123021109
E: ID_SERIAL_SHORT=923123021109
E: ID_USB_INTERFACES=:0e0100:0e0200:
E: ID_VENDOR=Intel_R__RealSense_TM__Depth_Camera_435
E: ID_VENDOR_ENC=Intel\x28R\x29\x20RealSense\x28TM\x29\x20Depth\x20Camera\x20435\x20
E: ID_VENDOR_FROM_DATABASE=Intel Corp.
E: ID_VENDOR_ID=8086
E: MAJOR=189
E: MINOR=1154
E: PRODUCT=8086/b07/50c8
E: SUBSYSTEM=usb
E: TYPE=239/2/1
E: USEC_INITIALIZED=8502200
I tried to connect the camera to a container with command:
lxc config device add cont cam1 usb vendorid=8086 productid=0b07 mode=0666
and tried as unix-char device with:
lxc config device add cont cam1 unix-char source=/dev/bus/usb/010/003 path=/dev/bus/usb/010/003 mode=0666 major=189 minor=1154
Commands in container:
# lsusb
Bus 002 Device 002: ID 8087:8002 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 009 Device 002: ID 258a:0001
Bus 009 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 010 Device 003: ID 8086:0b07 Intel Corp.
Bus 010 Device 002: ID 2109:8110 VIA Labs, Inc. Hub
Bus 010 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
...
# modinfo uvcvideo | grep "version:"
version: 1.1.2.realsense-1.3.16
# udevadm info --name /dev/bus/usb/010/003
P: /devices/pci0000:00/0000:00:1c.4/0000:06:00.0/usb10/10-2/10-2.1
N: bus/usb/010/003
E: BUSNUM=010
E: DEVNAME=/dev/bus/usb/010/003
E: DEVNUM=003
E: DEVPATH=/devices/pci0000:00/0000:00:1c.4/0000:06:00.0/usb10/10-2/10-2.1
E: DEVTYPE=usb_device
E: DRIVER=usb
E: MAJOR=189
E: MINOR=1154
E: PRODUCT=8086/b07/50c8
E: SUBSYSTEM=usb
E: TYPE=239/2/1
(it looks like not full information in the container about the camera)
# rs-distance
There are 0 connected RealSense devices.
I have tried privileged and not privileged container. Results are the same - camera not found.
-
Hi Yuri Pipchenko I am not aware of previous cases where LXD containers have been used with librealsense and my research of your question did not find any either. Docker containers can be used with librealsense (though I know they are not the same as LXD containers).
My research indicated that virtual machines (VM) can be involved with LXD. Are you using a VM with your LXD setup, please? If so, the librealsense SDK has difficulty interfacing with VMs due to the need to emulate the USB controller. Intel recommend VMware Workstation Player if you do need to use a VM, as described in the opening paragraph of the librealsense Linux installation guide in the link below.
https://github.com/IntelRealSense/librealsense/blob/master/doc/installation.md
-
Hi MartyG Thank you for your reply. LXD and Docker are very similar - both are a containers using linux cgroups, but not fully functional VMs. I'm just more comfortable with LXD, because it allows to develop and debug a project inside. And as I understand it, both should use the same USB pass-through approaches.
-
I do not have any librealsense-related LXD references to check. There was a past Docker case though where a RealSense user got it working by ensuring that the host and container kernel versions matched. If Docker and LXD are similar, the information in the link below may provide some ideas for what to try next.
https://github.com/IntelRealSense/realsense-ros/issues/388#issuecomment-410672421
-
Thank you very much, MartyG. I will try it.
-
It works with docker, because of when docker container is running I can mount whole /dev with --volume=/dev:
docker run -it --rm --net=host --privileged --volume=/dev:/dev ...
But this mount option is impossible with LXD. And it's necessary to forward separately each device that is part of the camera D435. Maybe someone knows what exactly these devices are?
Please sign in to leave a comment.
Comments
7 comments