From a6eec0228c9176095b6112e314763edd95a254a0 Mon Sep 17 00:00:00 2001 From: "yi.wu" Date: Fri, 10 Mar 2017 17:09:19 +0800 Subject: [PATCH 1/9] thinner docker --- paddle/scripts/docker/README.md | 9 +++ paddle/scripts/docker/buildall.sh | 27 +++++++++ .../docker/buildimage/Dockerfile.build | 59 +++++++++++++++++++ paddle/scripts/docker/paddle-core/Dockerfile | 38 ++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 paddle/scripts/docker/README.md create mode 100644 paddle/scripts/docker/buildall.sh create mode 100644 paddle/scripts/docker/buildimage/Dockerfile.build create mode 100644 paddle/scripts/docker/paddle-core/Dockerfile diff --git a/paddle/scripts/docker/README.md b/paddle/scripts/docker/README.md new file mode 100644 index 0000000000000..167b6be8eeb11 --- /dev/null +++ b/paddle/scripts/docker/README.md @@ -0,0 +1,9 @@ +# Build docker image + +We use a docker environment to build paddle binaries and put it into a runtime image `paddle-core` for uses of most cases + +***Notice***: do **not** run in this directory, run under the top level of this project like: + +``` +sh paddle/scripts/docker/buildall.sh +``` diff --git a/paddle/scripts/docker/buildall.sh b/paddle/scripts/docker/buildall.sh new file mode 100644 index 0000000000000..2d7de80965214 --- /dev/null +++ b/paddle/scripts/docker/buildall.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +BINARIES_DIR=paddle/scripts/docker/buildimage/binaries + +function build_in_docker() { + docker build . -t paddle-build-env -f paddle/scripts/docker/buildimage/Dockerfile.build + BUILDER=$(docker run -d paddle-build-env) + docker exec $BUILDER /bin/bash -c "export BUILD_AND_INSTALL=ON && /paddle/paddle/scripts/docker/build.sh" + mkdir -p $BINARIES_DIR + docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_pserver_main $BINARIES_DIR + docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_trainer $BINARIES_DIR + docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_merge_model $BINARIES_DIR + docker cp $BUILDER:/usr/local/bin/paddle $BINARIES_DIR + docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_usage $BINARIES_DIR + + docker cp $BUILDER:/usr/local/opt/paddle/share/wheels $BINARIES_DIR + + docker stop $BUILDER && docker rm $BUILDER +} + +function build_paddle_core() { + docker build . -t paddle-core -f paddle/scripts/docker/paddle-core/Dockerfile + +} + +build_in_docker +build_paddle_core diff --git a/paddle/scripts/docker/buildimage/Dockerfile.build b/paddle/scripts/docker/buildimage/Dockerfile.build new file mode 100644 index 0000000000000..03e6ac792f225 --- /dev/null +++ b/paddle/scripts/docker/buildimage/Dockerfile.build @@ -0,0 +1,59 @@ +# A image for building paddle binaries +FROM ubuntu:14.04 +MAINTAINER PaddlePaddle Authors + +ARG DEBIAN_FRONTEND=noninteractive +ARG UBUNTU_MIRROR +RUN /bin/bash -c 'if [[ -n ${UBUNTU_MIRROR} ]]; then sed -i 's#http://archive.ubuntu.com#${UBUNTU_MIRROR}#g' /etc/apt/sources.list; fi' + +# ENV variables +ARG BUILD_WOBOQ +ARG BUILD_AND_INSTALL +ARG WITH_AVX +ARG WITH_DOC +ARG WITH_STYLE_CHECK + +ENV BUILD_WOBOQ=${BUILD_WOBOQ:-OFF} +ENV BUILD_AND_INSTALL=${BUILD_AND_INSTALL:-OFF} +ENV WITH_GPU=OFF +ENV WITH_AVX=${WITH_AVX:-ON} +ENV WITH_DOC=${WITH_DOC:-OFF} +ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} + +ENV HOME /root + +RUN sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y git python-pip python-dev openssh-server bison && \ + apt-get install -y wget unzip tar xz-utils bzip2 gzip coreutils && \ + apt-get install -y curl sed grep graphviz libjpeg-dev zlib1g-dev && \ + apt-get install -y python-numpy python-matplotlib gcc g++ gfortran && \ + apt-get install -y automake locales clang-format-3.8 && \ + apt-get clean -y + +# git credential to skip password typing +RUN git config --global credential.helper store + +# Fix locales to en_US.UTF-8 +RUN localedef -i en_US -f UTF-8 en_US.UTF-8 + +RUN pip install --upgrade pip && \ + pip install -U 'protobuf==3.1.0' && \ + pip install -U wheel pillow BeautifulSoup && \ + pip install -U docopt PyYAML sphinx && \ + pip install -U sphinx-rtd-theme==0.1.9 recommonmark && \ + pip install -U pre-commit 'requests==2.9.2' jupyter + +RUN curl -sSL https://cmake.org/files/v3.4/cmake-3.4.1.tar.gz | tar -xz && \ + cd cmake-3.4.1 && ./bootstrap && make -j `nproc` && make install && \ + cd .. && rm -rf cmake-3.4.1 + +COPY . /paddle/ +RUN cd /paddle/ && git submodule update --init --recursive +RUN /paddle/paddle/scripts/docker/build.sh + +VOLUME ["/usr/share/nginx/html/data", "/usr/share/nginx/html/paddle"] + + +# FIXME: wait a long time is OK +CMD ["sleep", "3600"] diff --git a/paddle/scripts/docker/paddle-core/Dockerfile b/paddle/scripts/docker/paddle-core/Dockerfile new file mode 100644 index 0000000000000..708e4fe8013fd --- /dev/null +++ b/paddle/scripts/docker/paddle-core/Dockerfile @@ -0,0 +1,38 @@ +FROM python:2.7.13-slim +MAINTAINER PaddlePaddle Authors + +# ENV variables +ARG WITH_AVX +ARG WITH_DOC +ARG WITH_STYLE_CHECK + +ENV WITH_GPU=OFF +ENV WITH_AVX=${WITH_AVX:-ON} +ENV WITH_DOC=${WITH_DOC:-OFF} +ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} + +ENV HOME /root +ENV LANG en_US.UTF-8 + +# Use Fix locales to en_US.UTF-8 + +RUN sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y libgfortran3 && \ + apt-get clean -y && \ + pip install --upgrade pip && \ + pip install -U 'protobuf==3.1.0' +RUN pip install numpy + +ADD paddle/scripts/docker/buildimage/binaries/paddle paddle/scripts/docker/buildimage/binaries/paddle_trainer \ +paddle/scripts/docker/buildimage/binaries/paddle_pserver_main paddle/scripts/docker/buildimage/binaries/paddle_merge_model \ +paddle/scripts/docker/buildimage/binaries/paddle_usage /usr/local/opt/paddle/bin/ +ADD paddle/scripts/docker/buildimage/binaries/wheels/py_paddle*linux*.whl paddle/scripts/docker/buildimage/binaries/wheels/paddle*.whl \ + /usr/local/opt/paddle/share/wheels/ +RUN pip install /usr/local/opt/paddle/share/wheels/py_paddle*linux*.whl && \ + pip install /usr/local/opt/paddle/share/wheels/paddle*.whl && \ + rm /usr/local/opt/paddle/share/wheels/py_paddle*linux*.whl && \ + rm /usr/local/opt/paddle/share/wheels/paddle*.whl +ENV PATH="/usr/local/opt/paddle/bin/:${PATH}" +# default command shows the paddle version and exit +CMD ["paddle", "version"] From f66fd44fecc8b6fe1880aea96d266998a35f37a0 Mon Sep 17 00:00:00 2001 From: "yi.wu" Date: Mon, 13 Mar 2017 19:00:45 +0800 Subject: [PATCH 2/9] do not use docker cp --- .gitignore | 4 ++- paddle/scripts/docker/buildall.sh | 27 +++++++++++-------- paddle/scripts/docker/paddle-core/Dockerfile | 12 ++++++--- .../Dockerfile} | 7 ----- 4 files changed, 27 insertions(+), 23 deletions(-) rename paddle/scripts/docker/{buildimage/Dockerfile.build => paddle-dev/Dockerfile} (90%) diff --git a/.gitignore b/.gitignore index 6aae076a49012..3b407e631019f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ *.DS_Store -build/ +build/paddle/math +build/paddle/utils +build/paddle/gserver *.user .vscode diff --git a/paddle/scripts/docker/buildall.sh b/paddle/scripts/docker/buildall.sh index 2d7de80965214..c10720ab62dfd 100644 --- a/paddle/scripts/docker/buildall.sh +++ b/paddle/scripts/docker/buildall.sh @@ -1,27 +1,32 @@ #!/bin/bash BINARIES_DIR=paddle/scripts/docker/buildimage/binaries +BUILD_DIR=$PWD/build function build_in_docker() { - docker build . -t paddle-build-env -f paddle/scripts/docker/buildimage/Dockerfile.build - BUILDER=$(docker run -d paddle-build-env) + if [ ! -d $BUILD_DIR ]; then + mkdir -p $BUILD_DIR + fi + docker build . -t paddle-build-env -f paddle/scripts/docker/paddle-dev/Dockerfile + # FIXME: need to wait a signal not sleeping + BUILDER=$(docker run -d -v ${PWD}:/paddle paddle-build-env sleep 3600) + # TODO(typhoonzero): docker exec $BUILDER /bin/bash -c "export BUILD_AND_INSTALL=ON && /paddle/paddle/scripts/docker/build.sh" mkdir -p $BINARIES_DIR - docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_pserver_main $BINARIES_DIR - docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_trainer $BINARIES_DIR - docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_merge_model $BINARIES_DIR - docker cp $BUILDER:/usr/local/bin/paddle $BINARIES_DIR - docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_usage $BINARIES_DIR - - docker cp $BUILDER:/usr/local/opt/paddle/share/wheels $BINARIES_DIR + # docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_pserver_main $BINARIES_DIR + # docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_trainer $BINARIES_DIR + # docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_merge_model $BINARIES_DIR + # docker cp $BUILDER:/usr/local/bin/paddle $BINARIES_DIR + # docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_usage $BINARIES_DIR + # + # docker cp $BUILDER:/usr/local/opt/paddle/share/wheels $BINARIES_DIR docker stop $BUILDER && docker rm $BUILDER } function build_paddle_core() { docker build . -t paddle-core -f paddle/scripts/docker/paddle-core/Dockerfile - } build_in_docker -build_paddle_core +#build_paddle_core diff --git a/paddle/scripts/docker/paddle-core/Dockerfile b/paddle/scripts/docker/paddle-core/Dockerfile index 708e4fe8013fd..628f581776182 100644 --- a/paddle/scripts/docker/paddle-core/Dockerfile +++ b/paddle/scripts/docker/paddle-core/Dockerfile @@ -24,10 +24,14 @@ RUN sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/ pip install -U 'protobuf==3.1.0' RUN pip install numpy -ADD paddle/scripts/docker/buildimage/binaries/paddle paddle/scripts/docker/buildimage/binaries/paddle_trainer \ -paddle/scripts/docker/buildimage/binaries/paddle_pserver_main paddle/scripts/docker/buildimage/binaries/paddle_merge_model \ -paddle/scripts/docker/buildimage/binaries/paddle_usage /usr/local/opt/paddle/bin/ -ADD paddle/scripts/docker/buildimage/binaries/wheels/py_paddle*linux*.whl paddle/scripts/docker/buildimage/binaries/wheels/paddle*.whl \ +ADD build/paddle/trainer/paddle_trainer \ + build/paddle/pserver/paddle_pserver_main \ + build/paddle/trainer/paddle_merge_model \ + /usr/local/opt/paddle/bin/ +ADD build/paddle/scripts/usage.sh /usr/local/opt/paddle/bin/paddle_usage +ADD paddle/scripts/submit_local.sh.in /usr/bin/paddle + +ADD paddle/dist/py_paddle*linux*.whl build/python/dist/paddle*.whl \ /usr/local/opt/paddle/share/wheels/ RUN pip install /usr/local/opt/paddle/share/wheels/py_paddle*linux*.whl && \ pip install /usr/local/opt/paddle/share/wheels/paddle*.whl && \ diff --git a/paddle/scripts/docker/buildimage/Dockerfile.build b/paddle/scripts/docker/paddle-dev/Dockerfile similarity index 90% rename from paddle/scripts/docker/buildimage/Dockerfile.build rename to paddle/scripts/docker/paddle-dev/Dockerfile index 03e6ac792f225..1aee44e21be9f 100644 --- a/paddle/scripts/docker/buildimage/Dockerfile.build +++ b/paddle/scripts/docker/paddle-dev/Dockerfile @@ -48,12 +48,5 @@ RUN curl -sSL https://cmake.org/files/v3.4/cmake-3.4.1.tar.gz | tar -xz && \ cd cmake-3.4.1 && ./bootstrap && make -j `nproc` && make install && \ cd .. && rm -rf cmake-3.4.1 -COPY . /paddle/ -RUN cd /paddle/ && git submodule update --init --recursive -RUN /paddle/paddle/scripts/docker/build.sh - -VOLUME ["/usr/share/nginx/html/data", "/usr/share/nginx/html/paddle"] - - # FIXME: wait a long time is OK CMD ["sleep", "3600"] From 1b269dbe0628d88181bb0a079da4e02bb3735d2a Mon Sep 17 00:00:00 2001 From: "yi.wu" Date: Tue, 14 Mar 2017 15:09:49 +0800 Subject: [PATCH 3/9] use deb to build paddle-core image --- paddle/scripts/deb/build_scripts/build.sh | 18 +++++++--- paddle/scripts/docker/buildall.sh | 27 ++++++++------- paddle/scripts/docker/paddle-core/Dockerfile | 16 ++------- .../scripts/docker/paddle-core/Dockerfile.gpu | 32 ++++++++++++++++++ .../docker/paddle-core/Dockerfile.gpunoavx | 33 +++++++++++++++++++ .../docker/paddle-core/Dockerfile.noavx | 32 ++++++++++++++++++ paddle/scripts/docker/paddle-dev/Dockerfile | 7 ++-- 7 files changed, 130 insertions(+), 35 deletions(-) create mode 100644 paddle/scripts/docker/paddle-core/Dockerfile.gpu create mode 100644 paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx create mode 100644 paddle/scripts/docker/paddle-core/Dockerfile.noavx diff --git a/paddle/scripts/deb/build_scripts/build.sh b/paddle/scripts/deb/build_scripts/build.sh index d13dea514841b..51cf7f1b9ba74 100755 --- a/paddle/scripts/deb/build_scripts/build.sh +++ b/paddle/scripts/deb/build_scripts/build.sh @@ -1,5 +1,6 @@ #!/bin/bash set -e +ARCH=$(uname -i) apt-get update apt-get install -y dh-make cd ~ @@ -8,28 +9,35 @@ mkdir -p ~/dist/cpu mkdir -p ~/dist/cpu-noavx mkdir -p ~/dist/gpu-noavx cd paddle -mkdir build + +# clean build dir and third_party dir cache +rm -rf build third_party +mkdir -p build cd build -cmake .. -DWITH_GPU=OFF -DWITH_SWIG_PY=ON -DWITH_AVX=ON +cmake .. -DWITH_GPU=OFF -DWITH_SWIG_PY=ON -DWITH_AVX=ON -DWITH_SWIG_PY=ON -DWITH_STYLE_CHECK=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON make -j `nproc` +# FIXME(typhoonzero): add ARCH gpu noavx flag to CPACK_SYSTEM_NAME. Why -D not affect anything? cpack -D CPACK_GENERATOR='DEB' .. mv *.deb ~/dist/cpu rm -rf * -cmake .. -DWITH_GPU=ON -DWITH_SWIG_PY=ON -DWITH_AVX=ON -DCUDNN_ROOT=/usr/ +ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/lib/libcudnn.so +cmake .. -DWITH_GPU=ON -DWITH_SWIG_PY=ON -DWITH_AVX=ON -DCUDNN_ROOT=/usr/ -DWITH_SWIG_PY=ON -DWITH_STYLE_CHECK=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON make -j `nproc` cpack -D CPACK_GENERATOR='DEB' .. mv *.deb ~/dist/gpu rm -rf * -cmake .. -DWITH_GPU=OFF -DWITH_SWIG_PY=ON -DWITH_AVX=OFF +rm -f /usr/lib/libcudnn.so +cmake .. -DWITH_GPU=OFF -DWITH_SWIG_PY=ON -DWITH_AVX=OFF -DWITH_SWIG_PY=ON -DWITH_STYLE_CHECK=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON make -j `nproc` cpack -D CPACK_GENERATOR='DEB' .. mv *.deb ~/dist/cpu-noavx rm -rf * -cmake .. -DWITH_GPU=ON -DWITH_SWIG_PY=ON -DWITH_AVX=OFF -DCUDNN_ROOT=/usr/ +ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/lib/libcudnn.so +cmake .. -DWITH_GPU=ON -DWITH_SWIG_PY=ON -DWITH_AVX=OFF -DCUDNN_ROOT=/usr/ -DWITH_SWIG_PY=ON -DWITH_STYLE_CHECK=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON make -j `nproc` cpack -D CPACK_GENERATOR='DEB' .. mv *.deb ~/dist/gpu-noavx diff --git a/paddle/scripts/docker/buildall.sh b/paddle/scripts/docker/buildall.sh index c10720ab62dfd..9c1a985754081 100644 --- a/paddle/scripts/docker/buildall.sh +++ b/paddle/scripts/docker/buildall.sh @@ -1,32 +1,31 @@ #!/bin/bash -BINARIES_DIR=paddle/scripts/docker/buildimage/binaries BUILD_DIR=$PWD/build +DEB_DIST_DIR=$PWD/dist +VERSION=latest function build_in_docker() { if [ ! -d $BUILD_DIR ]; then mkdir -p $BUILD_DIR fi + if [ ! -d $DEB_DIST_DIR ]; then + mkdir -p $DEB_DIST_DIR + fi docker build . -t paddle-build-env -f paddle/scripts/docker/paddle-dev/Dockerfile # FIXME: need to wait a signal not sleeping - BUILDER=$(docker run -d -v ${PWD}:/paddle paddle-build-env sleep 3600) - # TODO(typhoonzero): - docker exec $BUILDER /bin/bash -c "export BUILD_AND_INSTALL=ON && /paddle/paddle/scripts/docker/build.sh" - mkdir -p $BINARIES_DIR - # docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_pserver_main $BINARIES_DIR - # docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_trainer $BINARIES_DIR - # docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_merge_model $BINARIES_DIR - # docker cp $BUILDER:/usr/local/bin/paddle $BINARIES_DIR - # docker cp $BUILDER:/usr/local/opt/paddle/bin/paddle_usage $BINARIES_DIR - # - # docker cp $BUILDER:/usr/local/opt/paddle/share/wheels $BINARIES_DIR + BUILDER=$(docker run -d -v ${PWD}:/root/paddle -v ${DEB_DIST_DIR}:/root/dist paddle-build-env sleep 3600) + # NOTICE: build deb files for real paddle image + docker exec $BUILDER /bin/bash -c "/root/paddle/paddle/scripts/deb/build_scripts/build.sh" docker stop $BUILDER && docker rm $BUILDER } function build_paddle_core() { - docker build . -t paddle-core -f paddle/scripts/docker/paddle-core/Dockerfile + docker build . -t paddle-core:$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile + docker build . -t paddle-core:gpu-$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile.gpu + docker build . -t paddle-core:cpu-noavx-$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile.noavx + docker build . -t paddle-core:gpu-noavx-$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx } build_in_docker -#build_paddle_core +build_paddle_core diff --git a/paddle/scripts/docker/paddle-core/Dockerfile b/paddle/scripts/docker/paddle-core/Dockerfile index 628f581776182..eade296a40121 100644 --- a/paddle/scripts/docker/paddle-core/Dockerfile +++ b/paddle/scripts/docker/paddle-core/Dockerfile @@ -23,20 +23,10 @@ RUN sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/ pip install --upgrade pip && \ pip install -U 'protobuf==3.1.0' RUN pip install numpy +# Use different deb file when building different type of images +ADD dist/cpu/*.deb /usr/local/opt/paddle/deb/cpu/ +RUN dpkg --force-all -i /usr/local/opt/paddle/deb/cpu/*.deb && rm -f /usr/local/opt/paddle/deb/cpu/*.deb -ADD build/paddle/trainer/paddle_trainer \ - build/paddle/pserver/paddle_pserver_main \ - build/paddle/trainer/paddle_merge_model \ - /usr/local/opt/paddle/bin/ -ADD build/paddle/scripts/usage.sh /usr/local/opt/paddle/bin/paddle_usage -ADD paddle/scripts/submit_local.sh.in /usr/bin/paddle - -ADD paddle/dist/py_paddle*linux*.whl build/python/dist/paddle*.whl \ - /usr/local/opt/paddle/share/wheels/ -RUN pip install /usr/local/opt/paddle/share/wheels/py_paddle*linux*.whl && \ - pip install /usr/local/opt/paddle/share/wheels/paddle*.whl && \ - rm /usr/local/opt/paddle/share/wheels/py_paddle*linux*.whl && \ - rm /usr/local/opt/paddle/share/wheels/paddle*.whl ENV PATH="/usr/local/opt/paddle/bin/:${PATH}" # default command shows the paddle version and exit CMD ["paddle", "version"] diff --git a/paddle/scripts/docker/paddle-core/Dockerfile.gpu b/paddle/scripts/docker/paddle-core/Dockerfile.gpu new file mode 100644 index 0000000000000..89386b0379ac1 --- /dev/null +++ b/paddle/scripts/docker/paddle-core/Dockerfile.gpu @@ -0,0 +1,32 @@ +FROM nvidia/cuda:7.5-cudnn5-runtime-ubuntu14.04 +MAINTAINER PaddlePaddle Authors + +# ENV variables +ARG WITH_AVX +ARG WITH_DOC +ARG WITH_STYLE_CHECK + +ENV WITH_GPU=OFF +ENV WITH_AVX=${WITH_AVX:-ON} +ENV WITH_DOC=${WITH_DOC:-OFF} +ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} + +ENV HOME /root +ENV LANG en_US.UTF-8 + +# Use Fix locales to en_US.UTF-8 + +RUN sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y python python-pip libgfortran3 && \ + apt-get clean -y && \ + pip install --upgrade pip && \ + pip install -U 'protobuf==3.1.0' +RUN pip install numpy +# Use different deb file when building different type of images +ADD dist/gpu/*.deb /usr/local/opt/paddle/deb/gpu/ +RUN dpkg --force-all -i /usr/local/opt/paddle/deb/gpu/*.deb && rm -f /usr/local/opt/paddle/deb/gpu/*.deb + +ENV PATH="/usr/local/opt/paddle/bin/:${PATH}" +# default command shows the paddle version and exit +CMD ["paddle", "version"] diff --git a/paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx b/paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx new file mode 100644 index 0000000000000..beaeb5c51e044 --- /dev/null +++ b/paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx @@ -0,0 +1,33 @@ +FROM python:2.7.13-slim +MAINTAINER PaddlePaddle Authors + +# ENV variables +ARG WITH_AVX +ARG WITH_DOC +ARG WITH_STYLE_CHECK + +ENV WITH_GPU=OFF +ENV WITH_AVX=${WITH_AVX:-ON} +ENV WITH_DOC=${WITH_DOC:-OFF} +ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} + +ENV HOME /root +ENV LANG en_US.UTF-8 + +# Use Fix locales to en_US.UTF-8 + +RUN sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y libgfortran3 && \ + apt-get clean -y && \ + pip install --upgrade pip && \ + pip install -U 'protobuf==3.1.0' +RUN pip install numpy +# Use different deb file when building different type of images +ADD dist/gpu-noavx/*.deb /usr/local/opt/paddle/deb/gpu-noavx/ +RUN dpkg --force-all -i /usr/local/opt/paddle/deb/gpu-noavx/*.deb && rm -f /usr/local/opt/paddle/deb/gpu-noavx/*.deb + + +ENV PATH="/usr/local/opt/paddle/bin/:${PATH}" +# default command shows the paddle version and exit +CMD ["paddle", "version"] diff --git a/paddle/scripts/docker/paddle-core/Dockerfile.noavx b/paddle/scripts/docker/paddle-core/Dockerfile.noavx new file mode 100644 index 0000000000000..853dd7703acde --- /dev/null +++ b/paddle/scripts/docker/paddle-core/Dockerfile.noavx @@ -0,0 +1,32 @@ +FROM nvidia/cuda:7.5-cudnn5-runtime-ubuntu14.04 +MAINTAINER PaddlePaddle Authors + +# ENV variables +ARG WITH_AVX +ARG WITH_DOC +ARG WITH_STYLE_CHECK + +ENV WITH_GPU=OFF +ENV WITH_AVX=${WITH_AVX:-ON} +ENV WITH_DOC=${WITH_DOC:-OFF} +ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} + +ENV HOME /root +ENV LANG en_US.UTF-8 + +# Use Fix locales to en_US.UTF-8 + +RUN sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y python python-pip libgfortran3 && \ + apt-get clean -y && \ + pip install --upgrade pip && \ + pip install -U 'protobuf==3.1.0' +RUN pip install numpy +# Use different deb file when building different type of images +ADD dist/cpu-noavx/*.deb /usr/local/opt/paddle/deb/cpu-noavx/ +RUN dpkg --force-all -i /usr/local/opt/paddle/deb/cpu-noavx/*.deb && rm -f /usr/local/opt/paddle/deb/cpu-noavx/*.deb + +ENV PATH="/usr/local/opt/paddle/bin/:${PATH}" +# default command shows the paddle version and exit +CMD ["paddle", "version"] diff --git a/paddle/scripts/docker/paddle-dev/Dockerfile b/paddle/scripts/docker/paddle-dev/Dockerfile index 1aee44e21be9f..11465a4ed8172 100644 --- a/paddle/scripts/docker/paddle-dev/Dockerfile +++ b/paddle/scripts/docker/paddle-dev/Dockerfile @@ -1,5 +1,6 @@ # A image for building paddle binaries -FROM ubuntu:14.04 +# Use cuda devel base image for both cpu and gpu environment +FROM nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04 MAINTAINER PaddlePaddle Authors ARG DEBIAN_FRONTEND=noninteractive @@ -22,8 +23,7 @@ ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} ENV HOME /root -RUN sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \ - apt-get update && \ +RUN apt-get update && \ apt-get install -y git python-pip python-dev openssh-server bison && \ apt-get install -y wget unzip tar xz-utils bzip2 gzip coreutils && \ apt-get install -y curl sed grep graphviz libjpeg-dev zlib1g-dev && \ @@ -48,5 +48,6 @@ RUN curl -sSL https://cmake.org/files/v3.4/cmake-3.4.1.tar.gz | tar -xz && \ cd cmake-3.4.1 && ./bootstrap && make -j `nproc` && make install && \ cd .. && rm -rf cmake-3.4.1 +RUN apt-get install -y swig # FIXME: wait a long time is OK CMD ["sleep", "3600"] From 12a3af19fbebb04b4b26d3aa0ca474bcfabdc672 Mon Sep 17 00:00:00 2001 From: "yi.wu" Date: Thu, 16 Mar 2017 09:55:54 +0800 Subject: [PATCH 4/9] update .gitignore --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 3b407e631019f..6aae076a49012 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,5 @@ *.DS_Store -build/paddle/math -build/paddle/utils -build/paddle/gserver +build/ *.user .vscode From 3298d3075d25376e931c81ea599618e7520010b7 Mon Sep 17 00:00:00 2001 From: "yi.wu" Date: Thu, 16 Mar 2017 09:56:36 +0800 Subject: [PATCH 5/9] production image name paddle not paddle-core --- paddle/scripts/docker/buildall.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/paddle/scripts/docker/buildall.sh b/paddle/scripts/docker/buildall.sh index 9c1a985754081..63e5301ad9188 100644 --- a/paddle/scripts/docker/buildall.sh +++ b/paddle/scripts/docker/buildall.sh @@ -21,10 +21,10 @@ function build_in_docker() { } function build_paddle_core() { - docker build . -t paddle-core:$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile - docker build . -t paddle-core:gpu-$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile.gpu - docker build . -t paddle-core:cpu-noavx-$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile.noavx - docker build . -t paddle-core:gpu-noavx-$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx + docker build . -t paddle:$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile + docker build . -t paddle:gpu-$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile.gpu + docker build . -t paddle:cpu-noavx-$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile.noavx + docker build . -t paddle:gpu-noavx-$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx } build_in_docker From 1ab419a1bdd5dd5013d923b156ac44c8db0d8955 Mon Sep 17 00:00:00 2001 From: "yi.wu" Date: Fri, 17 Mar 2017 13:31:02 +0800 Subject: [PATCH 6/9] new design: #1625 --- .../docker/Dockerfile.gpu => Dockerfile | 18 ++--- paddle/scripts/docker/Dockerfile | 71 ------------------- paddle/scripts/docker/build.sh | 69 +++++++++++++++++- paddle/scripts/docker/buildall.sh | 31 -------- paddle/scripts/docker/paddle-core/Dockerfile | 32 --------- .../scripts/docker/paddle-core/Dockerfile.gpu | 32 --------- .../docker/paddle-core/Dockerfile.gpunoavx | 33 --------- .../docker/paddle-core/Dockerfile.noavx | 32 --------- paddle/scripts/docker/paddle-dev/Dockerfile | 53 -------------- 9 files changed, 73 insertions(+), 298 deletions(-) rename paddle/scripts/docker/Dockerfile.gpu => Dockerfile (88%) delete mode 100644 paddle/scripts/docker/Dockerfile delete mode 100644 paddle/scripts/docker/buildall.sh delete mode 100644 paddle/scripts/docker/paddle-core/Dockerfile delete mode 100644 paddle/scripts/docker/paddle-core/Dockerfile.gpu delete mode 100644 paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx delete mode 100644 paddle/scripts/docker/paddle-core/Dockerfile.noavx delete mode 100644 paddle/scripts/docker/paddle-dev/Dockerfile diff --git a/paddle/scripts/docker/Dockerfile.gpu b/Dockerfile similarity index 88% rename from paddle/scripts/docker/Dockerfile.gpu rename to Dockerfile index a687d490a3af3..b835cc52cbe25 100644 --- a/paddle/scripts/docker/Dockerfile.gpu +++ b/Dockerfile @@ -1,3 +1,5 @@ +# A image for building paddle binaries +# Use cuda devel base image for both cpu and gpu environment FROM nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04 MAINTAINER PaddlePaddle Authors @@ -14,14 +16,12 @@ ARG WITH_STYLE_CHECK ENV BUILD_WOBOQ=${BUILD_WOBOQ:-OFF} ENV BUILD_AND_INSTALL=${BUILD_AND_INSTALL:-OFF} -ENV WITH_GPU=ON +ENV WITH_GPU=OFF ENV WITH_AVX=${WITH_AVX:-ON} ENV WITH_DOC=${WITH_DOC:-OFF} ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} -ENV DOCKER_BUILD=TRUE ENV HOME /root - # Add bash enhancements COPY ./paddle/scripts/docker/root/ /root/ @@ -50,9 +50,7 @@ RUN curl -sSL https://cmake.org/files/v3.4/cmake-3.4.1.tar.gz | tar -xz && \ cd cmake-3.4.1 && ./bootstrap && make -j `nproc` && make install && \ cd .. && rm -rf cmake-3.4.1 -COPY . /paddle/ -RUN cd /paddle/ && git submodule update --init --recursive -RUN /paddle/paddle/scripts/docker/build.sh +RUN apt-get install -y swig VOLUME ["/usr/share/nginx/html/data", "/usr/share/nginx/html/paddle"] @@ -63,9 +61,5 @@ RUN sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config EXPOSE 22 -# Jupyter Notebook: Paddle book -EXPOSE 8888 - -COPY ./paddle/scripts/docker/entrypoint /opt/bin/ - -CMD ["/opt/bin/entrypoint"] +# development image default do build work +CMD ["bash", "/paddle/paddle/scripts/docker/build.sh"] diff --git a/paddle/scripts/docker/Dockerfile b/paddle/scripts/docker/Dockerfile deleted file mode 100644 index 48af9e5b5fe83..0000000000000 --- a/paddle/scripts/docker/Dockerfile +++ /dev/null @@ -1,71 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER PaddlePaddle Authors - -ARG DEBIAN_FRONTEND=noninteractive -ARG UBUNTU_MIRROR -RUN /bin/bash -c 'if [[ -n ${UBUNTU_MIRROR} ]]; then sed -i 's#http://archive.ubuntu.com#${UBUNTU_MIRROR}#g' /etc/apt/sources.list; fi' - -# ENV variables -ARG BUILD_WOBOQ -ARG BUILD_AND_INSTALL -ARG WITH_AVX -ARG WITH_DOC -ARG WITH_STYLE_CHECK - -ENV BUILD_WOBOQ=${BUILD_WOBOQ:-OFF} -ENV BUILD_AND_INSTALL=${BUILD_AND_INSTALL:-OFF} -ENV WITH_GPU=OFF -ENV WITH_AVX=${WITH_AVX:-ON} -ENV WITH_DOC=${WITH_DOC:-OFF} -ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} -ENV DOCKER_BUILD=TRUE - -ENV HOME /root - -# Add bash enhancements -COPY ./paddle/scripts/docker/root/ /root/ - -RUN apt-get update && \ - apt-get install -y git python-pip python-dev openssh-server bison && \ - apt-get install -y wget unzip tar xz-utils bzip2 gzip coreutils && \ - apt-get install -y curl sed grep graphviz libjpeg-dev zlib1g-dev && \ - apt-get install -y python-numpy python-matplotlib gcc g++ gfortran && \ - apt-get install -y automake locales clang-format-3.8 && \ - apt-get clean -y - -# git credential to skip password typing -RUN git config --global credential.helper store - -# Fix locales to en_US.UTF-8 -RUN localedef -i en_US -f UTF-8 en_US.UTF-8 - -RUN pip install --upgrade pip && \ - pip install -U 'protobuf==3.1.0' && \ - pip install -U wheel pillow BeautifulSoup && \ - pip install -U docopt PyYAML sphinx && \ - pip install -U sphinx-rtd-theme==0.1.9 recommonmark && \ - pip install -U pre-commit 'requests==2.9.2' jupyter - -RUN curl -sSL https://cmake.org/files/v3.4/cmake-3.4.1.tar.gz | tar -xz && \ - cd cmake-3.4.1 && ./bootstrap && make -j `nproc` && make install && \ - cd .. && rm -rf cmake-3.4.1 - -COPY . /paddle/ -RUN cd /paddle/ && git submodule update --init --recursive -RUN /paddle/paddle/scripts/docker/build.sh - -VOLUME ["/usr/share/nginx/html/data", "/usr/share/nginx/html/paddle"] - -# Configure OpenSSH server. c.f. https://docs.docker.com/engine/examples/running_ssh_service -RUN mkdir /var/run/sshd -RUN echo 'root:root' | chpasswd -RUN sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config -RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config -EXPOSE 22 - -# Jupyter Notebook: Paddle book -EXPOSE 8888 - -COPY ./paddle/scripts/docker/entrypoint /opt/bin/ - -CMD ["/opt/bin/entrypoint"] diff --git a/paddle/scripts/docker/build.sh b/paddle/scripts/docker/build.sh index 668b6e6b84191..9f91d8b5715b1 100755 --- a/paddle/scripts/docker/build.sh +++ b/paddle/scripts/docker/build.sh @@ -7,7 +7,26 @@ function abort(){ trap 'abort' 0 set -e - +mkdir -p /paddle/dist/cpu +mkdir -p /paddle/dist/gpu +mkdir -p /paddle/dist/cpu-noavx +mkdir -p /paddle/dist/gpu-noavx +# Set BASE_IMAGE and DEB_PATH according to env variables +if [ ${WITH_GPU} == "ON" ]; then + BASE_IMAGE="nvidia/cuda:7.5-cudnn5-runtime-ubuntu14.04" + if [ ${WITH_AVX} == "ON" ]; then + DEB_PATH="dist/gpu/" + else + DEB_PATH="dist/gpu-noavx/" + fi +else + BASE_IMAGE="python:2.7.13-slim" + if [ ${WITH_AVX} == "ON" ]; then + DEB_PATH="dist/cpu/" + else + DEB_PATH="dist/cpu-noavx/" + fi +fi # If Dockerfile.* sets BUILD_AND_INSTALL to 'ON', it would have copied # source tree to /paddle, and this scripts should build it into # /paddle/build. @@ -29,9 +48,13 @@ if [[ ${BUILD_AND_INSTALL:-OFF} == 'ON' ]]; then -DCMAKE_EXPORT_COMPILE_COMMANDS=ON make -j `nproc` make install + # generate deb package for current build + # FIXME(typhoonzero): should we remove paddle/scripts/deb ? + cpack -D CPACK_GENERATOR='DEB' .. + mv /paddle/build/*.deb /paddle/${DEB_PATH} if [[ ${BUILD_WOBOQ:-OFF} == 'ON' ]]; then - apt-get install -y clang-3.8 llvm-3.8 libclang-3.8-dev + apt-get install -y clang-3.8 llvm-3.8 libclang-3.8-dev # Install woboq_codebrowser. git clone https://github.com/woboq/woboq_codebrowser /woboq cd /woboq @@ -65,4 +88,46 @@ if [[ ${BUILD_AND_INSTALL:-OFF} == 'ON' ]]; then fi fi +# generate production docker image Dockerfile +if [ ${USE_MIRROR} ]; then + MIRROR_UPDATE="sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \\" +else + MIRROR_UPDATE="\\" +fi + +cat > /paddle/build/Dockerfile < + +# ENV variables +ARG WITH_AVX +ARG WITH_DOC +ARG WITH_STYLE_CHECK + +ENV WITH_GPU=${WITH_GPU} +ENV WITH_AVX=\${WITH_AVX:-ON} +ENV WITH_DOC=\${WITH_DOC:-OFF} +ENV WITH_STYLE_CHECK=\${WITH_STYLE_CHECK:-OFF} + +ENV HOME /root +ENV LANG en_US.UTF-8 + +# Use Fix locales to en_US.UTF-8 + +RUN ${MIRROR_UPDATE} + apt-get update && \ + apt-get install -y libgfortran3 && \ + apt-get clean -y && \ + pip install --upgrade pip && \ + pip install -U 'protobuf==3.1.0' +RUN pip install numpy +# Use different deb file when building different type of images +ADD \$PWD/${DEB_PATH}*.deb /usr/local/opt/paddle/deb/ +RUN dpkg --force-all -i /usr/local/opt/paddle/deb/*.deb && rm -f /usr/local/opt/paddle/deb/*.deb + +ENV PATH="/usr/local/opt/paddle/bin/:${PATH}" +# default command shows the paddle version and exit +CMD ["paddle", "version"] +EOF + trap : 0 diff --git a/paddle/scripts/docker/buildall.sh b/paddle/scripts/docker/buildall.sh deleted file mode 100644 index 63e5301ad9188..0000000000000 --- a/paddle/scripts/docker/buildall.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -BUILD_DIR=$PWD/build -DEB_DIST_DIR=$PWD/dist -VERSION=latest - -function build_in_docker() { - if [ ! -d $BUILD_DIR ]; then - mkdir -p $BUILD_DIR - fi - if [ ! -d $DEB_DIST_DIR ]; then - mkdir -p $DEB_DIST_DIR - fi - docker build . -t paddle-build-env -f paddle/scripts/docker/paddle-dev/Dockerfile - # FIXME: need to wait a signal not sleeping - BUILDER=$(docker run -d -v ${PWD}:/root/paddle -v ${DEB_DIST_DIR}:/root/dist paddle-build-env sleep 3600) - # NOTICE: build deb files for real paddle image - docker exec $BUILDER /bin/bash -c "/root/paddle/paddle/scripts/deb/build_scripts/build.sh" - - docker stop $BUILDER && docker rm $BUILDER -} - -function build_paddle_core() { - docker build . -t paddle:$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile - docker build . -t paddle:gpu-$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile.gpu - docker build . -t paddle:cpu-noavx-$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile.noavx - docker build . -t paddle:gpu-noavx-$VERSION -f paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx -} - -build_in_docker -build_paddle_core diff --git a/paddle/scripts/docker/paddle-core/Dockerfile b/paddle/scripts/docker/paddle-core/Dockerfile deleted file mode 100644 index eade296a40121..0000000000000 --- a/paddle/scripts/docker/paddle-core/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -FROM python:2.7.13-slim -MAINTAINER PaddlePaddle Authors - -# ENV variables -ARG WITH_AVX -ARG WITH_DOC -ARG WITH_STYLE_CHECK - -ENV WITH_GPU=OFF -ENV WITH_AVX=${WITH_AVX:-ON} -ENV WITH_DOC=${WITH_DOC:-OFF} -ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} - -ENV HOME /root -ENV LANG en_US.UTF-8 - -# Use Fix locales to en_US.UTF-8 - -RUN sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \ - apt-get update && \ - apt-get install -y libgfortran3 && \ - apt-get clean -y && \ - pip install --upgrade pip && \ - pip install -U 'protobuf==3.1.0' -RUN pip install numpy -# Use different deb file when building different type of images -ADD dist/cpu/*.deb /usr/local/opt/paddle/deb/cpu/ -RUN dpkg --force-all -i /usr/local/opt/paddle/deb/cpu/*.deb && rm -f /usr/local/opt/paddle/deb/cpu/*.deb - -ENV PATH="/usr/local/opt/paddle/bin/:${PATH}" -# default command shows the paddle version and exit -CMD ["paddle", "version"] diff --git a/paddle/scripts/docker/paddle-core/Dockerfile.gpu b/paddle/scripts/docker/paddle-core/Dockerfile.gpu deleted file mode 100644 index 89386b0379ac1..0000000000000 --- a/paddle/scripts/docker/paddle-core/Dockerfile.gpu +++ /dev/null @@ -1,32 +0,0 @@ -FROM nvidia/cuda:7.5-cudnn5-runtime-ubuntu14.04 -MAINTAINER PaddlePaddle Authors - -# ENV variables -ARG WITH_AVX -ARG WITH_DOC -ARG WITH_STYLE_CHECK - -ENV WITH_GPU=OFF -ENV WITH_AVX=${WITH_AVX:-ON} -ENV WITH_DOC=${WITH_DOC:-OFF} -ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} - -ENV HOME /root -ENV LANG en_US.UTF-8 - -# Use Fix locales to en_US.UTF-8 - -RUN sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \ - apt-get update && \ - apt-get install -y python python-pip libgfortran3 && \ - apt-get clean -y && \ - pip install --upgrade pip && \ - pip install -U 'protobuf==3.1.0' -RUN pip install numpy -# Use different deb file when building different type of images -ADD dist/gpu/*.deb /usr/local/opt/paddle/deb/gpu/ -RUN dpkg --force-all -i /usr/local/opt/paddle/deb/gpu/*.deb && rm -f /usr/local/opt/paddle/deb/gpu/*.deb - -ENV PATH="/usr/local/opt/paddle/bin/:${PATH}" -# default command shows the paddle version and exit -CMD ["paddle", "version"] diff --git a/paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx b/paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx deleted file mode 100644 index beaeb5c51e044..0000000000000 --- a/paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx +++ /dev/null @@ -1,33 +0,0 @@ -FROM python:2.7.13-slim -MAINTAINER PaddlePaddle Authors - -# ENV variables -ARG WITH_AVX -ARG WITH_DOC -ARG WITH_STYLE_CHECK - -ENV WITH_GPU=OFF -ENV WITH_AVX=${WITH_AVX:-ON} -ENV WITH_DOC=${WITH_DOC:-OFF} -ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} - -ENV HOME /root -ENV LANG en_US.UTF-8 - -# Use Fix locales to en_US.UTF-8 - -RUN sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \ - apt-get update && \ - apt-get install -y libgfortran3 && \ - apt-get clean -y && \ - pip install --upgrade pip && \ - pip install -U 'protobuf==3.1.0' -RUN pip install numpy -# Use different deb file when building different type of images -ADD dist/gpu-noavx/*.deb /usr/local/opt/paddle/deb/gpu-noavx/ -RUN dpkg --force-all -i /usr/local/opt/paddle/deb/gpu-noavx/*.deb && rm -f /usr/local/opt/paddle/deb/gpu-noavx/*.deb - - -ENV PATH="/usr/local/opt/paddle/bin/:${PATH}" -# default command shows the paddle version and exit -CMD ["paddle", "version"] diff --git a/paddle/scripts/docker/paddle-core/Dockerfile.noavx b/paddle/scripts/docker/paddle-core/Dockerfile.noavx deleted file mode 100644 index 853dd7703acde..0000000000000 --- a/paddle/scripts/docker/paddle-core/Dockerfile.noavx +++ /dev/null @@ -1,32 +0,0 @@ -FROM nvidia/cuda:7.5-cudnn5-runtime-ubuntu14.04 -MAINTAINER PaddlePaddle Authors - -# ENV variables -ARG WITH_AVX -ARG WITH_DOC -ARG WITH_STYLE_CHECK - -ENV WITH_GPU=OFF -ENV WITH_AVX=${WITH_AVX:-ON} -ENV WITH_DOC=${WITH_DOC:-OFF} -ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} - -ENV HOME /root -ENV LANG en_US.UTF-8 - -# Use Fix locales to en_US.UTF-8 - -RUN sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \ - apt-get update && \ - apt-get install -y python python-pip libgfortran3 && \ - apt-get clean -y && \ - pip install --upgrade pip && \ - pip install -U 'protobuf==3.1.0' -RUN pip install numpy -# Use different deb file when building different type of images -ADD dist/cpu-noavx/*.deb /usr/local/opt/paddle/deb/cpu-noavx/ -RUN dpkg --force-all -i /usr/local/opt/paddle/deb/cpu-noavx/*.deb && rm -f /usr/local/opt/paddle/deb/cpu-noavx/*.deb - -ENV PATH="/usr/local/opt/paddle/bin/:${PATH}" -# default command shows the paddle version and exit -CMD ["paddle", "version"] diff --git a/paddle/scripts/docker/paddle-dev/Dockerfile b/paddle/scripts/docker/paddle-dev/Dockerfile deleted file mode 100644 index 11465a4ed8172..0000000000000 --- a/paddle/scripts/docker/paddle-dev/Dockerfile +++ /dev/null @@ -1,53 +0,0 @@ -# A image for building paddle binaries -# Use cuda devel base image for both cpu and gpu environment -FROM nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04 -MAINTAINER PaddlePaddle Authors - -ARG DEBIAN_FRONTEND=noninteractive -ARG UBUNTU_MIRROR -RUN /bin/bash -c 'if [[ -n ${UBUNTU_MIRROR} ]]; then sed -i 's#http://archive.ubuntu.com#${UBUNTU_MIRROR}#g' /etc/apt/sources.list; fi' - -# ENV variables -ARG BUILD_WOBOQ -ARG BUILD_AND_INSTALL -ARG WITH_AVX -ARG WITH_DOC -ARG WITH_STYLE_CHECK - -ENV BUILD_WOBOQ=${BUILD_WOBOQ:-OFF} -ENV BUILD_AND_INSTALL=${BUILD_AND_INSTALL:-OFF} -ENV WITH_GPU=OFF -ENV WITH_AVX=${WITH_AVX:-ON} -ENV WITH_DOC=${WITH_DOC:-OFF} -ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF} - -ENV HOME /root - -RUN apt-get update && \ - apt-get install -y git python-pip python-dev openssh-server bison && \ - apt-get install -y wget unzip tar xz-utils bzip2 gzip coreutils && \ - apt-get install -y curl sed grep graphviz libjpeg-dev zlib1g-dev && \ - apt-get install -y python-numpy python-matplotlib gcc g++ gfortran && \ - apt-get install -y automake locales clang-format-3.8 && \ - apt-get clean -y - -# git credential to skip password typing -RUN git config --global credential.helper store - -# Fix locales to en_US.UTF-8 -RUN localedef -i en_US -f UTF-8 en_US.UTF-8 - -RUN pip install --upgrade pip && \ - pip install -U 'protobuf==3.1.0' && \ - pip install -U wheel pillow BeautifulSoup && \ - pip install -U docopt PyYAML sphinx && \ - pip install -U sphinx-rtd-theme==0.1.9 recommonmark && \ - pip install -U pre-commit 'requests==2.9.2' jupyter - -RUN curl -sSL https://cmake.org/files/v3.4/cmake-3.4.1.tar.gz | tar -xz && \ - cd cmake-3.4.1 && ./bootstrap && make -j `nproc` && make install && \ - cd .. && rm -rf cmake-3.4.1 - -RUN apt-get install -y swig -# FIXME: wait a long time is OK -CMD ["sleep", "3600"] From 653c981df920cff7b1e7b194ddf5121f23614f15 Mon Sep 17 00:00:00 2001 From: "yi.wu" Date: Fri, 17 Mar 2017 16:09:26 +0800 Subject: [PATCH 7/9] tags for build docker image --- Dockerfile | 2 +- paddle/scripts/docker/build.sh | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b835cc52cbe25..8f3137df08875 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ MAINTAINER PaddlePaddle Authors ARG DEBIAN_FRONTEND=noninteractive ARG UBUNTU_MIRROR -RUN /bin/bash -c 'if [[ -n ${UBUNTU_MIRROR} ]]; then sed -i 's#http://archive.ubuntu.com#${UBUNTU_MIRROR}#g' /etc/apt/sources.list; fi' +RUN /bin/bash -c 'if [[ -n ${UBUNTU_MIRROR} ]]; then sed -i 's#http://archive.ubuntu.com/ubuntu#${UBUNTU_MIRROR}#g' /etc/apt/sources.list; fi' # ENV variables ARG BUILD_WOBOQ diff --git a/paddle/scripts/docker/build.sh b/paddle/scripts/docker/build.sh index 9f91d8b5715b1..b617865016dc2 100755 --- a/paddle/scripts/docker/build.sh +++ b/paddle/scripts/docker/build.sh @@ -16,15 +16,19 @@ if [ ${WITH_GPU} == "ON" ]; then BASE_IMAGE="nvidia/cuda:7.5-cudnn5-runtime-ubuntu14.04" if [ ${WITH_AVX} == "ON" ]; then DEB_PATH="dist/gpu/" + DOCKER_SUFFIX="gpu" else DEB_PATH="dist/gpu-noavx/" + DOCKER_SUFFIX="gpu-noavx" fi else BASE_IMAGE="python:2.7.13-slim" if [ ${WITH_AVX} == "ON" ]; then DEB_PATH="dist/cpu/" + DOCKER_SUFFIX="" else DEB_PATH="dist/cpu-noavx/" + DOCKER_SUFFIX="noavx" fi fi # If Dockerfile.* sets BUILD_AND_INSTALL to 'ON', it would have copied @@ -95,7 +99,7 @@ else MIRROR_UPDATE="\\" fi -cat > /paddle/build/Dockerfile < /paddle/build/Dockerfile.${DOCKER_SUFFIX} < From 0b4d4560460718337639d9ad122f4277c192c4bd Mon Sep 17 00:00:00 2001 From: "yi.wu" Date: Fri, 17 Mar 2017 20:55:57 +0800 Subject: [PATCH 8/9] add python requests, add DELETE_BUILD_CACHE arg --- paddle/scripts/docker/build.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/paddle/scripts/docker/build.sh b/paddle/scripts/docker/build.sh index b617865016dc2..1779a0753beef 100755 --- a/paddle/scripts/docker/build.sh +++ b/paddle/scripts/docker/build.sh @@ -25,7 +25,7 @@ else BASE_IMAGE="python:2.7.13-slim" if [ ${WITH_AVX} == "ON" ]; then DEB_PATH="dist/cpu/" - DOCKER_SUFFIX="" + DOCKER_SUFFIX="cpu" else DEB_PATH="dist/cpu-noavx/" DOCKER_SUFFIX="noavx" @@ -40,8 +40,11 @@ if [[ ${BUILD_AND_INSTALL:-OFF} == 'ON' ]]; then fi mkdir -p /paddle/build # -p means no error if exists + cd /paddle/build # clean local cmake and third_party cache - cd /paddle/build && rm -rf * && rm -rf ../third_party + if [ ${DELETE_BUILD_CACHE} == 'ON' ]; then + rm -rf * && rm -rf ../third_party + fi cmake .. \ -DWITH_DOC=${WITH_DOC:-OFF} \ -DWITH_GPU=${WITH_GPU:-OFF} \ @@ -54,7 +57,9 @@ if [[ ${BUILD_AND_INSTALL:-OFF} == 'ON' ]]; then make install # generate deb package for current build # FIXME(typhoonzero): should we remove paddle/scripts/deb ? - cpack -D CPACK_GENERATOR='DEB' .. + # FIXME: CPACK_DEBIAN_PACKAGE_DEPENDS removes all dev dependencies, must + # install them in docker + cpack -D CPACK_GENERATOR='DEB' -D CPACK_DEBIAN_PACKAGE_DEPENDS="" .. mv /paddle/build/*.deb /paddle/${DEB_PATH} if [[ ${BUILD_WOBOQ:-OFF} == 'ON' ]]; then @@ -123,7 +128,7 @@ RUN ${MIRROR_UPDATE} apt-get install -y libgfortran3 && \ apt-get clean -y && \ pip install --upgrade pip && \ - pip install -U 'protobuf==3.1.0' + pip install -U 'protobuf==3.1.0' requests RUN pip install numpy # Use different deb file when building different type of images ADD \$PWD/${DEB_PATH}*.deb /usr/local/opt/paddle/deb/ From e8d33bee479a1bd574875f8b5ca1463955d6323d Mon Sep 17 00:00:00 2001 From: "yi.wu" Date: Fri, 17 Mar 2017 21:25:19 +0800 Subject: [PATCH 9/9] gpu image dependencies --- paddle/scripts/docker/build.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/scripts/docker/build.sh b/paddle/scripts/docker/build.sh index 1779a0753beef..c44874eede03a 100755 --- a/paddle/scripts/docker/build.sh +++ b/paddle/scripts/docker/build.sh @@ -14,6 +14,8 @@ mkdir -p /paddle/dist/gpu-noavx # Set BASE_IMAGE and DEB_PATH according to env variables if [ ${WITH_GPU} == "ON" ]; then BASE_IMAGE="nvidia/cuda:7.5-cudnn5-runtime-ubuntu14.04" + # additional packages to install when building gpu images + GPU_DOCKER_PKG="python-pip" if [ ${WITH_AVX} == "ON" ]; then DEB_PATH="dist/gpu/" DOCKER_SUFFIX="gpu" @@ -125,7 +127,7 @@ ENV LANG en_US.UTF-8 RUN ${MIRROR_UPDATE} apt-get update && \ - apt-get install -y libgfortran3 && \ + apt-get install -y libgfortran3 ${GPU_DOCKER_PKG} && \ apt-get clean -y && \ pip install --upgrade pip && \ pip install -U 'protobuf==3.1.0' requests