Dockerfile.rocm 6.8 KB
Newer Older
1 2 3
# A image for building paddle binaries
# Use rocm-terminal base image for both rocm environment
# When you modify it, please be aware of rocm version
4 5
#
# Build: ROCM 4.0.1
6 7
# cd Paddle/tools/dockerfile
# docker build -f Dockerfile.rocm  \
8 9
#        -t paddlepaddle/paddle-centos-rocm401-dev:latest .
#
10 11
# docker run -it --device=/dev/kfd --device=/dev/dri \
# --security-opt seccomp=unconfined --group-add video \
12
# paddlepaddle/paddle-centos-rocm401-dev:latest /bin/bash
13

14
FROM centos:7.8.2003
15 16
MAINTAINER PaddlePaddle Authors <paddle-dev@baidu.com>

17 18 19 20
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

21
RUN yum install -y epel-release deltarpm sudo openssh-server gettext-devel sqlite-devel \
22
        zlib-devel openssl-devel pcre-devel vim tk-devel tkinter libtool xz graphviz wget curl-devel \
23
        make bzip2 git patch unzip bison yasm diffutils automake which file kernel-headers kernel-devel \
24
        net-tools numactl-devel chrpath screen initscripts
25

26
# Install devtoolset-7
27 28 29 30 31 32 33 34 35 36 37 38 39
RUN yum install -y yum-utils centos-release-scl && \
    yum-config-manager --enable rhel-server-rhscl-7-rpms && \
    yum-config-manager --enable rhel-7-server-rpms && \
    yum-config-manager --enable rhel-7-server-optional-rpms && \
    INSTALL_PKGS="devtoolset-7-binutils devtoolset-7-gcc devtoolset-7-gcc-c++ devtoolset-7-gcc-gfortran devtoolset-7-gdb" && \
    yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
    rpm -V $INSTALL_PKGS && \
    yum -y clean all --enablerepo='*'
ENV PATH=/opt/rh/devtoolset-7/root/usr/bin:$PATH
ENV LD_LIBRARY_PATH=/opt/rh/devtoolset-7/root/usr/lib64:/opt/rh/devtoolset-7/root/usr/lib:$LD_LIBRARY_PATH
RUN echo "source scl_source enable devtoolset-7" > "/etc/profile.d/devtoolset-7.sh"

# cmake 3.16.0
40
WORKDIR /opt
41 42 43 44 45 46 47 48 49
RUN wget -q https://cmake.org/files/v3.16/cmake-3.16.0-Linux-x86_64.tar.gz && \
    tar -zxvf cmake-3.16.0-Linux-x86_64.tar.gz && rm cmake-3.16.0-Linux-x86_64.tar.gz && \
    mv cmake-3.16.0-Linux-x86_64 cmake-3.16
ENV PATH=/opt/cmake-3.16/bin:${PATH}

# ROCM
RUN yum install -y kmod wget openblas-devel epel-release
RUN echo "[ROCm]" > /etc/yum.repos.d/rocm.repo && \
    echo "name=ROCm" >> /etc/yum.repos.d/rocm.repo && \
50
    echo "baseurl=http://repo.radeon.com/rocm/yum/4.0.1" >> /etc/yum.repos.d/rocm.repo && \
51 52 53 54 55
    echo "enabled=1" >> /etc/yum.repos.d/rocm.repo && \
    echo "gpgcheck=0" >> /etc/yum.repos.d/rocm.repo
RUN yum install -y rocm-dev rocm-utils rocfft miopen-hip rocblas hipsparse rocrand rccl hipcub rocthrust rocprofiler-dev roctracer-dev
# fix rocthrust
RUN sed -i '21 a #include <thrust/system/hip/config.h>' /opt/rocm/include/thrust/system/hip/detail/error.inl
56 57 58 59 60 61
# export ROCM env
ENV ROCM_PATH=/opt/rocm
ENV HIP_PATH=/opt/rocm/hip
ENV HIP_CLANG_PATH=/opt/rocm/llvm/bin
ENV PATH=/opt/rocm/bin:$PATH
ENV PATH=/opt/rocm/opencl/bin:$PATH
62
ENV LD_LIBRARY_PATH=/opt/rocm/lib:$LD_LIBRARY_PATH
63 64 65 66 67 68 69 70 71

# git 2.17.1
RUN cd /opt && wget -q https://paddle-ci.gz.bcebos.com/git-2.17.1.tar.gz && \
  tar -xvf git-2.17.1.tar.gz && \
  cd git-2.17.1 && \
  ./configure --with-openssl --prefix=/usr/local && \
  make -j8 && make install && \
  cd .. && rm -rf git-2.17.1.tar.gz && rm -rf git-2.17.1

72
ENV GOROOT=/usr/local/go
73 74 75 76 77
ENV GOPATH=/root/gopath
ENV PATH=${GOROOT}/bin:${GOPATH}/bin:${PATH}

# go 1.8.1
RUN wget --no-check-certificate -qO- https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz | \
78 79 80 81
    tar -xz -C /usr/local && \
    mkdir /root/gopath && \
    mkdir /root/gopath/bin && \
    mkdir /root/gopath/src
82 83

# protobuf 3.6.1
84
RUN cd /opt && wget -q --no-check-certificate https://paddle-ci.cdn.bcebos.com/protobuf-cpp-3.6.1.tar.gz && \
85 86 87 88 89
    tar xzf protobuf-cpp-3.6.1.tar.gz && \
    cd protobuf-3.6.1 && ./configure && make -j4 && make install && \
    cd .. && rm -f protobuf-cpp-3.6.1.tar.gz && rm -rf protobuf-3.6.1

# conda
90 91 92
ENV CONDA_FILE=Miniconda3-py37_4.9.2-Linux-x86_64.sh
RUN cd /opt && wget 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}
93
ENV PATH=/opt/conda/bin:${PATH}
94 95 96 97
RUN conda init bash && conda install -n base jupyter jupyterlab

# install pylint and pre-commit
RUN /opt/conda/bin/pip install pre-commit pylint pytest astroid isort protocol PyGithub
98

99
# install Paddle requirement
100 101 102 103 104
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
105 106 107 108 109 110 111 112 113
RUN /opt/conda/bin/pip install -r /root/requirements.txt && rm -rf /root/requirements.txt

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

# install PaddleDetection requirement
RUN wget https://raw.githubusercontent.com/PaddlePaddle/PaddleDetection/develop/requirements.txt -O /root/requirements.txt
RUN /opt/conda/bin/pip install -r /root/requirements.txt && rm -rf /root/requirements.txt
114 115 116 117 118 119

# configure ssh
RUN sed -i "s/^#PermitRootLogin/PermitRootLogin/" /etc/ssh/sshd_config && \
    sed -i "s/^#PubkeyAuthentication/PubkeyAuthentication/" /etc/ssh/sshd_config && \
    sed -i "s/^#RSAAuthentication/RSAAuthentication/" /etc/ssh/sshd_config

120 121 122 123 124
# clang-format 3.8
RUN wget https://copr.fedorainfracloud.org/coprs/alonid/llvm-3.8.0/repo/epel-7/alonid-llvm-3.8.0-epel-7.repo -P /etc/yum.repos.d/
RUN yum install -y clang-3.8.0
ENV PATH=/opt/llvm-3.8.0/bin:${PATH}

125 126 127 128 129 130 131
# patchelf
RUN yum install -y patchelf && \
    yum clean all && \
    rm -rf /var/cache/yum && \
    rm -rf /var/lib/yum/yumdb && \
    rm -rf /var/lib/yum/history

132 133 134 135
# swig 2.0.12
RUN wget -O /opt/swig-2.0.12.tar.gz https://sourceforge.net/projects/swig/files/swig/swig-2.0.12/swig-2.0.12.tar.gz/download && \
    cd /opt && tar xzf swig-2.0.12.tar.gz && cd /opt/swig-2.0.12 && ./configure && make && make install && \
    cd /opt && rm swig-2.0.12.tar.gz && rm -rf swig-2.0.12
136 137

# ccache 3.7.9
138
RUN cd /opt && wget https://paddle-ci.gz.bcebos.com/ccache-3.7.9.tar.gz && \
139 140 141
    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 && \
142 143
    ln -s /usr/local/ccache-3.7.9/bin/ccache /usr/local/bin/ccache && \
    cd .. && rm -rf ccache-3.7.9.tar.gz && rm -rf ccache-3.7.9
144

145 146 147 148 149 150 151 152
# configure ssh
RUN sed -i "s/^#PermitRootLogin/PermitRootLogin/" /etc/ssh/sshd_config && \
    sed -i "s/^#PubkeyAuthentication/PubkeyAuthentication/" /etc/ssh/sshd_config && \
    sed -i "s/^#RSAAuthentication/RSAAuthentication/" /etc/ssh/sshd_config && \
    sed -i "s/#UseDNS .*/UseDNS no/" /etc/ssh/sshd_config

RUN ssh-keygen -A

153
EXPOSE 22