Dockerfile.rocm 6.7 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 10
#        --build-arg ROCM_VERSION=4.0.1  \
#        -t paddlepaddle/paddle-centos-rocm401-dev:latest .
#
11 12
# docker run -it --device=/dev/kfd --device=/dev/dri \
# --security-opt seccomp=unconfined --group-add video \
13
# paddlepaddle/paddle-centos-rocm401-dev:latest /bin/bash
14

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

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

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

27
# Install devtoolset-7
28 29 30 31 32 33 34 35 36 37 38 39 40
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
41
WORKDIR /opt
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
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
ARG ROCM_VERSION
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 && \
    echo "baseurl=http://repo.radeon.com/rocm/yum/${ROCM_VERSION}" >> /etc/yum.repos.d/rocm.repo && \
    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
58 59 60 61 62 63
# 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
64
ENV LD_LIBRARY_PATH=/opt/rocm/lib:$LD_LIBRARY_PATH
65 66 67 68 69 70 71 72 73

# 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

74
ENV GOROOT=/usr/local/go
75 76 77 78 79
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 | \
80 81 82 83
    tar -xz -C /usr/local && \
    mkdir /root/gopath && \
    mkdir /root/gopath/bin && \
    mkdir /root/gopath/src
84 85

# protobuf 3.6.1
86
RUN cd /opt && wget -q --no-check-certificate https://paddle-ci.cdn.bcebos.com/protobuf-cpp-3.6.1.tar.gz && \
87 88 89 90 91 92 93 94
    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
RUN cd /opt && wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && chmod +x Miniconda3-latest-Linux-x86_64.sh
RUN mkdir /opt/conda && ./Miniconda3-latest-Linux-x86_64.sh -b -f -p "/opt/conda" && rm -rf Miniconda3-latest-Linux-x86_64.sh
ENV PATH=/opt/conda/bin:${PATH}
95
RUN conda init bash && conda install -n base jupyter 
96

97
# install Paddle requirement
98 99 100 101 102
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
103 104 105 106 107 108 109 110 111
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
112 113 114 115 116 117

# 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

118 119 120 121 122
# 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}

123 124 125 126 127 128 129
# 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

130 131 132 133
# 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
134 135

# ccache 3.7.9
136
RUN cd /opt && wget https://paddle-ci.gz.bcebos.com/ccache-3.7.9.tar.gz && \
137 138 139
    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 && \
140 141
    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
142

143 144 145 146 147 148 149 150
# 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

151
EXPOSE 22