Skip to content

Commit 3d7be97

Browse files
committed
speeding up the docker build by pararellizing the submodule fetch
Adding pack from the filesystem was moved to the bottom, so that it can be iterated on outside of the docker, without triggering a layer (and subsequent) layer rebuild. This speeds up the debug cycle
1 parent df58ff2 commit 3d7be97

File tree

2 files changed

+28
-34
lines changed

2 files changed

+28
-34
lines changed

opt/build/onnxruntime/Dockerfile.x64

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ ARG ONNXRUNTIME_VER=1.6.0
1010
ARG ARCH=x64
1111

1212
RUN apt-get -qq update
13-
RUN apt-get -qq install -y curl wget tar git
14-
RUN apt-get -qq install -y build-essential cmake
15-
RUN apt-get -qq install -y libcurl4-openssl-dev libssl-dev libatlas-base-dev zlib1g-dev
16-
17-
RUN apt-get -qq install -y python3 python3-pip python3-dev
13+
RUN apt-get -qq install -y curl wget tar git \
14+
build-essential cmake \
15+
libcurl4-openssl-dev libssl-dev libatlas-base-dev zlib1g-dev \
16+
python3 python3-pip python3-dev python3-numpy
1817
RUN pip3 install --upgrade pip setuptools wheel
19-
# RUN pip3 install numpy
20-
RUN apt-get -q install -y python3-numpy
2118

2219
ENV LANG=en_US.UTF-8
2320
RUN apt-get install -y locales && \
@@ -27,15 +24,16 @@ RUN apt-get install -y locales && \
2724

2825
WORKDIR /build
2926

30-
ADD ./pack.sh /build/
3127
ARG BUILDTYPE=MinSizeRel
3228
ARG BUILDARGS="--config ${BUILDTYPE} --parallel"
3329

34-
RUN git clone --single-branch --branch rel-${ONNXRUNTIME_VER} --recursive ${ONNXRUNTIME_REPO} onnxruntime
35-
36-
RUN cd onnxruntime ;\
37-
./build.sh ${BUILDARGS} --update --build ;\
38-
./build.sh ${BUILDARGS} --build_shared_lib
30+
RUN git clone --single-branch --branch rel-${ONNXRUNTIME_VER} ${ONNXRUNTIME_REPO} onnxruntime
31+
WORKDIR /build/onnxruntime
32+
RUN git fetch --recurse-submodules -j4
33+
RUN ./build.sh ${BUILDARGS} --update --build
34+
RUN ./build.sh ${BUILDARGS} --build_shared_lib
3935
# RUN ./build.sh ${BUILDARGS} --enable_pybind --build_wheel
4036

37+
ADD ./pack.sh /build
38+
WORKDIR /build
4139
RUN ./pack.sh ${ONNXRUNTIME_VER} ${ARCH}

opt/build/onnxruntime/Dockerfile.x64-gpu

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,18 @@ ARG ONNXRUNTIME_VER=1.6.0
88
ARG ARCH=x64-gpu
99

1010
RUN apt-get -qq update
11-
RUN apt-get -qq install -y curl wget tar git
12-
RUN apt-get -qq install -y build-essential
13-
RUN apt-get -qq install -y libcurl4-openssl-dev libssl-dev libatlas-base-dev zlib1g-dev
11+
RUN apt-get -qq install -y curl \
12+
wget tar git build-essential \
13+
libcurl4-openssl-dev libssl-dev \
14+
libatlas-base-dev zlib1g-dev python3 python3-pip \
15+
python3-dev python3-numpy rsync
1416

15-
RUN apt-get -qq install -y python3 python3-pip python3-dev
1617
RUN pip3 install --upgrade pip setuptools wheel
17-
# RUN pip3 install numpy
18-
RUN apt-get -q install -y python3-numpy
19-
RUN apt-get install -y snapd
20-
RUN wget https://github.com/Kitware/CMake/releases/download/v3.15.2/cmake-3.15.2.tar.gz; \
21-
tar -zxvf cmake-3.15.2.tar.gz; \
22-
cd cmake-3.15.2; \
23-
./bootstrap; \
24-
make -j4; \
25-
make install
18+
19+
RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.19.5/cmake-3.19.5-Linux-x86_64.tar.gz -O /tmp/cmake.tgz
20+
WORKDIR /tmp
21+
RUN tar -xpf cmake.tgz
22+
RUN rsync -aqH cmake*/* /usr
2623

2724

2825
ENV LANG=en_US.UTF-8
@@ -33,15 +30,14 @@ RUN apt-get install -y locales && \
3330

3431
WORKDIR /build
3532

36-
ADD ./pack.sh /build/
3733
ARG BUILDTYPE=MinSizeRel
3834
ARG BUILDARGS="--config ${BUILDTYPE} --parallel"
3935

40-
RUN git clone --single-branch --branch rel-${ONNXRUNTIME_VER} --recursive ${ONNXRUNTIME_REPO} onnxruntime
41-
36+
RUN git clone --single-branch --branch rel-${ONNXRUNTIME_VER} ${ONNXRUNTIME_REPO} onnxruntime
37+
WORKDIR /build/onnxruntime
38+
RUN git fetch --recurse-submodules -j4
39+
RUN ./build.sh ${BUILDARGS} --update --build --use_cuda --cudnn_home /usr/local/cuda --cuda_home /usr/local/cuda --build_shared_lib --parallel
4240

43-
RUN cd onnxruntime ;\
44-
./build.sh ${BUILDARGS} --update --build --use_cuda --cudnn_home /usr/local/cuda --cuda_home /usr/local/cuda --build_shared_lib --parallel
45-
# RUN ./build.sh ${BUILDARGS} --enable_pybind --build_wheel
46-
47-
RUN ./pack.sh ${ONNXRUNTIME_VER} ${ARCH}
41+
ADD ./pack.sh /build/
42+
WORKDIR /build
43+
RUN /pack.sh ${ONNXRUNTIME_VER} ${ARCH}

0 commit comments

Comments
 (0)