• DepthAI-v2
  • Raspberry PI 4 + OAK-D + BalenaOS + docker container

Hi @Luxonis-Lukasz!

sure will check, I'm desperate to get it up and running, so I'm eager to test new releases, if you need more information that I can gather, just let me know.

br, Krzysiek

    OsinPL feel free to join our discord https://discord.gg/4hGT3AFPMZ (and specifically #docker channel) - we'll be able to have more real-time conversation there, together with other community members. I have docker tweaks in my TODO list, so will be sharing any updates there as well

    still same problem:

    my current Dockerfile:

    FROM luxonis/depthai-library:v2.14.0.0
    ENV DEBIAN_FRONTEND=noninteractive
    
    RUN apt update && apt install -y udev ffmpeg libsm6 libxext6 libgl1-mesa-glx
    RUN echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="03e7", MODE="0666"' | tee /etc/udev/rules.d/80-movidius.rules
    
    WORKDIR /depthai-python/examples/
    RUN python3 install_requirements.py
    
    CMD python3 ObjectTracker/object_tracker.py

    and result:

    [Logs]    [2/21/2022, 1:24:46 PM] [myoakd] Traceback (most recent call last):
    [Logs]    [2/21/2022, 1:24:46 PM] [myoakd]   File "/depthai-python/examples/ObjectTracker/object_tracker.py", line 68, in <module>
    [Logs]    [2/21/2022, 1:24:46 PM] [myoakd]     with dai.Device(pipeline) as device:
    [Logs]    [2/21/2022, 1:24:46 PM] [myoakd] RuntimeError: Failed to find device after booting, error message: X_LINK_DEVICE_NOT_FOUND

    @OsinPL setting udevrules and installing udev is not recommended - as this may cause the discovery issue to fail.

    Could you try without it and also paste the command you're running the Docker with?

      Luxonis-Lukasz I can see my device when perform lsusb:

      [Logs] [2/21/2022, 4:16:35 PM] [myoakd] Bus 001 Device 127: ID 03e7:2485 Movidius Ltd. Movidius MyriadX

      after removing lines you suggested:

      FROM luxonis/depthai-library:v2.14.0.0
      ENV DEBIAN_FRONTEND=noninteractive
      
      RUN apt update && apt install -y ffmpeg libsm6 libxext6 libgl1-mesa-glx
      
      WORKDIR /depthai-python/examples/
      RUN python3 install_requirements.py
      
      COPY oakd-test.py .
      
      CMD python3 oakd-test.py

      so the effect is simply the same 🙁

      [Logs]    [2/21/2022, 4:18:50 PM] [myoakd] Traceback (most recent call last):
      [Logs]    [2/21/2022, 4:18:50 PM] [myoakd]   File "/depthai-python/examples/oakd-test.py", line 70, in <module>
      [Logs]    [2/21/2022, 4:18:50 PM] [myoakd]     with dai.Device(pipeline) as device:
      [Logs]    [2/21/2022, 4:18:50 PM] [myoakd] RuntimeError: Failed to find device after booting, error message: X_LINK_DEVICE_NOT_FOUND

      here you have docker-compose.yaml body:

      version: "2.0"
      services:
        myoakd:
          build:
            context: .
            dockerfile: Dockerfile-luxonis
          privileged: true
          network_mode: host
          environment:
            - DISPLAY=$DISPLAY
          devices:
            - "/dev/bus/usb:/dev/bus/usb"
            - "/tmp/.X11-unix:/tmp/.X11-unix"
          labels:
              io.balena.features.dbus: '1'
              io.balena.features.balena-socket: '1'
              io.balena.features.kernel-modules: '1'

        OsinPL could you try running the following command? I don't think you need to install any requirements or libraries, the following should work

        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/rgb_preview.py

          Luxonis-Lukasz the problem is that balena is limited to use their cli tool, that is based on Dockerfile and docker-compose 2.1, so one difference I've noticed is that I can't add device-cgroup-rule='c 189:* rmw' 🙁

          Luxonis-Lukasz I did test with rpi os without balena and it looks like it works, I have headless version so can't see camera view but I can see this info:

          Connected cameras:  [<CameraBoardSocket.RGB: 0>, <CameraBoardSocket.LEFT: 1>, <CameraBoardSocket.RIGHT: 2>]
          Usb speed:  SUPER

          one change the test py file location is /depthai-python/examples/ColorCamera/rgb_preview.py
          so issue is about accessing camera device from docker container hosted on BalenaOS.

          I will try to ping them and get some info.

          thx!

            8 months later

            For the next person who finds this:

            Ok, got it working balena has actually managed to make Udev work well out of the box with their base images. so for perpetuity here is my docker-compose.yaml & Dockerfile:
            Dockerfile.template:

            FROM balenalib/%%BALENA_ARCH%%-debian-python:3.9-bullseye
            ENV UDEV=1
            ENV DEBIAN_FRONTEND=noninteractive
            RUN apt-get update && apt-get install -y wget python3-dev 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 libopencv-dev
            RUN git clone --recurse-submodules https://github.com/luxonis/depthai-python.git
            
            WORKDIR depthai-python
            
            RUN ./ci/docker_dependencies.sh
            RUN pip install -U pip && pip install --extra-index-url https://www.piwheels.org/simple/ --prefer-binary opencv-python
            
            # Install C++ library
            RUN cmake -S /depthai-python/depthai-core -B /build -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -D CMAKE_INSTALL_PREFIX=/usr/local
            RUN cmake --build /build --parallel 4 --config Relase --target install
            
            # Install Python library
            RUN cd /depthai-python && python3 -m pip install .

            docker-compose.yaml:

            version: '2.4'
            
            services:
              spatial-tracker:
                build:
                  context: .
                  dockerfile: Dockerfile.template
                restart: always
                privileged: true
                network_mode: host
                environment:
                  - DISPLAY=$DISPLAY
                devices:
                  - "/dev/bus/usb:/dev/bus/usb"
                  - "/tmp/.X11-unix:/tmp/.X11-unix"
                device_cgroup_rules:
                  - "c 189:* rmw"
                tty: true
                labels:
                  io.balena.features.dbus: '1'
                  io.balena.features.balena-socket: '1'
                  io.balena.features.kernel-modules: '1'
                  io.balena.features.sysfs: '1'