Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adjust versions in Dockerfile, clean args, add minor comments, dlc 2.3.5
  • Loading branch information
maryapp authored and stes committed Aug 25, 2023
commit dd252b9e601144d2cf4548ff055d29722a80ea80
18 changes: 11 additions & 7 deletions docker/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
ARG CUDA_VERSION=11.4.0-cudnn8-runtime-ubuntu20.04
ARG CUDA_VERSION
FROM nvidia/cuda:${CUDA_VERSION}

ARG DEEPLABCUT_VERSION=2.2.1.1
ARG DEEPLABCUT_VERSION
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update -yy \
&& apt-get install -yy --no-install-recommends python3 python3-pip python3-dev ffmpeg libsm6 libxext6 \
&& apt-get install -yy --no-install-recommends python3.8 python3-pip python3-dev ffmpeg libsm6 libxext6 \
&& apt-get install -yy --no-install-recommends build-essential make cmake gcc g++ \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN pip3 install --no-cache-dir --upgrade pip \
&& pip3 install --no-cache-dir --upgrade deeplabcut==${DEEPLABCUT_VERSION} numpy==1.19.5 decorator==4.4.2 tensorflow==2.5.0 \
&& pip3 list
RUN pip3 install --upgrade \
deeplabcut==${DEEPLABCUT_VERSION} \
decorator==4.4.2 \
tensorflow==2.5.0 \
torch==1.12 \
numpy==1.21 \
&& pip3 list

# The installed tensorflow version will not work with the latest protocol buffer version,
# hence we are fixing the version to 3.20.
#
# See https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
# for details on why this is needed.
RUN pip3 install --no-cache-dir protobuf==3.20.1
RUN pip3 install protobuf==3.20.1

# TODO required to fix permission errors when running the container with limited permission.
RUN chmod a+rwx -R /usr/local/lib/python3.8/dist-packages/deeplabcut/pose_estimation_tensorflow/models/pretrained
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.core
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG CUDA_VERSION=11.4.0-cudnn8-runtime-ubuntu20.04
ARG DEEPLABCUT_VERSION=2.2.1.1
ARG CUDA_VERSION
ARG DEEPLABCUT_VERSION
FROM deeplabcut/deeplabcut:${DEEPLABCUT_VERSION}-base-cuda${CUDA_VERSION}

ENV DLClight True
Expand Down
16 changes: 6 additions & 10 deletions docker/Dockerfile.gui
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
ARG CUDA_VERSION=11.4.0-cudnn8-runtime-ubuntu20.04
ARG DEEPLABCUT_VERSION=2.2.1.1
ARG CUDA_VERSION
ARG DEEPLABCUT_VERSION

FROM deeplabcut/deeplabcut:${DEEPLABCUT_VERSION}-base-cuda${CUDA_VERSION}

RUN DEBIAN_FRONTEND=noninteractive apt-get update -yy \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install -yy --no-install-recommends \
libgtk-3-dev python3-wxgtk4.0 locales \
&& apt-get install -yy --no-install-recommends libgtk-3-dev python3-wxgtk4.0 locales \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& locale-gen en_US.UTF-8 en_GB.UTF-8

ARG DEEPLABCUT_VERSION=2.2.1.1
RUN pip3 install --no-cache-dir --upgrade pip \
&& pip3 install --no-cache-dir --upgrade deeplabcut[gui]==${DEEPLABCUT_VERSION} numpy==1.19.5 decorator==4.4.2 tensorflow==2.5.0 protobuf==3.20.1 \
ARG DEEPLABCUT_VERSION
RUN pip3 install --no-cache-dir --upgrade deeplabcut[gui]==${DEEPLABCUT_VERSION} \
&& pip3 list



ENV DLClight=False
CMD ["python3", "-m", "deeplabcut"]
33 changes: 23 additions & 10 deletions docker/Dockerfile.jupyter
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
ARG CUDA_VERSION=11.4.0-cudnn8-runtime-ubuntu20.04
ARG DEEPLABCUT_VERSION=2.2.1.1
FROM deeplabcut/deeplabcut:${DEEPLABCUT_VERSION}-gui-cuda${CUDA_VERSION}

RUN pip install --no-cache-dir jupyter
COPY ./examples /app/examples
CMD ["jupyter", "notebook", \
"--no-browser", \
"--NotebookApp.password", "sha3_224:019dc9326f7c:689d6c568f840f6126fb438ba0cdb8ce94ddd0769399e152caf79931", \
"--ip", "0.0.0.0" ]
ARG CUDA_VERSION
ARG DEEPLABCUT_VERSION
FROM deeplabcut/deeplabcut:${DEEPLABCUT_VERSION}-core-cuda${CUDA_VERSION}

RUN pip3 install --no-cache-dir \
notebook==6.4.12 \
&& pip3 list

ENV PYTHONPATH "${PYTHONPATH}:/usr/lib/python3"

ARG USER=docker_user
RUN useradd -m ${USER} \
&& cp /root/.bashrc /home/${USER}/ \
&& mkdir /app /data /codebase \
&& chown -R --from=root ${USER} /home/${SUSER} \
/app /data /codebase
ENV HOME /home/${USER}
WORKDIR ${HOME}
USER ${USER}

RUN jupyter notebook --generate-config
EXPOSE 8888
ENTRYPOINT ["jupyter", "notebook", "--no-browser", "--ip", "0.0.0.0"]
180 changes: 95 additions & 85 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,118 +4,128 @@

set -e

# Set default Docker binary
export DOCKER=${DOCKER:-'docker'}
export DOCKER_BUILD="$DOCKER build"
export BASENAME=deeplabcut/deeplabcut
export DOCKERDIR=docker

# Check if script is being run from the correct directory
if [[ ! -d ./${DOCKERDIR} ]]; then
>&2 echo Run from repository root. Current pwd is
>&2 pwd
exit 1
echo >&2 Run from repository root. Current pwd is
pwd >&2
exit 1
fi

# List Docker images related to DeepLabCut
list_images() {
$DOCKER images \
| grep '^deeplabcut ' \
| sed -s 's/\s\s\+/\t/g' \
| cut -f1,2 -d$'\t' --output-delimiter ':' \
| grep core
$DOCKER images |
grep '^deeplabcut ' |
sed -s 's/\s\s\+/\t/g' |
cut -f1,2 -d$'\t' --output-delimiter ':' |
grep core
}

# Run tests inside Docker containers
run_test() {
kwargs=(
-u $(id -u) --tmpfs /.local --tmpfs /.cache
--tmpfs /test/.pytest_cache
--env DLClight=True -t
$1
)
kwargs=(
-u $(id -u) --tmpfs /.local --tmpfs /.cache
--tmpfs /test/.pytest_cache
--env DLClight=True -t
$1
)

# Unit tests
$DOCKER run ${kwargs[@]} python3 -m pytest -v tests || return 255
# Unit tests
$DOCKER run ${kwargs[@]} python3 -m pytest -v tests || return 255

# Functional tests
$DOCKER run ${kwargs[@]} python3 testscript_cli.py || return 255
# Functional tests
$DOCKER run ${kwargs[@]} python3 testscript_cli.py || return 255

return 0
return 0
}
export -f run_test

# Iterate through build matrix and perform actions
iterate_build_matrix() {
## TODO(stes): Consider adding legacy versions for CUDA
## if there is demand from users:
# 10.2-runtime-ubuntu18.04 \
# 11.1.1-runtime-ubuntu18.04 \
mode=${1:-build}
for cuda_version in \
11.4.0-cudnn8-runtime-ubuntu20.04 \
11.7.0-cudnn8-runtime-ubuntu20.04
do
for deeplabcut_version in \
2.2.0.6 \
2.2.1.1
do
for stage in base core test gui jupyter; do
tag=${deeplabcut_version}-${stage}-cuda${cuda_version}
case "$mode" in
build)
echo \
--build-arg=CUDA_VERSION=${cuda_version} \
--build-arg=DEEPLABCUT_VERSION=${deeplabcut_version} \
"--tag=${BASENAME}:$tag" \
-f "Dockerfile.${stage}" \.
;;
clean|test|push)
echo ${BASENAME}:${tag}
;;
esac
done
done
done
## TODO(stes): Consider adding legacy versions for CUDA
## if there is demand from users:

mode=${1:-build}
for cuda_version in \
11.4.3-cudnn8-runtime-ubuntu20.04; do
for deeplabcut_version in \
2.3.5; do #2.3.2 \
for stage in \
base core test gui jupyter; do
tag=${deeplabcut_version}-${stage}-cuda${cuda_version}-latest
case "$mode" in
build)
echo \
--build-arg=CUDA_VERSION=${cuda_version} \
--build-arg=DEEPLABCUT_VERSION=${deeplabcut_version} \
"--tag=${BASENAME}:$tag" \
-f "Dockerfile.${stage}" \.
;;
push | clean | test)
echo ${BASENAME}:${tag}
;;
esac
done
done
done
}

# Get Git hash
githash() {
git log -1 --pretty=format:"%h"
git log -1 --pretty=format:"%h"
}

# Create logs directory and set log file name
mkdir -p logs
logfile=logs/$(date +%y%m%d-%H%M%S)-$(githash)
echo "Logging to $logdir.*"

# Iterate through command line arguments
for arg in "$@"; do
case $1 in
clean)
iterate_build_matrix clean \
| tr '\n' '\0' \
| xargs -I@ -0 bash -c "docker image rm @ |& grep -v 'No such image'"
;;
build)
echo "DeepLabCut docker build:: $(git log -1 --oneline)"
cp -r examples ${DOCKERDIR}
(
cd ${DOCKERDIR}
iterate_build_matrix \
| tr '\n' '\0' \
| xargs -I@ -0 bash -c "echo Building @; $DOCKER build @ || exit 255"
echo Successful build.
) |& tee ${logfile}.build
;;
test)
(
echo "DeepLabCut docker build:: $(git log -1 --oneline)"
iterate_build_matrix test \
| grep '\-test\-' \
| tr '\n' '\0' \
| xargs -0 -I@ bash -c "run_test @ || exit 255"
echo Successful test.
) |& tee ${logfile}.test
;;
push)
iterate_build_matrix push \
| grep -v '\-test\-' \
| tr '\n' '\0' \
| xargs -I@ -0 echo ${DOCKER} push @
;;
esac
case $1 in
clean)
iterate_build_matrix clean |
tr '\n' '\0' |
xargs -I@ -0 bash -c "docker image rm @ |& grep -v 'No such image'"
;;
build)
echo "DeepLabCut docker build:: $(git log -1 --oneline)"
cp -r examples ${DOCKERDIR}
(
cd ${DOCKERDIR}
iterate_build_matrix |
tr '\n' '\0' |
xargs -I@ -0 bash -c "echo Building @; $DOCKER build @ || exit 255"
echo Successful build.
) |& tee ${logfile}.build
;;
test)
(
echo "DeepLabCut docker build:: $(git log -1 --oneline)"
iterate_build_matrix test |
grep '\-test\-' |
tr '\n' '\0' |
xargs -0 -I@ bash -c "run_test @ || exit 255"
echo Successful test.
) |& tee ${logfile}.test
;;
push)
iterate_build_matrix push |
grep -v '\-test\-' |
tr '\n' '\0' |
xargs -I@ -0 bash -c "echo docker push @-latest; \
docker tag @ @-latest; \
docker push @-latest; \
docker image rm @ |& grep -v 'No such image'"
;;
*)
echo "Usage: $0 [build|test|push]"
exit 1
;;
esac
done