Dockerfile.npu_aarch64 9.1 KB
Newer Older
1
# A image for building paddle binaries
2 3
# Use cann 5.0.2.alpha005 and aarch64 for A300t-9000
# Update CANN_VERSION if using other versions
4
#
5 6 7
# Build: CANN 5.0.2.alpha005
# Download pkgs from https://www.hiascend.com/software/cann/community 
# and copy them to current dir first, then run build commands
8 9
# cd Paddle/tools/dockerfile
# docker build -f Dockerfile.npu_aarch64  \
10 11
# --build-arg CANN_VERSION=5.0.2.alpha005 \
# -t paddlepaddle/paddle:latest-dev-5.0.2.alpha005-gcc82-aarch64 .
12 13 14 15 16
#
# docker run -it --pids-limit 409600 \
# -v /usr/local/Ascend/driver:/usr/local/Ascend/driver \
# -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi \
# -v /usr/local/dcmi:/usr/local/dcmi \
17
# paddlepaddle/paddle:latest-dev-5.0.2.alpha005-gcc82-aarch64 /bin/bash
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

FROM ubuntu:18.04
MAINTAINER PaddlePaddle Authors <paddle-dev@baidu.com>

RUN apt-get update && apt-get install -y apt-utils
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
RUN apt-get update && apt-get install -y software-properties-common && add-apt-repository ppa:deadsnakes/ppa && add-apt-repository ppa:ubuntu-toolchain-r/test
RUN apt-get update && apt-get install -y curl wget vim git unzip unrar tar xz-utils libssl-dev bzip2 gzip make libgcc-s1 sudo openssh-server \
            coreutils ntp language-pack-zh-hans python-qt4 libsm6 libxext6 libxrender-dev libgl1-mesa-glx libsqlite3-dev libopenblas-dev \
            bison graphviz libjpeg-dev zlib1g zlib1g-dev automake locales swig net-tools libtool module-init-tools numactl libnuma-dev \
            openssl libffi-dev pciutils libblas-dev gfortran libblas3 liblapack-dev liblapack3 default-jre screen tmux gdb lldb gcc g++

# GCC 8.2
WORKDIR /opt
RUN wget -q https://paddle-ci.gz.bcebos.com/gcc-8.2.0.tar.xz && \
    tar -xvf gcc-8.2.0.tar.xz && cd gcc-8.2.0 && \
    unset LIBRARY_PATH CPATH C_INCLUDE_PATH PKG_CONFIG_PATH CPLUS_INCLUDE_PATH INCLUDE && \
    ./contrib/download_prerequisites && \
    cd .. && mkdir temp_gcc82 && cd temp_gcc82 && \
    ../gcc-8.2.0/configure --prefix=/opt/compiler/gcc-8.2 --enable-threads=posix --disable-checking --disable-multilib && \
    make -j8 && make install && \
    cd .. && rm -rf temp_gcc82 && rm -rf gcc-8.2.0* && \
    cd /usr/lib/aarch64-linux-gnu && \
    mv libstdc++.so.6 libstdc++.so.6.bak && mv libstdc++.so.6.0.25 libstdc++.so.6.0.25.bak && \
    ln -s /opt/compiler/gcc-8.2/lib64/libgfortran.so.5 /usr/lib/aarch64-linux-gnu/libstdc++.so.5 && \
    ln -s /opt/compiler/gcc-8.2/lib64/libstdc++.so.6   /usr/lib/aarch64-linux-gnu/libstdc++.so.6 && \
    cp /opt/compiler/gcc-8.2/lib64/libstdc++.so.6.0.25 /usr/lib/aarch64-linux-gnu && \
    cd /usr/bin && mv gcc gcc.bak && mv g++ g++.bak && \
    ln -s /opt/compiler/gcc-8.2/bin/gcc /usr/bin/gcc && \
    ln -s /opt/compiler/gcc-8.2/bin/g++ /usr/bin/g++
ENV PATH=/opt/compiler/gcc-8.2/bin:$PATH
ENV LD_LIBRARY_PATH=/opt/compiler/gcc-8.2/lib:/opt/compiler/gcc-8.2/lib64:$LD_LIBRARY_PATH

# cmake 3.19
WORKDIR /opt
RUN wget -q https://cmake.org/files/v3.19/cmake-3.19.8-Linux-aarch64.tar.gz && \
    tar -zxvf cmake-3.19.8-Linux-aarch64.tar.gz && rm cmake-3.19.8-Linux-aarch64.tar.gz && \
    mv cmake-3.19.8-Linux-aarch64 cmake-3.19
ENV PATH=/opt/cmake-3.19/bin:${PATH}

# conda 4.9.2
WORKDIR /opt
ARG CONDA_FILE=Miniconda3-py37_4.9.2-Linux-aarch64.sh
RUN cd /opt && wget -q https://repo.anaconda.com/miniconda/${CONDA_FILE} && chmod +x ${CONDA_FILE}
RUN mkdir /opt/conda && ./${CONDA_FILE} -b -f -p "/opt/conda" && rm -rf ${CONDA_FILE}
ENV PATH=/opt/conda/bin:${PATH}
RUN conda init bash && conda install -n base jupyter jupyterlab

# install pylint and pre-commit
RUN /opt/conda/bin/pip install pre-commit pylint pylint pytest astroid isort coverage qtconsole 
# install CANN 5.0.2 requirement
RUN /opt/conda/bin/pip install 'numpy<1.20,>=1.13.3' 'decorator>=4.4.0' 'sympy>=1.4' 'cffi>=1.12.3' 'protobuf>=3.11.3'
RUN /opt/conda/bin/pip install attrs pyyaml pathlib2 scipy requests psutil

# install Paddle requirement
RUN wget https://raw.githubusercontent.com/PaddlePaddle/Paddle/develop/python/requirements.txt -O /root/requirements.txt
RUN /opt/conda/bin/pip install -r /root/requirements.txt && rm -rf /root/requirements.txt
RUN wget https://raw.githubusercontent.com/PaddlePaddle/Paddle/develop/python/unittest_py/requirements.txt -O /root/requirements.txt
RUN /opt/conda/bin/pip install -r /root/requirements.txt && rm -rf /root/requirements.txt

# Install Go and glide
RUN wget -qO- https://golang.org/dl/go1.16.5.linux-arm64.tar.gz | \
    tar -xz -C /usr/local && \
    mkdir /root/gopath && \
    mkdir /root/gopath/bin && \
    mkdir /root/gopath/src
ENV GOROOT=/usr/local/go GOPATH=/root/gopath
# should not be in the same line with GOROOT definition, otherwise docker build could not find GOROOT.
ENV PATH=${PATH}:${GOROOT}/bin:${GOPATH}/bin
# install glide
RUN curl -s -q https://glide.sh/get | sh

# git credential to skip password typing
RUN git config --global credential.helper store

# Fix locales to en_US.UTF-8
RUN localedef -i en_US -f UTF-8 en_US.UTF-8

RUN apt-get install libprotobuf-dev -y

99 100
RUN apt install lsof -y

101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
# Older versions of patchelf limited the size of the files being processed and were fixed in this pr.
# https://github.com/NixOS/patchelf/commit/ba2695a8110abbc8cc6baf0eea819922ee5007fa
# So install a newer version here.
RUN wget -q http://ports.ubuntu.com/pool/universe/p/patchelf/patchelf_0.10-2build1_arm64.deb && \
    dpkg -i patchelf_0.10-2build1_arm64.deb && rm -rf patchelf_0.10-2build1_arm64.deb

# Configure OpenSSH server. c.f. https://docs.docker.com/engine/examples/running_ssh_service
RUN mkdir /var/run/sshd && echo 'root:root' | chpasswd && sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config && sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
CMD source ~/.bashrc

# ccache 3.7.9
RUN wget https://paddle-ci.gz.bcebos.com/ccache-3.7.9.tar.gz && \
    tar xf ccache-3.7.9.tar.gz && mkdir /usr/local/ccache-3.7.9 && cd ccache-3.7.9 && \
    ./configure -prefix=/usr/local/ccache-3.7.9 && \
    make -j8 && make install && cd .. && rm -rf ccache-3.7.9* && \
    ln -s /usr/local/ccache-3.7.9/bin/ccache /usr/local/bin/ccache

# clang-form 3.8.0
RUN wget https://releases.llvm.org/3.8.0/clang+llvm-3.8.0-aarch64-linux-gnu.tar.xz && \ 
    tar xf clang+llvm-3.8.0-aarch64-linux-gnu.tar.xz && cd clang+llvm-3.8.0-aarch64-linux-gnu && \
    cp -r * /usr/local && cd .. && rm -rf clang+llvm-3.8.0-aarch64-linux-gnu*

# HwHiAiUser
RUN groupadd HwHiAiUser && \
    useradd -g HwHiAiUser -m -d /home/HwHiAiUser HwHiAiUser

# copy /etc/ascend_install.info to current dir fist
COPY ascend_install.info /etc/ascend_install.info

# copy /usr/local/Ascend/driver/version.info to current dir fist
RUN mkdir -p /usr/local/Ascend/driver
COPY version.info /usr/local/Ascend/driver/version.info

134
# Download packages from https://www.hiascend.com/software/cann/community and copy them to current dir first
135
WORKDIR /usr/local/Ascend
136
ARG CANN_VERSION=5.0.2.alpha005
137 138 139 140 141 142
# update envs for driver
ENV LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64:$LD_LIBRARY_PATH
ENV LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64/common:$LD_LIBRARY_PATH
ENV LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64/driver:$LD_LIBRARY_PATH

# Install Ascend toolkit
143 144 145 146
COPY Ascend-cann-toolkit_${CANN_VERSION}_linux-aarch64.run /usr/local/Ascend/
RUN chmod +x Ascend-cann-toolkit_${CANN_VERSION}_linux-aarch64.run && \
    ./Ascend-cann-toolkit_${CANN_VERSION}_linux-aarch64.run --install --quiet && \
    rm -rf Ascend-cann-toolkit_${CANN_VERSION}_linux-aarch64.run
147 148 149 150 151 152 153 154 155
# udpate envs for model transformation and operator develop
ENV PATH=/usr/local/Ascend/ascend-toolkit/latest/atc/bin:$PATH
ENV LD_LIBRARY_PATH=/usr/local/Ascend/ascend-toolkit/latest/atc/lib64:$LD_LIBRARY_PATH
ENV PYTHONPATH=/usr/local/Ascend/ascend-toolkit/latest/pyACL/python/site-packages/acl:$PYTHONPATH
ENV PYTHONPATH=/usr/local/Ascend/ascend-toolkit/latest/atc/python/site-packages:$PYTHONPATH
ENV PYTHONPATH=/usr/local/Ascend/ascend-toolkit/latest/toolkit/python/site-packages:$PYTHONPATH
ENV TOOLCHAIN_HOME=/usr/local/Ascend/ascend-toolkit/latest/toolkit

# Install Ascend NNAE
156 157 158 159
COPY Ascend-cann-nnae_${CANN_VERSION}_linux-aarch64.run /usr/local/Ascend/
RUN chmod +x Ascend-cann-nnae_${CANN_VERSION}_linux-aarch64.run && \
    ./Ascend-cann-nnae_${CANN_VERSION}_linux-aarch64.run --install --quiet && \
    rm -rf Ascend-cann-nnae_${CANN_VERSION}_linux-aarch64.run
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184

# update envs for third party AI framework develop
ENV PATH=/usr/local/Ascend/nnae/latest/fwkacllib/bin:$PATH
ENV PATH=/usr/local/Ascend/nnae/latest/fwkacllib/ccec_compiler/bin:$PATH
ENV LD_LIBRARY_PATH=/usr/local/Ascend/nnae/latest/fwkacllib/lib64:$LD_LIBRARY_PATH
ENV PYTHONPATH=/usr/local/Ascend/nnae/latest/fwkacllib/python/site-packages:$PYTHONPATH
ENV ASCEND_AICPU_PATH=/usr/local/Ascend/nnae/latest
ENV ASCEND_OPP_PATH=/usr/local/Ascend/nnae/latest/opp

# DEV image should open error level log
# 0 debug; 1 info; 2 warning; 3 error; 4 null
ENV ASCEND_GLOBAL_LOG_LEVEL=3
RUN rm -rf /usr/local/Ascend/driver

# Create /lib64/ld-linux-aarch64.so.1
RUN umask 0022 && \
    if [ ! -d "/lib64" ]; \
    then \
        mkdir /lib64 && ln -sf /lib/ld-linux-aarch64.so.1 /lib64/ld-linux-aarch64.so.1; \
    fi

# Clean
RUN apt-get clean -y

EXPOSE 22