Skip to content

Commit 1dbabb2

Browse files
authored
Update dockerfiles (microsoft#5929)
1. Remove conda from the images. Because conda contains a file named /opt/miniconda/lib/libcrypto.so.1.0.0 which can't pass our security scan. Also, it will be easier for us to manage the third party usage registrations. 2. Remove openssh from the images. Because the official openssh package provided by Ubuntu can't pass our security scan. 3. Reduce the image size to 1/3 by using stages. Also, because it contains less packages, it will be less often needed to update. 4. Put the LICENSE-IMAGE.txt file in right place. It is missed in current images. You can see it was added to a temp folder "/code" but it got deleted afterwards. 5. Update the CPU docker image's base image to Ubuntu 18.04. The GPU one is already 18.04. It's better to keep them the same. 6. Remove the build arg ONNXRUNTIME_REPO/ONNXRUNTIME_BRANCH. Instead, the new one always uses the local source. I feel it can reduce confusion.
1 parent c5b4d90 commit 1dbabb2

File tree

4 files changed

+26
-42
lines changed

4 files changed

+26
-42
lines changed

.dockerignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.git
22
.gitignore
33
.gitattributes
4-
docs
54

dockerfiles/Dockerfile.cuda

+12-20
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,19 @@
66

77
# nVidia cuda 10.2 Base Image
88
FROM nvidia/cuda:10.2-cudnn8-devel
9-
MAINTAINER Vinitra Swamy "[email protected]"
9+
MAINTAINER Changming Sun "[email protected]"
10+
ADD . /code
1011

11-
ARG ONNXRUNTIME_REPO=https://github.com/Microsoft/onnxruntime
12-
ARG ONNXRUNTIME_BRANCH=master
13-
14-
RUN apt-get update &&\
15-
apt-get install -y sudo git bash unattended-upgrades
12+
ENV DEBIAN_FRONTEND=noninteractive
13+
RUN apt-get update && apt-get install -y --no-install-recommends python3-dev ca-certificates g++ python3-numpy gcc make git python3-setuptools python3-wheel python3-pip unattended-upgrades
1614
RUN unattended-upgrade
1715

18-
WORKDIR /code
19-
ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:/code/cmake-3.14.3-Linux-x86_64/bin:/opt/miniconda/bin:${PATH}
20-
ENV LD_LIBRARY_PATH /opt/miniconda/lib:$LD_LIBRARY_PATH
16+
ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
17+
RUN apt-get update && apt-get install -y --no-install-recommends python3-dev ca-certificates g++ python3-numpy gcc make git python3-setuptools python3-wheel python3-pip aria2 && aria2c -q -d /tmp -o cmake-3.18.2-Linux-x86_64.tar.gz https://github.com/Kitware/CMake/releases/download/v3.18.2/cmake-3.18.2-Linux-x86_64.tar.gz && tar -zxf /tmp/cmake-3.18.2-Linux-x86_64.tar.gz --strip=1 -C /usr
18+
19+
RUN cd /code && /bin/bash ./build.sh --skip_submodule_sync --cuda_home /usr/local/cuda --cudnn_home /usr/lib/x86_64-linux-gnu/ --use_cuda --config Release --build_wheel --update --build --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) 'CMAKE_CUDA_ARCHITECTURES=30;37;50;52;60;70'
2120

22-
# Prepare onnxruntime repository & build onnxruntime with CUDA
23-
RUN git clone --single-branch --branch ${ONNXRUNTIME_BRANCH} --recursive ${ONNXRUNTIME_REPO} onnxruntime &&\
24-
/bin/sh onnxruntime/dockerfiles/scripts/install_common_deps.sh &&\
25-
cp onnxruntime/docs/Privacy.md /code/Privacy.md &&\
26-
cp onnxruntime/ThirdPartyNotices.txt /code/ThirdPartyNotices.txt &&\
27-
cp onnxruntime/dockerfiles/LICENSE-IMAGE.txt /code/LICENSE-IMAGE.txt &&\
28-
cd onnxruntime &&\
29-
/bin/sh ./build.sh --cuda_home /usr/local/cuda --cudnn_home /usr/lib/x86_64-linux-gnu/ --use_cuda --config Release --build_wheel --update --build --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) &&\
30-
pip install /code/onnxruntime/build/Linux/Release/dist/*.whl &&\
31-
cd .. &&\
32-
rm -rf onnxruntime cmake-3.14.3-Linux-x86_64
21+
FROM nvidia/cuda:10.2-cudnn8-runtime
22+
COPY --from=0 /code/build/Linux/Release/dist /root
23+
COPY --from=0 /code/dockerfiles/LICENSE-IMAGE.txt /code/LICENSE-IMAGE.txt
24+
RUN apt-get update && apt-get install -y --no-install-recommends libstdc++6 ca-certificates python3-setuptools python3-wheel python3-pip && python3 -m pip install /root/*.whl && rm -rf /root/*.whl

dockerfiles/Dockerfile.source

+11-18
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,17 @@
44
# --------------------------------------------------------------
55
# Dockerfile to run ONNXRuntime with source build for CPU
66

7-
# Ubuntu 16.04 Base Image
8-
FROM ubuntu:16.04
9-
MAINTAINER Vinitra Swamy "[email protected]"
7+
FROM ubuntu:18.04
8+
MAINTAINER Changming Sun "[email protected]"
9+
ADD . /code
1010

11-
ARG ONNXRUNTIME_REPO=https://github.com/Microsoft/onnxruntime
12-
ARG ONNXRUNTIME_SERVER_BRANCH=master
13-
14-
RUN apt-get update &&\
15-
apt-get install -y sudo git bash
16-
17-
WORKDIR /code
18-
ENV PATH /opt/miniconda/bin:/code/cmake-3.14.3-Linux-x86_64/bin:${PATH}
11+
ENV DEBIAN_FRONTEND=noninteractive
12+
RUN apt-get update && apt-get install -y --no-install-recommends python3-dev ca-certificates g++ python3-numpy gcc make git python3-setuptools python3-wheel python3-pip aria2 && aria2c -q -d /tmp -o cmake-3.18.2-Linux-x86_64.tar.gz https://github.com/Kitware/CMake/releases/download/v3.18.2/cmake-3.18.2-Linux-x86_64.tar.gz && tar -zxf /tmp/cmake-3.18.2-Linux-x86_64.tar.gz --strip=1 -C /usr
1913

2014
# Prepare onnxruntime repository & build onnxruntime
21-
RUN git clone --single-branch --branch ${ONNXRUNTIME_SERVER_BRANCH} --recursive ${ONNXRUNTIME_REPO} onnxruntime &&\
22-
/bin/sh onnxruntime/dockerfiles/scripts/install_common_deps.sh &&\
23-
cd onnxruntime &&\
24-
/bin/sh ./build.sh --use_openmp --config Release --build_wheel --update --build --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) &&\
25-
pip install /code/onnxruntime/build/Linux/Release/dist/*.whl &&\
26-
cd .. &&\
27-
rm -rf onnxruntime cmake-3.14.3-Linux-x86_64
15+
RUN cd /code && /bin/bash ./build.sh --skip_submodule_sync --use_openmp --config Release --build_wheel --update --build --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER)
16+
17+
FROM ubuntu:18.04
18+
COPY --from=0 /code/build/Linux/Release/dist /root
19+
COPY --from=0 /code/dockerfiles/LICENSE-IMAGE.txt /code/LICENSE-IMAGE.txt
20+
RUN apt-get update && apt-get install -y --no-install-recommends libstdc++6 libgomp1 ca-certificates python3-setuptools python3-wheel python3-pip && python3 -m pip install /root/*.whl && rm -rf /root/*.whl

dockerfiles/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Use `docker pull` with any of the images and tags below to pull an image and try
4141

4242
1. Build the docker image from the Dockerfile in this repository.
4343
```
44-
docker build -t onnxruntime-source -f Dockerfile.source .
44+
docker build -t onnxruntime-source -f Dockerfile.source ..
4545
```
4646

4747
2. Run the Docker image
@@ -51,11 +51,11 @@ Use `docker pull` with any of the images and tags below to pull an image and try
5151
```
5252

5353
## CUDA
54-
**Ubuntu 16.04, CUDA 10.0, CuDNN 7**
54+
**Ubuntu 18.04, CUDA 10.2, CuDNN 8**
5555

5656
1. Build the docker image from the Dockerfile in this repository.
5757
```
58-
docker build -t onnxruntime-cuda -f Dockerfile.cuda .
58+
docker build -t onnxruntime-cuda -f Dockerfile.cuda ..
5959
```
6060

6161
2. Run the Docker image

0 commit comments

Comments
 (0)