Skip to content

Commit 1ab419a

Browse files
author
yi.wu
committed
new design: #1625
1 parent c1d5aaa commit 1ab419a

File tree

9 files changed

+73
-298
lines changed

9 files changed

+73
-298
lines changed

paddle/scripts/docker/Dockerfile.gpu renamed to Dockerfile

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# A image for building paddle binaries
2+
# Use cuda devel base image for both cpu and gpu environment
13
FROM nvidia/cuda:7.5-cudnn5-devel-ubuntu14.04
24
MAINTAINER PaddlePaddle Authors <[email protected]>
35

@@ -14,14 +16,12 @@ ARG WITH_STYLE_CHECK
1416

1517
ENV BUILD_WOBOQ=${BUILD_WOBOQ:-OFF}
1618
ENV BUILD_AND_INSTALL=${BUILD_AND_INSTALL:-OFF}
17-
ENV WITH_GPU=ON
19+
ENV WITH_GPU=OFF
1820
ENV WITH_AVX=${WITH_AVX:-ON}
1921
ENV WITH_DOC=${WITH_DOC:-OFF}
2022
ENV WITH_STYLE_CHECK=${WITH_STYLE_CHECK:-OFF}
21-
ENV DOCKER_BUILD=TRUE
2223

2324
ENV HOME /root
24-
2525
# Add bash enhancements
2626
COPY ./paddle/scripts/docker/root/ /root/
2727

@@ -50,9 +50,7 @@ RUN curl -sSL https://cmake.org/files/v3.4/cmake-3.4.1.tar.gz | tar -xz && \
5050
cd cmake-3.4.1 && ./bootstrap && make -j `nproc` && make install && \
5151
cd .. && rm -rf cmake-3.4.1
5252

53-
COPY . /paddle/
54-
RUN cd /paddle/ && git submodule update --init --recursive
55-
RUN /paddle/paddle/scripts/docker/build.sh
53+
RUN apt-get install -y swig
5654

5755
VOLUME ["/usr/share/nginx/html/data", "/usr/share/nginx/html/paddle"]
5856

@@ -63,9 +61,5 @@ RUN sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config
6361
RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
6462
EXPOSE 22
6563

66-
# Jupyter Notebook: Paddle book
67-
EXPOSE 8888
68-
69-
COPY ./paddle/scripts/docker/entrypoint /opt/bin/
70-
71-
CMD ["/opt/bin/entrypoint"]
64+
# development image default do build work
65+
CMD ["bash", "/paddle/paddle/scripts/docker/build.sh"]

paddle/scripts/docker/Dockerfile

Lines changed: 0 additions & 71 deletions
This file was deleted.

paddle/scripts/docker/build.sh

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,26 @@ function abort(){
77

88
trap 'abort' 0
99
set -e
10-
10+
mkdir -p /paddle/dist/cpu
11+
mkdir -p /paddle/dist/gpu
12+
mkdir -p /paddle/dist/cpu-noavx
13+
mkdir -p /paddle/dist/gpu-noavx
14+
# Set BASE_IMAGE and DEB_PATH according to env variables
15+
if [ ${WITH_GPU} == "ON" ]; then
16+
BASE_IMAGE="nvidia/cuda:7.5-cudnn5-runtime-ubuntu14.04"
17+
if [ ${WITH_AVX} == "ON" ]; then
18+
DEB_PATH="dist/gpu/"
19+
else
20+
DEB_PATH="dist/gpu-noavx/"
21+
fi
22+
else
23+
BASE_IMAGE="python:2.7.13-slim"
24+
if [ ${WITH_AVX} == "ON" ]; then
25+
DEB_PATH="dist/cpu/"
26+
else
27+
DEB_PATH="dist/cpu-noavx/"
28+
fi
29+
fi
1130
# If Dockerfile.* sets BUILD_AND_INSTALL to 'ON', it would have copied
1231
# source tree to /paddle, and this scripts should build it into
1332
# /paddle/build.
@@ -29,9 +48,13 @@ if [[ ${BUILD_AND_INSTALL:-OFF} == 'ON' ]]; then
2948
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
3049
make -j `nproc`
3150
make install
51+
# generate deb package for current build
52+
# FIXME(typhoonzero): should we remove paddle/scripts/deb ?
53+
cpack -D CPACK_GENERATOR='DEB' ..
54+
mv /paddle/build/*.deb /paddle/${DEB_PATH}
3255

3356
if [[ ${BUILD_WOBOQ:-OFF} == 'ON' ]]; then
34-
apt-get install -y clang-3.8 llvm-3.8 libclang-3.8-dev
57+
apt-get install -y clang-3.8 llvm-3.8 libclang-3.8-dev
3558
# Install woboq_codebrowser.
3659
git clone https://github.com/woboq/woboq_codebrowser /woboq
3760
cd /woboq
@@ -65,4 +88,46 @@ if [[ ${BUILD_AND_INSTALL:-OFF} == 'ON' ]]; then
6588
fi
6689
fi
6790

91+
# generate production docker image Dockerfile
92+
if [ ${USE_MIRROR} ]; then
93+
MIRROR_UPDATE="sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \\"
94+
else
95+
MIRROR_UPDATE="\\"
96+
fi
97+
98+
cat > /paddle/build/Dockerfile <<EOF
99+
FROM ${BASE_IMAGE}
100+
MAINTAINER PaddlePaddle Authors <[email protected]>
101+
102+
# ENV variables
103+
ARG WITH_AVX
104+
ARG WITH_DOC
105+
ARG WITH_STYLE_CHECK
106+
107+
ENV WITH_GPU=${WITH_GPU}
108+
ENV WITH_AVX=\${WITH_AVX:-ON}
109+
ENV WITH_DOC=\${WITH_DOC:-OFF}
110+
ENV WITH_STYLE_CHECK=\${WITH_STYLE_CHECK:-OFF}
111+
112+
ENV HOME /root
113+
ENV LANG en_US.UTF-8
114+
115+
# Use Fix locales to en_US.UTF-8
116+
117+
RUN ${MIRROR_UPDATE}
118+
apt-get update && \
119+
apt-get install -y libgfortran3 && \
120+
apt-get clean -y && \
121+
pip install --upgrade pip && \
122+
pip install -U 'protobuf==3.1.0'
123+
RUN pip install numpy
124+
# Use different deb file when building different type of images
125+
ADD \$PWD/${DEB_PATH}*.deb /usr/local/opt/paddle/deb/
126+
RUN dpkg --force-all -i /usr/local/opt/paddle/deb/*.deb && rm -f /usr/local/opt/paddle/deb/*.deb
127+
128+
ENV PATH="/usr/local/opt/paddle/bin/:${PATH}"
129+
# default command shows the paddle version and exit
130+
CMD ["paddle", "version"]
131+
EOF
132+
68133
trap : 0

paddle/scripts/docker/buildall.sh

Lines changed: 0 additions & 31 deletions
This file was deleted.

paddle/scripts/docker/paddle-core/Dockerfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

paddle/scripts/docker/paddle-core/Dockerfile.gpu

Lines changed: 0 additions & 32 deletions
This file was deleted.

paddle/scripts/docker/paddle-core/Dockerfile.gpunoavx

Lines changed: 0 additions & 33 deletions
This file was deleted.

paddle/scripts/docker/paddle-core/Dockerfile.noavx

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)