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.

Was able to make it work 🎉 (on tx2), cc @b-g , but it has been a painful journey 🤒, good news is that we can run YOLO inside a Docker without any perf hits, runs 9-10 fps same as outside docker… So we will be able to finally provide an easy install way for opendatacam which should be just consist of:

  • Flashing Jetson
  • Install docker & run docker image (giving we succeed to make the wifi hotspot config from command line also)

Docker on Jetson TX2 specificities:

Since Jetpack 3.2 (we are at Jetpack 3.3), docker can run out of the box… which is good news because before you had to recompile the kernel and it was much more painful…

The challenge is that out of the box docker doesn’t have access to the GPU, so it’s useless to run darknet in it… Nvidia released on an official nvidia-docker base image setup all the nvidia GPU software (CUDA, CUDNN) for us, but no support for Jetson now… (it might come in the future: https://github.com/NVIDIA/nvidia-docker/issues/214 )

The good news is that in the meantime there is a workaround to give docker access to the GPU and the jetpack installed CUDA, CUDNNN software , which is documented here: https://github.com/Technica-Corporation/Tegra-Docker#giving-docker-access-to-gpu

We are using this method, the downside are that it seems you can’t do any compilation work that need the GPU (or CUDA stuff) when building the Docker image, you need to include pre-compiled binaries: Some learning along the way

This means you need to pre-compile darknet with the jetson architecture config (different for Xavier and TX2, see: https://github.com/AlexeyAB/darknet/blob/master/Makefile#L10 ) and an opencv version that need to be the same as the one you will be running in your Docker.

You see me coming, I had a hard time figuring out that the opencv version built-in with the Jetpack 3.3 was not the same as the one I was trying to install in the Docker container: https://github.com/jcjimenez/darknet-docker/issues/1#issuecomment-457186788 . (And then a hard time figuring out how to compile your own opencv, install it on Jetpack … opencv takes something like 1 hour to compile on jetson tx2 ⏰💤)

How to build a jetson GPU “darknet” Docker image:

_This repo: https://github.com/jcjimenez/darknet-docker/tree/master/jetson-tx2 helped making progress… It is more advanced than https://github.com/Technica-Corporation/Tegra-Docker_

🚨 this is still WIP, will improve change / things 🚨

  1. Compile opencv on jetson using this script: https://github.com/jcjimenez/darknet-docker/blob/master/jetson-tx2/build-opencv.sh . This take around 1h on the jetson tx2.

  2. Remove default jetpack pre-installed opencv ( source ):

sudo rm -f /usr/lib/libopencv*
sudo rm -rf /usr/include/opencv
  1. Install opencv 3.4.1 by extracting the tar file produced in 1. at root level /

sudo tar -xvzf opencv-3.4.1.tgz

  1. Compile darknet with make

  2. Copy paste darknet folder and opencv compiled tar file in some empty folder we will use for image creation

  3. Create a Dockerimage file and copy paste this:

FROM arm64v8/ubuntu:16.04

RUN apt-get update && apt-get install -y apt-utils bzip2 curl wget git sudo unp cmake && apt-get clean && rm -rf /var/cache/apt
RUN apt-get -y autoremove && apt-get -y autoclean
RUN rm -rf /var/cache/apt

# Opencv dep
RUN apt-get update
RUN apt-get install -y \
    libglew-dev \
    libtiff5-dev \
    zlib1g-dev \
    libjpeg-dev \
    libpng12-dev \
    libjasper-dev \
    libavcodec-dev \
    libavformat-dev \
    libavutil-dev \
    libpostproc-dev \
    libswscale-dev \
    libeigen3-dev \
    libtbb-dev \
    libgtk-3-dev \
    libgstreamer1.0-0 \
    libwayland-client0 \
    libwayland-egl1-mesa \
    libwayland-cursor0 \
    cmake \
    pkg-config

RUN apt-get install -y python-dev python-numpy python-py python-pytest -y
RUN apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
RUN apt-get install -y ffmpeg

COPY darknet/ darknet/

# install opencv
ADD opencv-3.4.1.tgz /

WORKDIR /darknet
  1. Run docker build command : sudo docker build -t dockerimagename .

This should build the image successfully

Extra info:

How to run the docker image

  1. Need to copy this script: https://github.com/jcjimenez/darknet-docker/blob/master/jetson-tx2/darknet-docker

  2. Run it: sudo ./darknet-docker run --rm -it dockerimagename (run and enter the docker instance to try things)

  3. Try to run darknet, for example: ./darknet detector demo cfg/voc.data cfg/yolo-voc.cfg yolo-voc.weights -c 0 -ext_output -dont_show -json_port 8070 -mjpeg_port 8090

Alternative idea

Also might be even simpler than docker to install for end user, provide a full Jetson image with everything installed: https://elinux.org/Jetson/TX2_Cloning … But people would need to erase everything on there jetson

TODO List

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
tdurandcommented, May 24, 2019

2:30 pm for you would work ? I think it can be pretty quick @florianporada

1reaction
vielmetticommented, May 5, 2019

Of interest to you, @DieterReuter

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker: Accelerated, Containerized Application Development
Docker is a platform designed to help developers build, share, and run modern applications. We handle the tedious setup, so you can focus...
Read more >
Docker (software) - Wikipedia
Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers.
Read more >
Docker - Visual Studio Marketplace
The Docker extension makes it easy to build, manage, and deploy containerized applications from Visual Studio Code.
Read more >
What is Docker? - IBM
Docker is an open source platform that enables developers to build, deploy, run, update and manage containers—standardized, executable components that ...
Read more >
Moby Project - GitHub
Moby is an open-source project created by Docker to enable and accelerate software containerization. It provides a "Lego set" of toolkit components, ...
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