• DepthAI
  • Running pipeline on 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

              lead_dev could you run the demo with --skipVersionCheck flag? I'll prepare a new image that will contain the demo, released from the depthai repository automatically, so running the demo from container will be easier

                Luxonis-Lukasz running into a similar issue from earlier where it runs rgb_preview.py from the depthai-python directory but can't seem to find the device when running depthai_demo.py from the depthai directory. Had issues with qt as well but just downgraded to using openCV