question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docker setup improvements: Give access to CSI cam for Jetson nano

See original GitHub issue

Since jetpack 4.3 , nvidia provides an official base image for jetson’s: .

Our current setup to “dockerize” opendatacam on jetson is pretty hacky because we didn’t have access to CUDA stuff inside docker and we needed to:

  • Compile darknet and opencv outside docker and copy the builds inside the image at build time
  • When running the image, we need to manually mount all the CUDA dependency from the base OS and rely on the fact that CUDA was properly installed on the jetsons we were launching OpenDataCam from

This new docker base image provided from nvidia should enable us to

  • have almost the same Dockerfile for Ubuntu CUDA machine / Jetsons by using cuda to compile darknet / compile opencv directly when building the image
  • have access the CSI cam like raspberry pi cam from docker , for platform like jetson nano it was a limitation

I’m working on updating our Docker process and I successfully managed to have opencv compiled inside the docker build, but I’m still struggling with some issues to compile darknet when building the image.

I’ve posted a repro on the nvidia forums: https://devtalk.nvidia.com/default/topic/1072782/jetson-nano/-compiling-darknet-in-l4t-base-r32-3-1-docker-image-get-error-cicc-not-found/

I’ll pick up this this later, and for now stick to our current pipeline to provide some testable build for OpenDataCam v3, as from user point of view, this doesn’t change much.

For reference, here is the current work in progress Dockerfile for jetsons

FROM nvcr.io/nvidia/l4t-base:r32.3.1

RUN  apt-get update -y && apt-get install -y \
            libgstreamer1.0-0 \
            gstreamer1.0-plugins-base \
            gstreamer1.0-plugins-good \
            gstreamer1.0-plugins-bad \
            gstreamer1.0-plugins-ugly \
            gstreamer1.0-libav \
            gstreamer1.0-doc \
            gstreamer1.0-tools \
            libgstreamer1.0-dev \
            libgstreamer-plugins-base1.0-dev
RUN  apt-get update -y && apt-get install -y  pkg-config \
 zlib1g-dev  libwebp-dev \
 libtbb2 libtbb-dev  \
 libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
 cmake
RUN apt-get install -y \
  autoconf \
  autotools-dev \
  build-essential \
  gcc \
  git
RUN apt-get update -y && apt-get install -y ffmpeg
ENV OPENCV_RELEASE_TAG 4.1.1
RUN git clone --depth 1 -b ${OPENCV_RELEASE_TAG}  https://github.com/opencv/opencv.git /var/local/git/opencv
RUN cd /var/local/git/opencv
RUN mkdir -p /var/local/git/opencv/build && \
    cd /var/local/git/opencv/build $$ && \
    cmake -D CMAKE_INSTALL_PREFIX=/usr/local CMAKE_BUILD_TYPE=Release -D WITH_GSTREAMER=ON -D WITH_GSTREAMER_0_10=OFF -D WITH_CUDA=OFF -D WITH_TBB=ON -D WITH_LIBV4L=ON WITH_FFMPEG=ON -DOPENCV_GENERATE_PKGCONFIG=ON ..
RUN  cd /var/local/git/opencv/build && \
      make install

RUN git clone --depth 1 -b uselib https://github.com/tdurand/darknet /var/local/darknet


WORKDIR /var/local/darknet
RUN sed -i -e s/GPU=0/GPU=1/ Makefile;
#RUN sed -i -e s/CUDNN=0/CUDNN=1/ Makefile;
RUN sed -i -e s/OPENCV=0/OPENCV=1/ Makefile;
RUN sed -i -e s/LIBSO=0/LIBSO=1/ Makefile;
# Uncomment line corresponding to ARCH , 42 nano, 45 tx2, 33 xavier
RUN sed -i '42 s/^#//g' Makefile;

# ERROR here,  darknet doesn’t compile
RUN make 

cc @b-g

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:66 (63 by maintainers)

github_iconTop GitHub Comments

3reactions
tdurandcommented, Apr 29, 2020

Updates from the marvelous world 🌈️🌈️🌈️🌈️🌈️🌈️ of Jetson + Jetpack + Docker + Nvidia 😋️😋️

I tried to update our Docker image & process to use the latest base image nvcr.io/nvidia/l4t-base:r32.4.2

It works (we still need to compile darknet outside and copy it to the Dockerfile at build time), and simplify greatly all the hacks we were doing at runtime to mount CUDA etc etc…

But I still can’t access to the raspberry pi cam on jetson nano, I’ve posted an issue on the nvidia forums https://forums.developer.nvidia.com/t/access-to-raspberry-cam-v2-fails-from-docker-container-using-l4t-32-4-2-using-nvarguscamerasrc/121512

Here is the work in progress Dockerfile

FROM nvcr.io/nvidia/l4t-base:r32.4.2

RUN  apt-get update -y && apt-get install -y \
            libgstreamer1.0-0 \
            gstreamer1.0-plugins-base \
            gstreamer1.0-plugins-good \
            gstreamer1.0-plugins-bad \
            gstreamer1.0-plugins-ugly \
            gstreamer1.0-libav \
            gstreamer1.0-doc \
            gstreamer1.0-tools \
            libgstreamer1.0-dev \
            libgstreamer-plugins-base1.0-dev
RUN  apt-get update -y && apt-get install -y  pkg-config \
 zlib1g-dev  libwebp-dev \
 libtbb2 libtbb-dev  \
 libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
 cmake
RUN apt-get install -y \
  autoconf \
  autotools-dev \
  build-essential \
  gcc \
  git
RUN apt-get update -y && apt-get install -y ffmpeg
ENV OPENCV_RELEASE_TAG 4.1.1
RUN git clone --depth 1 -b ${OPENCV_RELEASE_TAG}  https://github.com/opencv/opencv.git /var/local/git/opencv
RUN cd /var/local/git/opencv
RUN mkdir -p /var/local/git/opencv/build && \
    cd /var/local/git/opencv/build $$ && \
    cmake -D CMAKE_INSTALL_PREFIX=/usr/local CMAKE_BUILD_TYPE=Release -D WITH_GSTREAMER=ON -D WITH_GSTREAMER_0_10=OFF -D WITH_CUDA=OFF -D WITH_TBB=ON -D WITH_LIBV4L=ON WITH_FFMPEG=ON -DOPENCV_GENERATE_PKGCONFIG=ON ..
RUN  cd /var/local/git/opencv/build && \
      make install

# Install pre-compiled darknet on docker
COPY darknet/ /var/local/darknet/

# Install node.js
RUN apt-get install -y libcurl4 curl
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install -y nodejs

# Technique to rebuild the docker file from here : https://stackoverflow.com/a/49831094/1228937
# Build using date > marker && docker build .
# date > marker && sudo docker build -t opendatacam .
#COPY marker /dev/null

RUN git clone --depth 1 -b development https://github.com/opendatacam/opendatacam /var/local/opendatacam

WORKDIR /var/local/opendatacam

RUN npm install
RUN npm run build

# Install Mongodb
# NB: for some reason this needs to be at the end otherwise mongod command isn't installed
# https://github.com/dockerfile/mongodb#run-mongod-w-persistentshared-directory
ENV DEBIAN_FRONTEND noninteractive
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 && \
    echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list
RUN apt-get update && apt-get install -y openssl libcurl3 mongodb-org
VOLUME ["/data/db"]

EXPOSE 8080 8070 8090 27017

# # Because we want to run mongodb and the node.js app
# # See https://docs.docker.com/config/containers/multi-service_container/
COPY docker-start-mongo-and-opendatacam.sh docker-start-mongo-and-opendatacam.sh
RUN chmod 777 docker-start-mongo-and-opendatacam.sh
CMD ./docker-start-mongo-and-opendatacam.sh
2reactions
tdurandcommented, Jun 5, 2020

Thanks, will do! I’m aiming to release a new beta with this setup in the coming days

Read more comments on GitHub >

github_iconTop Results From Across the Web

Access to Raspberry Cam ( nvargus-daemon ) from docker ...
I'm working on running YOLO darknet with raspberry cam module on the jetson nano and it works great. (with OpenCV with gstreamer support)....
Read more >
Nvidia Jetson (Nano) + CSI camera from container - balenaOS
Hi, we're intending to run BalenaOS on a Jetson Nano in conjunction with a CSI camera, a need many embedded vision developers will...
Read more >
Get Started with Jetson Nano 4GB & CSI Camera - OKdo
Base setup and first boot · Unbox the Jetson Nano Developer Kit. · Using the jumper, connect the J48 power select header pins...
Read more >
Edge inference with RedisAI on Jetson Nano - Arm Community
The following Dockerfile builds a Redis Server docker image with Redis Gears and RedisAI modules included. You can change the versions and ...
Read more >
Nvarguscamerasrc source code - Libreria Lithos
Linux: Create a new directory for the AOO developer install. Buy . By downloading and using ... 4. io 2020-02-16 · CSI-Camera Interface...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found