Skip to content

Commit

Permalink
feat: add jetson nano docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
sileht committed Mar 15, 2021
1 parent db17a41 commit 756845b
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ci/Jenkinsfile.docker
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ pipeline {
sh 'ci/build-docker-images.sh gpu_tensorrt'
}
}}
stage('Build docker nano image') { steps {
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE', catchInterruptions: false) {
sh 'echo "DISABLED"'
sh 'it does work, it have the same issue as https://github.com/pytorch/pytorch/issues/39680'
sh 'exit 1'
sh 'ci/build-docker-images.sh nano'
}
}}
stage('Update dockerhub readme') {
when {
expression { BRANCH_NAME == "master" }
Expand Down
4 changes: 4 additions & 0 deletions ci/build-docker-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TARGETS[gpu]="gpu/default"
TARGETS[gpu_tf]="gpu/tf"
TARGETS[gpu_torch]="gpu/torch"
TARGETS[gpu_tensorrt]="gpu_tensorrt/tensorrt"
TARGETS[nano]="nano/default"

PR_NUMBER=$(echo $GIT_BRANCH | sed -n '/^PR-/s/PR-//gp')
if [ "$TAG_NAME" ]; then
Expand All @@ -31,6 +32,9 @@ else
TMP_TAG="trash"
fi

# Setup binfmt to use qemu for arm docker image
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

image_url_prefix="jolibrain/deepdetect"

for name in $NAMES; do
Expand Down
161 changes: 161 additions & 0 deletions docker/nano.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# if built on amd64 arch, install these packages to add arm support to docker
# apt install -y qemu binfmt-support qemu-user-static

FROM nvcr.io/nvidia/deepstream-l4t:5.1-21.02-base AS build

ARG DEEPDETECT_DEFAULT_MODELS=true

RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update -y && apt-get install -y \
wget \
curl \
cmake \
git \
ccache \
automake \
rsync \
build-essential \
pkg-config \
zip \
g++ \
gcc-7 g++-7 \
zlib1g-dev \
protobuf-compiler \
libprotobuf-dev \
libgoogle-glog-dev \
libgflags-dev \
libeigen3-dev \
libopencv-dev \
libboost-dev \
libboost-filesystem-dev \
libboost-thread-dev \
libboost-system-dev \
libboost-stacktrace-dev \
libboost-iostreams-dev \
libboost-program-options-dev \
libboost-test-dev \
libboost-regex-dev \
libboost-date-time-dev \
libboost-chrono-dev \
libssl-dev \
libgtest-dev \
libcurlpp-dev \
libcurl4-openssl-dev \
libopenblas-dev \
libhdf5-dev \
libleveldb-dev \
libsnappy-dev \
liblmdb-dev \
libutfcpp-dev \
rapidjson-dev \
libmapbox-variant-dev \
autoconf \
libtool-bin \
swig \
unzip \
libgoogle-perftools-dev \
libarchive-dev \
bash-completion \
schedtool \
python-numpy \
util-linux

RUN apt clean -y

RUN curl -L https://github.com/Kitware/CMake/releases/download/v3.19.6/cmake-3.19.6-Linux-aarch64.sh -o cmake-install.sh
RUN chmod +x ./cmake-install.sh
RUN ./cmake-install.sh --prefix=/usr/local --skip-license

ADD . /opt/deepdetect
WORKDIR /opt/deepdetect/

ENV CCACHE_DIR=/ccache
#ENV PATH=/usr/lib/ccache:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

# Build Deepdetect
ENV TERM=xterm
RUN mkdir build && cd build && \
cmake .. \
-DBUILD_SPDLOG=ON \
-DBUILD_PROTOBUF=OFF \
-DUSE_HTTP_SERVER_OATPP=ON \
-DUSE_CAFFE=OFF \
-DUSE_TENSORRT=ON \
-DUSE_TENSORRT_OSS=ON \
-DCUDA_ARCH="-gencode arch=compute_62,code=sm_62 -gencode arch=compute_53,code=sm_53" \
-DJETSON=ON && make

# Copy libs to /tmp/libs for next build stage
RUN ./docker/get_libs.sh

# Build final Docker image
FROM nvcr.io/nvidia/deepstream-l4t:5.1-21.02-base AS runtime

LABEL description="DeepDetect deep learning server & API / jetson nano version"
LABEL maintainer="[email protected]"

# Install tools and dependencies
RUN export DEBIAN_FRONTEND=noninteractive && \
apt-get update -y && apt-get install -y \
wget \
curl \
libopenblas-base \
liblmdb0 \
libleveldb1v5 \
libboost-regex1.62.0 \
libgoogle-glog0v5 \
libprotobuf10 \
libopencv3.2 \
libgflags2.2 \
libcurl4 \
libcurlpp0 \
libhdf5-cpp-100 \
libboost-atomic1.65.1 \
libboost-chrono1.65.1 \
libboost-date-time1.65.1 \
libboost-filesystem1.65.1 \
libboost-thread1.65.1 \
libboost-iostreams1.65.1 \
libboost-regex1.65.1 \
libboost-stacktrace1.65.1 \
libboost-system1.65.1 \
libarchive13

# Fix permissions
RUN ln -sf /dev/stdout /var/log/deepdetect.log && \
ln -sf /dev/stderr /var/log/deepdetect.log

RUN useradd -ms /bin/bash dd && \
chown -R dd:dd /opt
USER dd

# Copy Deepdetect binaries from previous step
COPY --from=build /opt/deepdetect/build/main /opt/deepdetect/build/main
COPY --from=build /opt/deepdetect/build/oatpp-swagger/src/oatpp-swagger/res/ /opt/deepdetect/build/oatpp-swagger/src/oatpp-swagger/res/
COPY --from=build --chown=dd /opt/deepdetect/datasets/imagenet/corresp_ilsvrc12.txt /opt/models/ggnet/corresp.txt
COPY --from=build --chown=dd /opt/deepdetect/datasets/imagenet/corresp_ilsvrc12.txt /opt/models/resnet_50/corresp.txt
COPY --from=build --chown=dd /opt/deepdetect/templates/caffe/googlenet/*prototxt /opt/models/ggnet/
COPY --from=build --chown=dd /opt/deepdetect/templates/caffe/resnet_50/*prototxt /opt/models/resnet_50/
COPY --from=build /tmp/lib/* /opt/deepdetect/build/lib/
COPY --from=build /opt/deepdetect/templates /opt/deepdetect/build/templates

COPY --from=build /opt/deepdetect/get_models.sh /opt/deepdetect/
COPY --from=build /opt/deepdetect/docker/check-dede-deps.sh /opt/deepdetect/
COPY --from=build /opt/deepdetect/docker/start-dede.sh /opt/deepdetect/

# External volume to be mapped, e.g. for models or training data
WORKDIR /opt/models

USER root
RUN chown -R dd:dd /opt/models

USER dd
RUN /opt/deepdetect/get_models.sh

# Ensure all libs are presents
RUN /opt/deepdetect/check-dede-deps.sh

WORKDIR /opt/deepdetect/build/main
CMD /opt/deepdetect/start-dede.sh -host 0.0.0.0
VOLUME ["/data"]
EXPOSE 8080

0 comments on commit 756845b

Please sign in to comment.