From 545ff417d00bd8a99b797976f920a110bcbdd733 Mon Sep 17 00:00:00 2001 From: leonwanghui Date: Mon, 30 Mar 2020 11:54:01 +0800 Subject: [PATCH] Add dockerfile to build MindSpore docker images Signed-off-by: leonwanghui --- README.md | 21 ++++++++ docker/README.md | 23 ++++++++ docker/mindspore-cpu/Dockerfile | 80 ++++++++++++++++++++++++++++ docker/mindspore-cuda10.1/Dockerfile | 80 ++++++++++++++++++++++++++++ docker/mindspore-cuda9.2/Dockerfile | 80 ++++++++++++++++++++++++++++ 5 files changed, 284 insertions(+) create mode 100644 docker/README.md create mode 100644 docker/mindspore-cpu/Dockerfile create mode 100644 docker/mindspore-cuda10.1/Dockerfile create mode 100644 docker/mindspore-cuda9.2/Dockerfile diff --git a/README.md b/README.md index a367d48ded4..925c22591d8 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ - [Installation](#installation) - [Binaries](#binaries) - [From Source](#from-source) + - [Docker Image](#docker-image) - [Quickstart](#quickstart) - [Docs](#docs) - [Community](#community) @@ -87,6 +88,26 @@ For installation using pip, take `Ubuntu-x86` and `CPU` build version as an exam [Install MindSpore](https://www.mindspore.cn/install/en). +### Docker Image + +MindSpore docker image is hosted on [Docker Hub](https://hub.docker.com/r/mindspore), +currently the containerized build options are supported as follows: + +| Hardware Platform | Docker Image URL | +| :---------------- | :--------------- | +| CPU | `mindspore/mindspore-cpu:0.1.0-alpha` | +| GPU CUDA 9.2 | `mindspore/mindspore-cuda9.2:0.1.0-alpha` | +| GPU CUDA 10.1 | `mindspore/mindspore-cuda10.1:0.1.0-alpha` | +| Ascend |
| + +Take `CPU` for example, you can directly pull the image using the below command: +``` +docker pull mindspore/mindspore-cpu:0.1.0-alpha +``` + +If anyone wants to learn more about the build process of MindSpore docker images, +please check out `docker` folder for the details. + ## Quickstart See the [Quick Start](https://www.mindspore.cn/tutorial/en/0.1.0-alpha/quick_start/quick_start.html) diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000000..76eae12f88d --- /dev/null +++ b/docker/README.md @@ -0,0 +1,23 @@ +## MindSpore Dockerfile Repository + +This folder hosts all the `Dockerfile` to build MindSpore container images with various hardware platforms. + +### MindSpore docker build command + +* CPU + + ``` + cd mindspore-cpu && docker build . -t mindspore/mindspore-cpu:0.1.0-alpha + ``` + +* GPU (CUDA 9.2) + + ``` + cd mindspore-cuda9.2 && docker build . -t mindspore/mindspore-cuda9.2:0.1.0-alpha + ``` + +* GPU (CUDA 10.1) + + ``` + cd mindspore-cuda10.1 && docker build . -t mindspore/mindspore-cuda10.1:0.1.0-alpha + ``` diff --git a/docker/mindspore-cpu/Dockerfile b/docker/mindspore-cpu/Dockerfile new file mode 100644 index 00000000000..dea2fd21493 --- /dev/null +++ b/docker/mindspore-cpu/Dockerfile @@ -0,0 +1,80 @@ +FROM ubuntu:18.04 + +MAINTAINER leonwanghui + +# Set env +ENV PYTHON_ROOT_PATH /usr/local/python-3.7.5 +ENV CMAKE_ROOT_PATH /usr/local/cmake-3.14.1 +ENV PATH ${PYTHON_ROOT_PATH}/bin:${CMAKE_ROOT_PATH}/bin:/usr/local/bin:$PATH + +# Install base tools +RUN apt update \ + && DEBIAN_FRONTEND=noninteractive apt install -y \ + vim \ + wget \ + xz-utils \ + net-tools \ + openssh-client \ + git \ + subversion \ + ntpdate \ + tzdata \ + tcl \ + sudo + +# Install compile tools +RUN DEBIAN_FRONTEND=noninteractive apt install -y \ + gcc \ + g++ \ + make \ + libgmp-dev \ + patch \ + autoconf \ + libtool \ + automake \ + flex + +# Set bash +RUN echo "dash dash/sh boolean false" | debconf-set-selections +RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash + +# Install python (v3.7.5) +RUN apt install -y --no-install-recommends libffi-dev libssl-dev zlib1g-dev libbz2-dev libncurses5-dev libgdbm-dev liblzma-dev libreadline-dev \ + && cd /tmp \ + && wget https://github.com/python/cpython/archive/v3.7.5.tar.gz \ + && tar -xvf v3.7.5.tar.gz \ + && cd /tmp/cpython-3.7.5 \ + && mkdir -p ${PYTHON_ROOT_PATH} \ + && ./configure --prefix=${PYTHON_ROOT_PATH} \ + && make -j4 \ + && make install -j4 \ + && rm -f /usr/local/bin/python \ + && rm -f /usr/local/bin/pip \ + && ln -s ${PYTHON_ROOT_PATH}/bin/python3.7 /usr/local/bin/python \ + && ln -s ${PYTHON_ROOT_PATH}/bin/pip3.7 /usr/local/bin/pip \ + && rm -rf /tmp/cpython-3.7.5 \ + && rm -f /tmp/v3.7.5.tar.gz + +# Set pip source +RUN mkdir -pv /root/.pip \ + && echo "[global]" > /root/.pip/pip.conf \ + && echo "trusted-host=mirrors.aliyun.com" >> /root/.pip/pip.conf \ + && echo "index-url=http://mirrors.aliyun.com/pypi/simple/" >> /root/.pip/pip.conf + +# Install pip package +RUN pip install numpy \ + && pip install wheel \ + && pip install nose \ + && pip install pytest \ + && pip install pytest-xdist \ + && pip list + +# Install cmake (v3.14.1) +RUN cd /tmp \ + && wget https://github.com/Kitware/CMake/releases/download/v3.14.1/cmake-3.14.1-Linux-x86_64.sh \ + && mkdir -p ${CMAKE_ROOT_PATH} \ + && bash ./cmake-3.14.1-Linux-x86_64.sh --prefix=${CMAKE_ROOT_PATH} --exclude-subdir --skip-license \ + && rm -f /tmp/cmake-3.14.1-Linux-x86_64.sh + +# Install MindSpore cpu whl package +RUN pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/0.1.0-alpha/MindSpore/cpu/ubuntu-x86/mindspore-0.1.0-cp37-cp37m-linux_x86_64.whl diff --git a/docker/mindspore-cuda10.1/Dockerfile b/docker/mindspore-cuda10.1/Dockerfile new file mode 100644 index 00000000000..83b23ff8783 --- /dev/null +++ b/docker/mindspore-cuda10.1/Dockerfile @@ -0,0 +1,80 @@ +FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04 + +MAINTAINER leonwanghui + +# Set env +ENV PYTHON_ROOT_PATH /usr/local/python-3.7.5 +ENV CMAKE_ROOT_PATH /usr/local/cmake-3.14.1 +ENV PATH ${PYTHON_ROOT_PATH}/bin:${CMAKE_ROOT_PATH}/bin:/usr/local/bin:$PATH + +# Install base tools +RUN apt update \ + && DEBIAN_FRONTEND=noninteractive apt install -y \ + vim \ + wget \ + xz-utils \ + net-tools \ + openssh-client \ + git \ + subversion \ + ntpdate \ + tzdata \ + tcl \ + sudo + +# Install compile tools +RUN DEBIAN_FRONTEND=noninteractive apt install -y \ + gcc \ + g++ \ + make \ + libgmp-dev \ + patch \ + autoconf \ + libtool \ + automake \ + flex + +# Set bash +RUN echo "dash dash/sh boolean false" | debconf-set-selections +RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash + +# Install python (v3.7.5) +RUN apt install -y --no-install-recommends libffi-dev libssl-dev zlib1g-dev libbz2-dev libncurses5-dev libgdbm-dev liblzma-dev libreadline-dev \ + && cd /tmp \ + && wget https://github.com/python/cpython/archive/v3.7.5.tar.gz \ + && tar -xvf v3.7.5.tar.gz \ + && cd /tmp/cpython-3.7.5 \ + && mkdir -p ${PYTHON_ROOT_PATH} \ + && ./configure --prefix=${PYTHON_ROOT_PATH} \ + && make -j4 \ + && make install -j4 \ + && rm -f /usr/local/bin/python \ + && rm -f /usr/local/bin/pip \ + && ln -s ${PYTHON_ROOT_PATH}/bin/python3.7 /usr/local/bin/python \ + && ln -s ${PYTHON_ROOT_PATH}/bin/pip3.7 /usr/local/bin/pip \ + && rm -rf /tmp/cpython-3.7.5 \ + && rm -f /tmp/v3.7.5.tar.gz + +# Set pip source +RUN mkdir -pv /root/.pip \ + && echo "[global]" > /root/.pip/pip.conf \ + && echo "trusted-host=mirrors.aliyun.com" >> /root/.pip/pip.conf \ + && echo "index-url=http://mirrors.aliyun.com/pypi/simple/" >> /root/.pip/pip.conf + +# Install pip package +RUN pip install numpy \ + && pip install wheel \ + && pip install nose \ + && pip install pytest \ + && pip install pytest-xdist \ + && pip list + +# Install cmake (v3.14.1) +RUN cd /tmp \ + && wget https://github.com/Kitware/CMake/releases/download/v3.14.1/cmake-3.14.1-Linux-x86_64.sh \ + && mkdir -p ${CMAKE_ROOT_PATH} \ + && bash ./cmake-3.14.1-Linux-x86_64.sh --prefix=${CMAKE_ROOT_PATH} --exclude-subdir --skip-license \ + && rm -f /tmp/cmake-3.14.1-Linux-x86_64.sh + +# Install MindSpore cuda-10.1 whl package +RUN pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/0.1.0-alpha/MindSpore/gpu/cuda-10.1/mindspore-0.1.0-cp37-cp37m-linux_x86_64.whl diff --git a/docker/mindspore-cuda9.2/Dockerfile b/docker/mindspore-cuda9.2/Dockerfile new file mode 100644 index 00000000000..cbfcfd42ace --- /dev/null +++ b/docker/mindspore-cuda9.2/Dockerfile @@ -0,0 +1,80 @@ +FROM nvidia/cuda:9.2-cudnn7-devel-ubuntu18.04 + +MAINTAINER leonwanghui + +# Set env +ENV PYTHON_ROOT_PATH /usr/local/python-3.7.5 +ENV CMAKE_ROOT_PATH /usr/local/cmake-3.14.1 +ENV PATH ${PYTHON_ROOT_PATH}/bin:${CMAKE_ROOT_PATH}/bin:/usr/local/bin:$PATH + +# Install base tools +RUN apt update \ + && DEBIAN_FRONTEND=noninteractive apt install -y \ + vim \ + wget \ + xz-utils \ + net-tools \ + openssh-client \ + git \ + subversion \ + ntpdate \ + tzdata \ + tcl \ + sudo + +# Install compile tools +RUN DEBIAN_FRONTEND=noninteractive apt install -y \ + gcc \ + g++ \ + make \ + libgmp-dev \ + patch \ + autoconf \ + libtool \ + automake \ + flex + +# Set bash +RUN echo "dash dash/sh boolean false" | debconf-set-selections +RUN DEBIAN_FRONTEND=noninteractive dpkg-reconfigure dash + +# Install python (v3.7.5) +RUN apt install -y --no-install-recommends libffi-dev libssl-dev zlib1g-dev libbz2-dev libncurses5-dev libgdbm-dev liblzma-dev libreadline-dev \ + && cd /tmp \ + && wget https://github.com/python/cpython/archive/v3.7.5.tar.gz \ + && tar -xvf v3.7.5.tar.gz \ + && cd /tmp/cpython-3.7.5 \ + && mkdir -p ${PYTHON_ROOT_PATH} \ + && ./configure --prefix=${PYTHON_ROOT_PATH} \ + && make -j4 \ + && make install -j4 \ + && rm -f /usr/local/bin/python \ + && rm -f /usr/local/bin/pip \ + && ln -s ${PYTHON_ROOT_PATH}/bin/python3.7 /usr/local/bin/python \ + && ln -s ${PYTHON_ROOT_PATH}/bin/pip3.7 /usr/local/bin/pip \ + && rm -rf /tmp/cpython-3.7.5 \ + && rm -f /tmp/v3.7.5.tar.gz + +# Set pip source +RUN mkdir -pv /root/.pip \ + && echo "[global]" > /root/.pip/pip.conf \ + && echo "trusted-host=mirrors.aliyun.com" >> /root/.pip/pip.conf \ + && echo "index-url=http://mirrors.aliyun.com/pypi/simple/" >> /root/.pip/pip.conf + +# Install pip package +RUN pip install numpy \ + && pip install wheel \ + && pip install nose \ + && pip install pytest \ + && pip install pytest-xdist \ + && pip list + +# Install cmake (v3.14.1) +RUN cd /tmp \ + && wget https://github.com/Kitware/CMake/releases/download/v3.14.1/cmake-3.14.1-Linux-x86_64.sh \ + && mkdir -p ${CMAKE_ROOT_PATH} \ + && bash ./cmake-3.14.1-Linux-x86_64.sh --prefix=${CMAKE_ROOT_PATH} --exclude-subdir --skip-license \ + && rm -f /tmp/cmake-3.14.1-Linux-x86_64.sh + +# Install MindSpore cuda-9.2 whl package +RUN pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/0.1.0-alpha/MindSpore/gpu/cuda-9.2/mindspore-0.1.0-cp37-cp37m-linux_x86_64.whl