• DepthAI
  • Running pipeline on Docker container

Hi @Brandon ,

I have been using the depthai sample code to run natively on both AMD64 and ARM64 platforms successfully against an OAK camera. Although if I try to run through the same code samples from a docker container, I consistently get the X_LINK_DEVICE_NOT_FOUND error as seen below.

root@dsodatdev7-desktop:/home/dso/depthai-python/examples/MobileNet# python3 rgb_mobilenet.py
Traceback (most recent call last):
File "rgb_mobilenet.py", line 56, in <module>
with dai.Device(pipeline) as device:
RuntimeError: Failed to find device after booting, error message: X_LINK_DEVICE_NOT_FOUND

I am following the recipe as described previously above in the docker run command. Is there any light you can shed on this error.

Thank you

Joseph E. Martinez

    JosephMtz69

    Thanks. I know there's a solution to this but I can't quite remember it. Asking the team.

    Thanks again,
    Brandon

    Hi JosephMtz69 ,
    Are you maybe using a PoE version of DepthAI device? Since they communicate over the network, --net host param should be provided, so that our API can correctly discover the device

    No, I am using the USB version of the OAK camera which is plugged into my Xavier AGX board via a USB hub ... natively it works ok ... but not when running from a docker container

      @JosephMtz69 I don't have this board on my end, but I do have Jetson Nano, so will try running docker container there and see if I can recreate, will circle back

      I've actually been running into a similar issue. It looks like regardless of what I do, I keep getting the same issue to persist. My goal is to run both the rgb_preview and the deptahi_demo.py examples in the same docker container on my unbuntu desktop.

      I initially tried using the depthai-library image from (https://hub.docker.com/r/luxonis/depthai-library). When using that image, I was able to connect to my OAK-D and ran the rgb_preview.py example. However, when I tried cloning depthai.git and installing the requirements into the container to run depthai_demo.py, I'd get the following error:

      File "depthai_demo.py", line 18, in <module>
      from depthai_helpers.arg_manager import parseArgs
      File "/app/depthai/depthai_helpers/arg_manager.py", line 10, in <module>
      from depthai_sdk.previews import Previews
      File "/app/depthai/depthai_sdk/src/depthai_sdk/init.py", line 4, in <module>
      from .managers import *
      File "/app/depthai/depthai_sdk/src/depthai_sdk/managers/init.py", line 4, in <module>
      from .pipeline_manager import PipelineManager
      File "/app/depthai/depthai_sdk/src/depthai_sdk/managers/pipeline_manager.py", line 7, in <module>
      class PipelineManager:
      File "/app/depthai/depthai_sdk/src/depthai_sdk/managers/pipeline_manager.py", line 32, in PipelineManager
      _depthConfig = dai.StereoDepthConfig()
      AttributeError: module 'depthai' has no attribute 'StereoDepthConfig'

      Assuming some packages may have been missing, I created a dockerfile to install all the dependencies from install_dependencies.sh. However, when I tried to run depth_demo.py in a container, it gave the same issue.

      I then tried using the base image instead in my dockerfile, (https://hub.docker.com/r/luxonis/depthai-base). While I was no longer getting the error from before, I kept getting an error saying

      File "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

      and a similar error when I attempted to run depthai_demo.py. I tried including the following below to my docker file, however that didn't work either.

      RUN wget https://github.com/libusb/libusb/releases/download/v1.0.24/libusb-1.0.24.tar.bz2 && \
      tar xf libusb-1.0.24.tar.bz2 && \
      cd libusb-1.0.24 && \
      ./configure --disable-udev --prefix="$PWD/install_dir" && \
      make -j && \
      make install
      ENV LD_LIBRARY_PATH="$PWD/libusb-1.0.24/install_dir/lib":$LD_LIBRARY_PATH

      Then I tried using a python base image similar to https://github.com/luxonis/depthai-docker/blob/master/Dockerfile-depthai however it was missing all the dependencies. I went back and updated the dockerfile to include the install_dependencies.sh but ran into the same issue again where the device couldn't be found as shown below.

      File "depthai_demo.py", line 575, in run
      self.instance.run_all(self.conf)
      File "depthai_demo.py", line 76, in run_all
      self.setup(conf)
      File "depthai_demo.py", line 153, in setup
      self.device = dai.Device(self.pm.pipeline.getOpenVINOVersion(), self.deviceInfo, usb2Mode=self.conf.args.usbSpeed == "usb2")
      Failed to find device after booting, error message: X_LINK_DEVICE_NOT_FOUND

      All the containers used the same arguments of

      docker run --rm -it\
      --privileged \
      -v /dev/bus/usb:/dev/bus/usb \
      --device-cgroup-rule='c 189:* rmw' \
      -e DISPLAY=$DISPLAY \
      -v /tmp/.X11-unix:/tmp/.X11-unix \
      --entrypoint /bin/bash imageName

      Each dockerfile also included RUN echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666"' | tee /etc/udev/rules.d/80-movidius.rules in case it wasn't set. I'm able to see the usb from within the container and even hear an initial click sometimes but it never connects to it.

      Please advise.

        lead_dev Thanks for the report! I will be working on the Docker image now, and there's some work already done on this branch - https://github.com/luxonis/depthai-python/tree/enable_multiarch_build
        So could you check if running

        git checkout enable_multiarch_build
        docker build -t imageName -f ci/Dockerfile .

        I'll be testing and updating the Dockerfile on this branch too, and eventually merge to master, but it may solve your issue quicker

        lead_dev JosephMtz69 I was just able to build a new docker container and access OAK-D from it, running rgb_preview.py script.

        To use it now, please do the following

        cd depthai-python
        git checkout enable_multiarch_build
        git submodule update --init --recursive
        xhost local:root
        docker build -t depthai -f ci/Dockerfile .
        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 depthai python3 /depthai-python/examples/ColorCamera/rgb_preview.py

        PR with this Dockerfile changes is here - https://github.com/luxonis/depthai-python/pull/270 - and as soon as we manage to make CI work, we'll have these docker images updated on the dockerhub automatically

          Luxonis-Lukasz I normally have a difficult time with the dockerfiles because it always fails on the line

          RUN wget http://docs.luxonis.com/_static/install_dependencies.sh && chmod +x install_dependencies.sh && ./install_dependencies.sh

          and gives the same error as shown in the attached image. Also, I can run rgb_preview.py, however the dockerfile anytime I attempt to run depthai_demo.py using the depthai repo from within the container, it fails to run saying that a device could not be found.

          Yes, I fixed this issue in the mentioned branch. It failed as it wanted to set udev rules where we use libusb without udev. Now, docker container has its own dependencies install script, adjusted to run with root user and without udev

            @Luxonis-Lukasz .... I was able to build and run from your docker file ... are you planning on merging this branch (enable_multiarch_build) that has the fix it it into the main branch?

            Yes, it should be merged soon, working on arm runners to build the image automatically and upload it to dockerhub, so that the image gets updated with every release

            @Luxonis-Lukasz ... thank you and very good .. just keep me posted when that merge happens .... that way I can remove from my local Dockerfile build that part that specifies the branch .. thanks again

              JosephMtz69 Happy to help! Actually, it might be merged even today as we just managed to make the workflows running - https://github.com/luxonis/depthai-python/pull/270
              The images will be deployed in 3 variants:

              • luxonis/depthai-library:armv7-<ref> - for armv7 hosts (linux/arm architecture)
              • luxonis/depthai-library:ubuntu-<ref> - for arm64 hosts (linux/amd64 architecture)
              • luxonis/depthai-library:armv8-<ref> - for armv8 hosts (linux/arm64 architecture)

              <ref> is either a version tag or branch name (main or develop), so there will be a plentiful of images to choose from. We'll also update the docs once this PR is merged

              (as a side note, may be useful in the short term) - for testing, I pushed these images with <ref> being enable_multiarch_build. So if you'd like to use these right now (before the PR is merged) you can use these images (click on image name to see it on DockerHub)

              Although be aware that these might disappear once we do a cleanup on our DockerHub

              Luxonis-Lukasz i'm using the image from the devel branch and was able to run rgb_preview successfully but encountered this issue when trying to run depthai_demo.py. I did already run python3 install_requirements.py and that did not resolve the issue. Please advise

                lead_dev Could you run, inside the container, the following commands to see if it helps?

                $ cd depthai
                $ python3 -m pip uninstall depthai
                $ python3 install_requirements.py
                $ python3 depthai_demo.py