|
1 |
| -# Docker Image for PaddlePaddle NPU |
| 1 | +# Docker Image for PaddlePaddle Ascend NPU |
2 | 2 |
|
3 |
| -FROM ubuntu:20.04 |
| 3 | +FROM <baseimg> |
4 | 4 | LABEL maintainer="PaddlePaddle Authors <paddle-dev@baidu.com>"
|
5 | 5 |
|
6 |
| -ENV DEBIAN_FRONTEND=noninteractive |
7 |
| - |
8 |
| -RUN apt-get update && apt-get install -y apt-utils |
9 |
| -RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime |
10 |
| -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata |
11 |
| -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 |
12 |
| -RUN apt-get update && apt-get install -y curl wget vim git unzip unrar tar ntp xz-utils libssl-dev bzip2 gzip make automake \ |
13 |
| - coreutils language-pack-zh-hans libsm6 libxext6 libxrender-dev libgl1-mesa-glx libsqlite3-dev libopenblas-dev liblapack3 \ |
14 |
| - bison libjpeg-dev zlib1g zlib1g-dev swig locales net-tools libtool numactl libnuma-dev liblzma-dev libbz2-dev libblas-dev \ |
15 |
| - openssl openssh-server libffi-dev pciutils libblas3 liblapack-dev libzstd-dev default-jre libgcc-s1 gcc g++ gfortran gdb |
16 |
| - |
17 |
| -# workdir |
18 |
| -WORKDIR /opt |
19 |
| - |
20 |
| -# GCC 8.4 |
21 |
| -RUN apt-get install -y gcc-8 g++-8 gfortran-8 |
22 |
| -RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90 && \ |
23 |
| - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 90 && \ |
24 |
| - update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-8 90 |
25 |
| - |
26 |
| -# cmake 3.27.7 |
27 |
| -RUN wget -q https://cmake.org/files/v3.27/cmake-3.27.7-linux-$(uname -m).sh && \ |
28 |
| - chmod +x cmake-3.27.7-linux-$(uname -m).sh && mkdir -p /opt/cmake-3.27.7 && \ |
29 |
| - ./cmake-3.27.7-linux-$(uname -m).sh --prefix=/opt/cmake-3.27.7 --skip-license && \ |
30 |
| - rm -rf cmake-3.27.7-linux-$(uname -m).sh |
31 |
| -ENV PATH=/opt/cmake-3.27.7/bin:${PATH} |
32 |
| - |
33 |
| -# default python version |
34 |
| -ARG PY_VERSION=3.10 |
35 |
| -RUN apt-get install -y python3-distutils python3.8 python3.8-dev python3.9 python3.9-dev python3.10 python3.10-dev |
36 |
| - |
37 |
| -# install pip |
38 |
| -RUN curl -s -q https://bootstrap.pypa.io/get-pip.py | /usr/bin/python3.8 && \ |
39 |
| - curl -s -q https://bootstrap.pypa.io/get-pip.py | /usr/bin/python3.9 && \ |
40 |
| - curl -s -q https://bootstrap.pypa.io/get-pip.py | /usr/bin/python3.10 |
41 |
| - |
42 |
| -# set default python |
43 |
| -RUN rm -rf /usr/bin/python3 && ln -s /usr/bin/python${PY_VERSION} /usr/bin/python3 && \ |
44 |
| - rm -rf /usr/bin/python && ln -s /usr/bin/python${PY_VERSION} /usr/bin/python |
45 |
| - |
46 |
| -# install pylint and pre-commit |
47 |
| -RUN pip3.8 install pre-commit==2.17.0 pylint pytest astroid isort coverage qtconsole distro && \ |
48 |
| - pip3.9 install pre-commit==2.17.0 pylint pytest astroid isort coverage qtconsole distro && \ |
49 |
| - pip3.10 install pre-commit==2.17.0 pylint pytest astroid isort coverage qtconsole distro |
50 |
| -RUN pip3.8 install attrs pyyaml pathlib2 scipy requests psutil Cython clang-format==13.0.0 && \ |
51 |
| - pip3.9 install attrs pyyaml pathlib2 scipy requests psutil Cython clang-format==13.0.0 && \ |
52 |
| - pip3.10 install attrs pyyaml pathlib2 scipy requests psutil Cython clang-format==13.0.0 |
53 |
| - |
54 |
| -# add more libs |
55 |
| -RUN apt-get update && apt-get install libprotobuf-dev protobuf-compiler libprotoc-dev lsof libgeos-dev \ |
56 |
| - pkg-config libhdf5-103 libhdf5-dev lrzsz libsndfile1 tree ninja-build -y |
57 |
| - |
58 |
| -# install Paddle requirement |
59 |
| -RUN wget --no-check-certificate https://raw.githubusercontent.com/PaddlePaddle/Paddle/develop/python/requirements.txt -O requirements.txt && \ |
60 |
| - pip3.8 install -r requirements.txt && \ |
61 |
| - pip3.9 install -r requirements.txt && \ |
62 |
| - pip3.10 install -r requirements.txt && rm -rf requirements.txt |
63 |
| - |
64 |
| -RUN wget --no-check-certificate https://raw.githubusercontent.com/PaddlePaddle/Paddle/develop/python/unittest_py/requirements.txt -O requirements.txt && \ |
65 |
| - pip3.8 install -r requirements.txt && \ |
66 |
| - pip3.9 install -r requirements.txt && \ |
67 |
| - pip3.10 install -r requirements.txt && rm -rf requirements.txt |
68 |
| - |
69 |
| -# git credential to skip password typing |
70 |
| -RUN git config --global credential.helper store |
71 |
| - |
72 |
| -# Fix locales to en_US.UTF-8 |
73 |
| -RUN localedef -i en_US -f UTF-8 en_US.UTF-8 |
74 |
| - |
75 |
| -# patchelf 0.14.5 - https://github.com/NixOS/patchelf/pull/216 |
76 |
| -RUN wget -q --no-check-certificate https://github.com/NixOS/patchelf/archive/refs/tags/0.14.5.tar.gz && \ |
77 |
| - tar xzf 0.14.5.tar.gz && cd patchelf-0.14.5 && \ |
78 |
| - ./bootstrap.sh > /dev/null && ./configure > /dev/null && \ |
79 |
| - make -j16 > /dev/null && make install > /dev/null && \ |
80 |
| - cd .. && rm -rf patchelf-0.14.5 && rm -rf 0.14.5.tar.gz |
81 |
| - |
82 |
| -# ccache 4.6.3 |
83 |
| -RUN wget -q https://github.com/ccache/ccache/releases/download/v4.6.3/ccache-4.6.3.tar.gz && \ |
84 |
| - tar xf ccache-4.6.3.tar.gz && mkdir /usr/local/ccache-4.6.3 && cd ccache-4.6.3 && \ |
85 |
| - mkdir build && cd build && \ |
86 |
| - cmake -DCMAKE_BUILD_TYPE=Release -DREDIS_STORAGE_BACKEND=OFF \ |
87 |
| - -DCMAKE_INSTALL_PREFIX=/usr/local/ccache-4.6.3 .. > /dev/null && \ |
88 |
| - make -j16 > /dev/null && make install > /dev/null && \ |
89 |
| - cd ../../ && rm -rf ccache-4.6.3.tar.gz && rm -rf ccache-4.6.3 && \ |
90 |
| - ln -s /usr/local/ccache-4.6.3/bin/ccache /usr/local/bin/ccache |
91 |
| - |
92 |
| -ENV CCACHE_MAXSIZE=80G \ |
93 |
| - CCACHE_LIMIT_MULTIPLE=0.8 \ |
94 |
| - CCACHE_SLOPPINESS=clang_index_store,time_macros,include_file_mtime |
95 |
| - |
96 |
| -# Configure OpenSSH server. c.f. https://docs.docker.com/engine/examples/running_ssh_service |
97 |
| -RUN mkdir /var/run/sshd && echo 'root:root' | chpasswd && \ |
98 |
| - sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config && \ |
99 |
| - sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config |
100 |
| -CMD source ~/.bashrc |
101 |
| - |
102 |
| -# /proc/sys/kernel/core_pattern |
103 |
| -RUN mkdir -p /var/core |
| 6 | + |
| 7 | + |
| 8 | +# HwHiAiUser |
| 9 | +RUN groupadd -g 1000 HwHiAiUser && \ |
| 10 | + useradd -u 1000 -g 1000 -m -d /home/HwHiAiUser HwHiAiUser |
| 11 | + |
| 12 | +RUN mkdir -p /usr/local/Ascend/driver |
| 13 | +WORKDIR /usr/local/Ascend |
| 14 | +ARG CANN_VERSION |
| 15 | +ARG SYSTEM |
| 16 | +ARG NPU_VERSION |
| 17 | + |
| 18 | +# install CANN requirement |
| 19 | +# https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/700alpha003/softwareinstall/instg/instg_0026.html |
| 20 | +RUN apt-get update -y && apt-get install -y zlib1g zlib1g-dev libsqlite3-dev openssl libssl-dev libffi-dev libbz2-dev \ |
| 21 | + libxslt1-dev unzip pciutils net-tools libblas-dev gfortran libblas3 liblapack-dev liblapack3 libopenblas-dev |
| 22 | + |
| 23 | +RUN pip3.8 install --upgrade pip setuptools wheel && \ |
| 24 | + pip3.9 install --upgrade pip setuptools wheel && \ |
| 25 | + pip3.10 install --upgrade pip setuptools wheel |
| 26 | + |
| 27 | +RUN pip3.8 install 'numpy>=1.19.2' 'decorator>=4.4.0' 'sympy>=1.5.1' 'cffi>=1.12.3' 'protobuf>=3.13.0' && \ |
| 28 | + pip3.9 install 'numpy>=1.19.2' 'decorator>=4.4.0' 'sympy>=1.5.1' 'cffi>=1.12.3' 'protobuf>=3.13.0' && \ |
| 29 | + pip3.10 install 'numpy>=1.19.2' 'decorator>=4.4.0' 'sympy>=1.5.1' 'cffi>=1.12.3' 'protobuf>=3.13.0' |
| 30 | + |
| 31 | +RUN pip3.8 install attrs pyyaml pathlib2 scipy requests psutil absl-py && \ |
| 32 | + pip3.9 install attrs pyyaml pathlib2 scipy requests psutil absl-py && \ |
| 33 | + pip3.10 install attrs pyyaml pathlib2 scipy requests psutil absl-py |
| 34 | + |
| 35 | +# update envs for driver |
| 36 | +ENV LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64:$LD_LIBRARY_PATH |
| 37 | +ENV LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64/common:$LD_LIBRARY_PATH |
| 38 | +ENV LD_LIBRARY_PATH=/usr/local/Ascend/driver/lib64/driver:$LD_LIBRARY_PATH |
| 39 | + |
| 40 | +# Install Ascend toolkit |
| 41 | +RUN wget -q --no-proxy https://paddle-ascend.bj.bcebos.com/cvmodel/ascend-materials/Ascend-cann-toolkit_${CANN_VERSION}_linux-${SYSTEM}.run --no-check-certificate && \ |
| 42 | + chmod +x Ascend-cann-toolkit_${CANN_VERSION}_linux-*.run && \ |
| 43 | + ./Ascend-cann-toolkit_${CANN_VERSION}_linux-*.run --install --quiet && \ |
| 44 | + echo "source /usr/local/Ascend/ascend-toolkit/set_env.sh" >>~/.bashrc && \ |
| 45 | + rm -rf Ascend-cann-toolkit_${CANN_VERSION}_linux-*.run |
| 46 | + |
| 47 | +# Install Ascend Kernels |
| 48 | +ARG ASCEND_KLS=Ascend-cann-kernels-${NPU_VERSION}_${CANN_VERSION}_linux-${SYSTEM}.run |
| 49 | +RUN wget -q --no-proxy https://paddle-ascend.bj.bcebos.com/cvmodel/ascend-materials/${ASCEND_KLS} --no-check-certificate && \ |
| 50 | + chmod +x ${ASCEND_KLS} && ./${ASCEND_KLS} --install --quiet && rm -rf ${ASCEND_KLS} |
| 51 | + |
| 52 | +# Install Ascend nnal |
| 53 | +RUN wget -q --no-proxy https://paddle-ascend.bj.bcebos.com/cvmodel/ascend-materials/Ascend-cann-nnal_${CANN_VERSION}_linux-${SYSTEM}.run --no-check-certificate && \ |
| 54 | + chmod +x Ascend-cann-nnal_${CANN_VERSION}_linux-${SYSTEM}.run && \ |
| 55 | + . /usr/local/Ascend/ascend-toolkit/set_env.sh && \ |
| 56 | + ./Ascend-cann-nnal_${CANN_VERSION}_linux-${SYSTEM}.run --install --quiet &&\ |
| 57 | + rm -rf Ascend-cann-nnal_${CANN_VERSION}_linux-${SYSTEM}.run && \ |
| 58 | + echo "source /usr/local/Ascend/nnal/atb/set_env.sh" >> /root/.bashrc |
| 59 | + |
| 60 | +# install post process ops |
| 61 | +RUN wget -q --no-proxy https://paddle-ascend.bj.bcebos.com/code-share-master.zip --no-check-certificate && \ |
| 62 | + . /usr/local/Ascend/ascend-toolkit/set_env.sh && \ |
| 63 | + unzip code-share-master.zip && \ |
| 64 | + cd code-share-master/build && bash build_ops.sh > /dev/null && \ |
| 65 | + chmod +x aie_ops.run && ./aie_ops.run --extract=/usr/local/Ascend/ && \ |
| 66 | + rm -rf /usr/local/Ascend/code-share-master |
| 67 | + |
| 68 | +# update env for ascendc |
| 69 | +ENV ASCEND_CUSTOM_OPP_PATH=/usr/local/Ascend/vendors/aie_ascendc |
| 70 | + |
| 71 | +# DEV image should open error level log |
| 72 | +# 0 debug; 1 info; 2 warning; 3 error; 4 null |
| 73 | +ENV ASCEND_GLOBAL_LOG_LEVEL=3 |
| 74 | + |
| 75 | +# environment for HCCL |
| 76 | +ENV HCCL_CONNECT_TIMEOUT=7200 |
| 77 | +ENV HCCL_WHITELIST_DISABLE=1 |
| 78 | +ENV HCCL_SECURITY_MODE=1 |
| 79 | +ENV HCCL_BUFFSIZE=120 |
| 80 | + |
| 81 | +# environment for PaddlePaddle |
| 82 | +ENV FLAGS_npu_storage_format=0 |
| 83 | +ENV FLAGS_use_stride_kernel=0 |
| 84 | +ENV FLAGS_allocator_strategy=naive_best_fit |
| 85 | +ENV PADDLE_XCCL_BACKEND=npu |
| 86 | + |
| 87 | +RUN rm -rf /usr/local/Ascend/driver |
104 | 88 |
|
105 | 89 | # Clean
|
106 | 90 | RUN apt-get clean -y
|
|
0 commit comments