• Community
  • Oak-D-Lite not working with official docker container

Tried the following instructions with Oak-D-Lite and it doesn't work

docker pull luxonis/depthai-library
sudo docker run --rm \
    --privileged \
    -v /dev/bus/usb:/dev/bus/usb \
    --device-cgroup-rule='c 189:* rmw' \
    -e DISPLAY=$DISPLAY \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    luxonis/depthai-library:latest \
    python3 /depthai-python/examples/01_rgb_preview.py

However, if I install and run everything on host machine 9Ubunut 20.04), it works

sudo curl -fL https://docs.luxonis.com/install_dependencies.sh | bash
git clone https://github.com/luxonis/depthai.git
cd depthai
python3 install_requirements.py
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666"' | sudo tee /etc/udev/rules.d/80-movidius.rules
sudo udevadm control --reload-rules && sudo udevadm trigger
python3 depthai_demo.py

Any pointers on a working container and/or docker command that works for the sensor?

Thanks,
Dennis

    Hi wllui,
    Could you try luxonis/depthai-library:v2.14.0.0 image? (dockerhub link here)
    It's a multi-arch image and should work better. We're also working on making the latest point to latest stable release of our image (not to cause further confusion)

    Thanks. Just tested it and it works

    docker pull luxonis/depthai-library:v2.14.0.0
    docker run --rm \
        --privileged \
        -v /dev/bus/usb:/dev/bus/usb \
        --device-cgroup-rule='c 189:* rmw' \
        -e DISPLAY=$DISPLAY \
        -v /tmp/.X11-unix:/tmp/.X11-unix \
        luxonis/depthai-library:v2.14.0.0 \
        python3 /depthai-python/examples/ColorCamera/rgb_preview.py

    Would you be able to share the Dockerfile for this image? Would be immensely helpful for me to use as a reference for building my own image that uses nvidia/cudagl:11.1.1-devel-ubuntu20.04 as the base

      wllui Dockerfile is available here, our image uses 20.04 (bullseye) as well so the instructions should work as well

      Thanks for the pointer.

      Confirming that I can build image from Dockerfile as-is (from python:3.9-bullseye) or from ubuntu:20.04

      However, if I were to use nvidia/cudagl:11.1.1-devel-ubuntu20.04 or nvidia/cudagl:11.4.2-devel-ubuntu20.04 as the base image and run it with

      sudo docker run --rm \
          --runtime=nvidia -ti \
          --privileged \
          -v /dev/bus/usb:/dev/bus/usb \
          --device-cgroup-rule='c 189:* rmw' \
          -e DISPLAY=$DISPLAY \
          -v /tmp/.X11-unix:/tmp/.X11-unix \
          depthai-python-cuda \
          python3 /depthai-python/examples/ColorCamera/rgb_preview.py

      I will get the following error

      Traceback (most recent call last):
        File "/depthai-python/examples/ColorCamera/rgb_preview.py", line 24, in <module>
          with dai.Device(pipeline) as device:
      RuntimeError: Failed to find device after booting, error message: X_LINK_DEVICE_NOT_FOUND

      Wonder if you have any pointers why this is the case? Thanks in advance.

      One more data point. I tested with nvidia/cuda:11.6.0-devel-ubuntu20.04and it actually works when I run it with

      sudo docker run --rm \
          --runtime=nvidia -ti\
          --privileged \
          -v /dev/bus/usb:/dev/bus/usb \
          --device-cgroup-rule='c 189:* rmw' \
          -e DISPLAY=$DISPLAY \
          -v /tmp/.X11-unix:/tmp/.X11-unix \
          depthai-python-cuda \
          python3 /depthai-python/examples/ColorCamera/rgb_preview.py

      However, not quite getting why the additional support of OpenGL through libglvnd is causing issues with depthai SDK in nvidia/cudagl:11.4.2-devel-ubuntu20.04 or nvidia/cudagl:11.1.1-devel-ubuntu20.04.

        wllui thanks for testing! Maybe nvidia/cudagl has some custom libusb configuration? As it's the only requirement we have, not to use udev when accessing USB devices. And I'm glad it worked with the other image!

          sandeep0101 yes, although I'd recommend local install - there is a custom configuration needed for VM to correctly recognize the USB devices IIRC

            Luxonis-Lukasz Thanks - will do local - having screwed my local environment previously many time, I was hoping Docker will save the time for me 🙂
            PY-Virtual Environment, hopefully will save the day.

              sandeep0101 I work on Mac and use built-in venv and it works great, I'm also on M1 so I have to remember about a few additional steps when working with it

              Luxonis-Lukasz , you are right. It was due to the existing libusb installed in those images. With minor modifications, I am now able to use these base images without issues. Sharing the Docker file and command here

              FROM nvidia/cudagl:11.1.1-devel-ubuntu20.04
              
              ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES},display
              
              ARG DEBIAN_FRONTEND=noninteractive
              ENV TZ=America/Los_Angeles
              
              RUN apt-get update && apt-get install -y wget build-essential cmake pkg-config libjpeg-dev libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libgtk2.0-dev libgtk-3-dev libatlas-base-dev gfortran git python3-pip usbutils
              
              ADD ci/docker_dependencies.sh .
              RUN ./docker_dependencies.sh
              RUN apt-get remove -y libusb-1.0-0
              RUN wget https://github.com/libusb/libusb/releases/download/v1.0.24/libusb-1.0.24.tar.bz2
              RUN tar xf libusb-1.0.24.tar.bz2
              RUN cd libusb-1.0.24 && \
                  ./configure --disable-udev && \
                  make -j && make install
              
              RUN pip install -U pip && pip install --extra-index-url https://www.piwheels.org/simple/ --prefer-binary opencv-python
              
              COPY . /depthai-python
              RUN cd /depthai-python && python3 -m pip install .
              sudo docker run --rm \
                  --runtime=nvidia -ti\
                  --privileged \
                  -v /dev/bus/usb:/dev/bus/usb \
                  --device-cgroup-rule='c 189:* rmw' \
                  -e DISPLAY=$DISPLAY \
                  -v /tmp/.X11-unix:/tmp/.X11-unix \
                  depthai-python-cudagl \
                  python3 /depthai-python/examples/ColorCamera/rgb_preview.py