From aca08255d2c2a9c7ca06ce4c53765b366f66a227 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Fri, 25 Nov 2016 22:05:45 -0800 Subject: [PATCH] Allow docker build to build from local Git commit. --- paddle/scripts/docker/Dockerfile.m4 | 40 +++++++++++++++---- paddle/scripts/docker/build.sh | 40 +++++-------------- paddle/scripts/docker/generate.sh | 60 ++++++----------------------- 3 files changed, 53 insertions(+), 87 deletions(-) mode change 100644 => 100755 paddle/scripts/docker/build.sh mode change 100644 => 100755 paddle/scripts/docker/generate.sh diff --git a/paddle/scripts/docker/Dockerfile.m4 b/paddle/scripts/docker/Dockerfile.m4 index e14493ed9e..7f08e66653 100644 --- a/paddle/scripts/docker/Dockerfile.m4 +++ b/paddle/scripts/docker/Dockerfile.m4 @@ -1,12 +1,36 @@ FROM PADDLE_BASE_IMAGE MAINTAINER PaddlePaddle Dev Team -COPY build.sh /root/ -ENV GIT_CHECKOUT=v0.9.0a0 + +# It is good to run apt-get install with Dockerfile RUN directive, +# because if the following invocation to /root/build.sh fails, `docker +# build` wouldn't have to re-install packages after we fix +# /root/build.sh. +RUN apt-get update && \ + apt-get install -y cmake libprotobuf-dev protobuf-compiler git \ + libgoogle-glog-dev libgflags-dev libatlas-dev libatlas3-base g++ m4 python-pip \ + python-protobuf python-numpy python-dev swig openssh-server \ + wget unzip python-matplotlib tar xz-utils bzip2 gzip coreutils \ + sed grep graphviz libjpeg-dev zlib1g-dev doxygen && \ + apt-get clean -y +RUN pip install BeautifulSoup docopt PyYAML pillow \ + 'sphinx>=1.4.0' sphinx_rtd_theme breathe recommonmark + ENV WITH_GPU=PADDLE_WITH_GPU -ENV IS_DEVEL=PADDLE_IS_DEVEL -ENV WITH_DEMO=PADDLE_WITH_DEMO -ENV PIP_INSTALL_ARGS "" -ENV PIP_GENERAL_ARGS "" -ENV USE_UBUNTU_MIRROR OFF ENV WITH_AVX=PADDLE_WITH_AVX -RUN cd /root/ && bash build.sh + +RUN mkdir /paddle +COPY . /paddle/ +COPY paddle/scripts/docker/build.sh /root/ +RUN /root/build.sh + +RUN echo 'export LD_LIBRARY_PATH=/usr/lib64:${LD_LIBRARY_PATH}' >> /etc/profile +RUN pip install /usr/local/opt/paddle/share/wheels/*.whl +RUN paddle version # print version after build + +# 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 +CMD ["/usr/sbin/sshd", "-D"] diff --git a/paddle/scripts/docker/build.sh b/paddle/scripts/docker/build.sh old mode 100644 new mode 100755 index ec5f3bd967..8e2e26b6ba --- a/paddle/scripts/docker/build.sh +++ b/paddle/scripts/docker/build.sh @@ -7,43 +7,21 @@ function abort(){ trap 'abort' 0 set -e -if [ ${USE_UBUNTU_MIRROR} == "ON" ]; then - sed -i 's#http://archive\.ubuntu\.com/ubuntu/#mirror://mirrors\.ubuntu\.com/mirrors\.txt#g'\ - /etc/apt/sources.list -fi -apt-get update -apt-get install -y cmake libprotobuf-dev protobuf-compiler git \ - libgoogle-glog-dev libgflags-dev libatlas-dev libatlas3-base g++ m4 python-pip\ - python-protobuf python-numpy python-dev swig if [ ${WITH_GPU} == 'ON' ]; then ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so /usr/lib/libcudnn.so fi -cd ~ -git clone https://github.com/baidu/Paddle.git paddle -cd paddle -git checkout ${GIT_CHECKOUT} -mkdir build -cd build -cmake .. -DWITH_DOC=OFF -DWITH_GPU=${WITH_GPU} -DWITH_SWIG_PY=ON\ - -DCUDNN_ROOT=/usr/ -DWITH_STYLE_CHECK=OFF -DWITH_AVX=${WITH_AVX} +mkdir -p /paddle/build # -p means no error if exists +cd /paddle/build +cmake .. \ + -DWITH_DOC=ON \ + -DWITH_GPU=${WITH_GPU} \ + -DWITH_AVX=${WITH_AVX} \ + -DWITH_SWIG_PY=ON \ + -DCUDNN_ROOT=/usr/ \ + -DWITH_STYLE_CHECK=OFF make -j `nproc` -# because durning make install, there are several warning, so set +e, do not cause abort make install -echo 'export LD_LIBRARY_PATH=/usr/lib64:${LD_LIBRARY_PATH}' >> /etc/profile -pip ${PIP_GENERAL_ARGS} install ${PIP_INSTALL_ARGS} /usr/local/opt/paddle/share/wheels/*.whl -paddle version # print version after build -if [ ${WITH_DEMO} == "ON" ]; then - apt-get install -y wget unzip perl python-matplotlib tar xz-utils bzip2 gzip coreutils\ - sed grep graphviz libjpeg-dev zlib1g-dev - pip ${PIP_GENERAL_ARGS} install ${PIP_INSTALL_ARGS} BeautifulSoup docopt \ - PyYAML pillow -fi -if [ ${IS_DEVEL} == "OFF" ]; then # clean build packages. - cd ~ - rm -rf paddle -fi -apt-get clean -y trap : 0 diff --git a/paddle/scripts/docker/generate.sh b/paddle/scripts/docker/generate.sh old mode 100644 new mode 100755 index 2ad7527db1..b808a62ec2 --- a/paddle/scripts/docker/generate.sh +++ b/paddle/scripts/docker/generate.sh @@ -1,60 +1,24 @@ #!/bin/bash + set -e cd `dirname $0` -m4 -DPADDLE_WITH_GPU=OFF -DPADDLE_IS_DEVEL=OFF -DPADDLE_WITH_DEMO=OFF \ - -DPADDLE_BASE_IMAGE=ubuntu:14.04 -DPADDLE_WITH_AVX=ON\ + +m4 -DPADDLE_WITH_GPU=OFF \ + -DPADDLE_WITH_AVX=ON \ + -DPADDLE_BASE_IMAGE=ubuntu:14.04 \ Dockerfile.m4 > Dockerfile.cpu -m4 -DPADDLE_WITH_GPU=OFF -DPADDLE_IS_DEVEL=OFF -DPADDLE_WITH_DEMO=OFF \ - -DPADDLE_BASE_IMAGE=ubuntu:14.04 -DPADDLE_WITH_AVX=OFF\ +m4 -DPADDLE_WITH_GPU=OFF \ + -DPADDLE_WITH_AVX=OFF \ + -DPADDLE_BASE_IMAGE=ubuntu:14.04 \ Dockerfile.m4 > Dockerfile.cpu-noavx -m4 -DPADDLE_WITH_GPU=OFF -DPADDLE_IS_DEVEL=ON -DPADDLE_WITH_DEMO=OFF \ - -DPADDLE_BASE_IMAGE=ubuntu:14.04 -DPADDLE_WITH_AVX=OFF\ - Dockerfile.m4 > Dockerfile.cpu-noavx-devel - -m4 -DPADDLE_WITH_GPU=OFF -DPADDLE_IS_DEVEL=ON -DPADDLE_WITH_DEMO=OFF \ - -DPADDLE_BASE_IMAGE=ubuntu:14.04 -DPADDLE_WITH_AVX=ON\ - Dockerfile.m4 > Dockerfile.cpu-devel - - -m4 -DPADDLE_WITH_GPU=OFF -DPADDLE_IS_DEVEL=ON -DPADDLE_WITH_DEMO=ON \ - -DPADDLE_BASE_IMAGE=ubuntu:14.04 -DPADDLE_WITH_AVX=ON\ - Dockerfile.m4 > Dockerfile.cpu-demo - -m4 -DPADDLE_WITH_GPU=OFF -DPADDLE_IS_DEVEL=ON -DPADDLE_WITH_DEMO=ON \ - -DPADDLE_BASE_IMAGE=ubuntu:14.04 -DPADDLE_WITH_AVX=OFF\ - Dockerfile.m4 > Dockerfile.cpu-noavx-demo - - -m4 -DPADDLE_WITH_GPU=ON -DPADDLE_IS_DEVEL=OFF -DPADDLE_WITH_DEMO=OFF \ - -DPADDLE_BASE_IMAGE=nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04 \ +m4 -DPADDLE_WITH_GPU=ON \ -DPADDLE_WITH_AVX=ON \ - Dockerfile.m4 > Dockerfile.gpu - -m4 -DPADDLE_WITH_GPU=ON -DPADDLE_IS_DEVEL=OFF -DPADDLE_WITH_DEMO=OFF \ -DPADDLE_BASE_IMAGE=nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04 \ - -DPADDLE_WITH_AVX=OFF \ - Dockerfile.m4 > Dockerfile.gpu-noavx - - -m4 -DPADDLE_WITH_GPU=ON -DPADDLE_IS_DEVEL=ON -DPADDLE_WITH_DEMO=OFF \ - -DPADDLE_BASE_IMAGE=nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04 \ - -DPADDLE_WITH_AVX=ON \ - Dockerfile.m4 > Dockerfile.gpu-devel + Dockerfile.m4 > Dockerfile.gpu -m4 -DPADDLE_WITH_GPU=ON -DPADDLE_IS_DEVEL=ON -DPADDLE_WITH_DEMO=OFF \ - -DPADDLE_BASE_IMAGE=nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04 \ +m4 -DPADDLE_WITH_GPU=ON \ -DPADDLE_WITH_AVX=OFF \ - Dockerfile.m4 > Dockerfile.gpu-noavx-devel - -m4 -DPADDLE_WITH_GPU=ON -DPADDLE_IS_DEVEL=ON -DPADDLE_WITH_DEMO=ON \ -DPADDLE_BASE_IMAGE=nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04 \ - -DPADDLE_WITH_AVX=ON \ - Dockerfile.m4 > Dockerfile.gpu-demo - - -m4 -DPADDLE_WITH_GPU=ON -DPADDLE_IS_DEVEL=ON -DPADDLE_WITH_DEMO=ON \ - -DPADDLE_BASE_IMAGE=nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04 \ - -DPADDLE_WITH_AVX=OFF \ - Dockerfile.m4 > Dockerfile.gpu-noavx-demo + Dockerfile.m4 > Dockerfile.gpu-noavx -- GitLab