Dockerfile.rocm 6.3 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 3.9
6 7
# cd Paddle/tools/dockerfile
# docker build -f Dockerfile.rocm  \
8
#        --build-arg ROCM_VERSION=3.9  \
9 10 11 12
#        -t paddlepaddle/paddle-centos-rocm39-dev:latest .
# 
# docker run -it --device=/dev/kfd --device=/dev/dri \
# --security-opt seccomp=unconfined --group-add video \
13
# paddlepaddle/paddle-centos-rocm39-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 24 25
        zlib-devel openssl-devel pcre-devel vim tk-devel tkinter libtool xz graphviz wget curl-devel \
        make bzip2 git patch unzip bison yasm diffutils automake which file kernel-headers kernel-devel

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 50 51 52 53 54 55 56
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
57 58 59 60 61 62
# 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
63
ENV LD_LIBRARY_PATH=/opt/rocm/lib:$LD_LIBRARY_PATH
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

# 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

ENV GOROOT=/usr/local/go 
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 | \
79 80 81 82
    tar -xz -C /usr/local && \
    mkdir /root/gopath && \
    mkdir /root/gopath/bin && \
    mkdir /root/gopath/src
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115

# protobuf 3.6.1
RUN cd /opt && wget -q --no-check-certificate https://paddle-ci.cdn.bcebos.com/protobuf-cpp-3.6.1.tar.gz && \ 
    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}
RUN conda init bash && \
    conda create -n python2.7 python=2.7 && \
    conda create -n python3.7 python=3.7

# 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 && \
    /opt/conda/envs/python2.7/bin/pip install -r /root/requirements.txt && \
    /opt/conda/envs/python3.7/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 && \
    /opt/conda/envs/python2.7/bin/pip install -r /root/requirements.txt && \
    /opt/conda/envs/python3.7/bin/pip install -r /root/requirements.txt && \
    rm -rf /root/requirements.txt

# 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

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

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

# ccache 3.7.9
129
RUN cd /opt && wget https://paddle-ci.gz.bcebos.com/ccache-3.7.9.tar.gz && \
130 131 132
    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 && \
133 134
    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
135

136 137 138 139 140 141 142 143
# 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

144
EXPOSE 22