Skip to content

Commit

Permalink
Add Docker configuration for InferenceUsingTFHubCenterNetObjDetect
Browse files Browse the repository at this point in the history
  • Loading branch information
zmughal committed Oct 3, 2023
1 parent 4608c3c commit 176b189
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
53 changes: 53 additions & 0 deletions docker/Dockerfile.nb-obj-detect
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#syntax=docker/dockerfile-upstream:1.4.0-rc1

# notebook/InferenceUsingTFHubCenterNetObjDetect.ipynb

# Packages from Ubuntu focal base
ARG NB_APT_PKGS_RUN=" libjpeg-turbo8 libpng16-16 netpbm gnuplot-nox"
ARG NB_APT_PKGS_DEV="perl-doc libjpeg-turbo8-dev libpng-dev"
ARG NB_POD="AI::TensorFlow::Libtensorflow::Manual::Notebook::InferenceUsingTFHubCenterNetObjDetect"

FROM base AS nb-builder

ARG NB_APT_PKGS_RUN
ARG NB_APT_PKGS_DEV
ARG NB_POD

USER root

RUN apt-get update && apt-get install -y --no-install-recommends $NB_APT_PKGS_RUN $NB_APT_PKGS_DEV
RUN bash -c ' \
eval $(perl -Mlocal::lib=/perl5-nb); \
export MAKEFLAGS=$(nproc); \
plx cpm install -g --cpanfile=<( \
awk "/=head1 CPANFILE/,EOF {print}" $( plx perldoc -l $NB_POD ) \
| awk "NR>1" \
)'
RUN apt-get remove -y $NB_APT_PKGS_DEV && apt-get autoremove -y && apt-get clean
RUN rm -Rf $HOME/.perl-cpm/ $HOME/.cpanm

FROM base AS object-detection

ARG NB_APT_PKGS_RUN
ARG NB_POD

ARG NB_USER
ARG NB_UID

USER root

COPY --from=nb-builder /perl5-nb /perl5-nb

RUN apt-get update && apt-get install -y --no-install-recommends $NB_APT_PKGS_RUN

RUN apt-get -qq purge \
&& apt-get -qq clean \
&& rm -rf /var/lib/apt/lists/*

RUN chown -R ${NB_USER}:${NB_USER} /perl5-nb

USER ${NB_USER}

RUN bash -c 'plx perl -c $( plx perldoc -l $NB_POD );'

# vim:ft=dockerfile
8 changes: 6 additions & 2 deletions docker/Dockerfile.nb-omnibus
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
# Builds on top of:
# - docker/Dockerfile.nb-image-class
# - docker/Dockerfile.nb-gene-expr-pred
# - docker/Dockerfile.nb-obj-detect
#
# The contents of `NB_APT_PKGS_RUN` come from those `Dockerfile`s.
ARG NB_APT_PKGS_RUN=" \
libjpeg-turbo8 libpng16-16 libgsl23 \
samtools libhts3 tabix libxml2 libexpat1 libdb5.3 netpbm gnuplot-nox \
libjpeg-turbo8 libpng16-16 netpbm gnuplot-nox \
"

FROM base as omnibus
Expand All @@ -23,6 +25,7 @@ USER root

COPY --from=nb-image-class /perl5-nb /perl5-nb-image-class
COPY --from=nb-gene-expr-pred /perl5-nb /perl5-nb-gene-expr-pred
COPY --from=nb-obj-detect /perl5-nb /perl5-nb-obj-detect

RUN apt-get update && apt-get install -y --no-install-recommends $NB_APT_PKGS_RUN

Expand All @@ -32,8 +35,8 @@ RUN apt-get -qq purge \

RUN \
mkdir -p /perl5-nb \
&& cp -pR /perl5-nb-image-class/. /perl5-nb-gene-expr-pred/. /perl5-nb/ \
&& rm -Rf /perl5-nb-image-class /perl5-nb-gene-expr-pred
&& cp -pR /perl5-nb-image-class/. /perl5-nb-gene-expr-pred/. /perl5-nb-obj-detect/. /perl5-nb/ \
&& rm -Rf /perl5-nb-image-class /perl5-nb-gene-expr-pred /perl5-nb-obj-detect

RUN chown -R ${NB_USER}:${NB_USER} /perl5-nb

Expand All @@ -45,6 +48,7 @@ RUN bash -c ' \
for NB_POD in \
AI::TensorFlow::Libtensorflow::Manual::Notebook::InferenceUsingTFHubMobileNetV2Model \
AI::TensorFlow::Libtensorflow::Manual::Notebook::InferenceUsingTFHubEnformerGeneExprPredModel \
AI::TensorFlow::Libtensorflow::Manual::Notebook::InferenceUsingTFHubCenterNetObjDetect \
; do \
plx perl -c $( plx perl -MPod::Simple::Search -e "print Pod::Simple::Search->new->find(shift @ARGV)" $NB_POD ); \
done;'
Expand Down
13 changes: 13 additions & 0 deletions docker/docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ group "default" {
"nb-omnibus",
"nb-image-class",
"nb-gene-expr-pred",
"nb-obj-detect",
]
}

Expand Down Expand Up @@ -106,13 +107,24 @@ target "nb-gene-expr-pred" {
tags = tag("cpu", "-nb-gene-expr-pred")
}

target "nb-obj-detect" {
inherits = [ "nb-cpu" ]
dockerfile = "docker/Dockerfile.nb-obj-detect"
target = "object-detection"
contexts = {
base = "target:base"
}
tags = tag("cpu", "-nb-obj-detect")
}

target "nb-omnibus" {
inherits = [ "nb-cpu" ]
dockerfile = "docker/Dockerfile.nb-omnibus"
contexts = {
base = "target:base"
nb-image-class = "target:nb-image-class"
nb-gene-expr-pred = "target:nb-gene-expr-pred"
nb-obj-detect = "target:nb-obj-detect"
}
tags = tag("cpu", "-nb-omnibus")
}
Expand All @@ -123,6 +135,7 @@ target "gpu-nb-omnibus" {
NB_APT_PKGS_RUN = <<EOF
libjpeg-turbo8 libpng16-16 libgsl23
samtools libhts3 tabix libxml2 libexpat1 libdb5.3 netpbm gnuplot-nox
libjpeg-turbo8 libpng16-16 netpbm gnuplot-nox
EOF
}
dockerfile = "docker/Dockerfile.with-gpu-libtf"
Expand Down
5 changes: 4 additions & 1 deletion lib/AI/TensorFlow/Libtensorflow/Manual/Quickstart.pod
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ L<InferenceUsingTFHubMobileNetV2Model|AI::TensorFlow::Libtensorflow::Manual::Not
= C<latest-nb-gene-expr-pred>: image containing dependencies needed to run
L<InferenceUsingTFHubEnformerGeneExprPredModel|AI::TensorFlow::Libtensorflow::Manual::Notebook::InferenceUsingTFHubEnformerGeneExprPredModel>.

= C<latest-nb-omnibus>: image containing dependencies for both of the above
= C<latest-nb-obj-detect>: image containing dependencies needed to run
L<InferenceUsingTFHubCenterNetObjDetect|AI::TensorFlow::Libtensorflow::Manual::Notebook::InferenceUsingTFHubCenterNetObjDetect>.

= C<latest-nb-omnibus>: image containing dependencies for all of the above
notebooks.

= C<latest-gpu-nb-omnibus>: same as C<latest-nb-omnibus> but with NVIDIA GPU support.
Expand Down

0 comments on commit 176b189

Please sign in to comment.