未验证 提交 6a9b307e 编写于 作者: Q Qi Li 提交者: GitHub

[ROCM] add dockerfile for rocm3.5 and rocm3.9, test=develop (#29735)

* [ROCM] add rocm 3.5 and 3.9 dockefile, test=develop

* [ROCM] update rocm bin path, test=develop

* [ROCM] add dockerfile for rocm 3.5 amd 3.9, test=document_fix

* [ROCM] fix code stype failure, test=document_fix
上级 55725cd2
# 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
FROM ubuntu:18.04
MAINTAINER PaddlePaddle Authors <paddle-dev@baidu.com>
# ENV variables
ARG WITH_GPU
ARG WITH_ROCM_PLATFORM
ENV WITH_GPU=${WITH_GPU:-OFF}
ENV WITH_ROCM_PLATFORM=${WITH_ROCM_PLATFORM:-ON}
ENV HOME /root
ENV DEBIAN_FRONTEND=noninteractive
# Add bash enhancements
COPY paddle/scripts/docker/root/ /root/
# Update Environment
RUN apt-get update && apt-get upgrade -y
RUN apt-get update && apt-get install -y apt-utils sudo
# Update Timezone
RUN apt install tzdata && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone && \
dpkg-reconfigure -f noninteractive tzdata
# Location
RUN apt-get update && apt-get install -y locales && locale-gen en_US.UTF-8
ENV LANG="en_US.UTF-8"
ENV LANGUAGE="en_US.UTF-8"
ENV LC_ALL="en_US.UTF-8"
RUN apt-get update && \
apt-get install -y make cmake build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev openmpi-bin openmpi-doc libopenmpi-dev \
git vim texinfo patchelf openssl unzip pciutils net-tools python-pip python-dev \
python-opencv python-matplotlib
# Downgrade gcc&&g++
WORKDIR /usr/bin
COPY tools/dockerfile/build_scripts /build_scripts
RUN bash /build_scripts/install_gcc.sh gcc82 && rm -rf /build_scripts
RUN cp gcc gcc.bak && cp g++ g++.bak && rm gcc && rm g++ && \
ln -s /usr/local/gcc-8.2/bin/gcc /usr/local/bin/gcc && \
ln -s /usr/local/gcc-8.2/bin/g++ /usr/local/bin/g++ && \
ln -s /usr/local/gcc-8.2/bin/gcc /usr/bin/gcc && \
ln -s /usr/local/gcc-8.2/bin/g++ /usr/bin/g++
ENV PATH=/usr/local/gcc-8.2/bin:$PATH
# install cmake
WORKDIR /opt
RUN wget -q https://cmake.org/files/v3.16/cmake-3.16.0-Linux-x86_64.tar.gz && tar -zxf cmake-3.16.0-Linux-x86_64.tar.gz && rm cmake-3.16.0-Linux-x86_64.tar.gz
ENV PATH=/opt/cmake-3.16.0-Linux-x86_64/bin:$PATH
RUN echo "export PATH=/opt/cmake-3.16.0-Linux-x86_64/bin:\${PATH}" >> ~/.bashrc
# Install Go and glide
RUN wget -qO- https://paddle-ci.cdn.bcebos.com/go1.8.1.linux-amd64.tar.gz | \
tar -xz -C /usr/local && \
mkdir /root/gopath && \
mkdir /root/gopath/bin && \
mkdir /root/gopath/src
ENV GOROOT=/usr/local/go GOPATH=/root/gopath
# should not be in the same line with GOROOT definition, otherwise docker build could not find GOROOT.
ENV PATH=${PATH}:${GOROOT}/bin:${GOPATH}/bin
RUN echo "GOROOT=/usr/local/go" >> ~/.bashrc && \
echo "GOPATH=/root/gopath" >> ~/.bashrc && \
echo "export PATH=\${PATH}:\${GOROOT}/bin:\${GOPATH}/bin" >> ~/.bashrc
# install glide
RUN curl -s -q https://glide.sh/get | sh
# git credential to skip password typing
RUN git config --global credential.helper store
# Fix locales to en_US.UTF-8
RUN localedef -i en_US -f UTF-8 en_US.UTF-8
RUN apt-get update && \
apt-get install -y python2.7 python2.7-dev \
python3.6 python3.6-dev \
python3.7 python3.7-dev \
python3.8 python3.8-dev \
python3-distutils && \
curl https://bootstrap.pypa.io/get-pip.py -o - | python2.7 && \
curl https://bootstrap.pypa.io/get-pip.py -o - | python3.6 && \
curl https://bootstrap.pypa.io/get-pip.py -o - | python3.7 && \
curl https://bootstrap.pypa.io/get-pip.py -o - | python3.8 && \
rm /usr/bin/python && ln -s /usr/bin/python2.7 /usr/bin/python && \
rm /usr/bin/python3 && ln -s /usr/bin/python3.7 /usr/bin/python3 && \
rm /usr/local/bin/pip && ln -s /usr/local/bin/pip2.7 /usr/local/bin/pip && \
rm /usr/local/bin/pip3 && ln -s /usr/local/bin/pip3.7 /usr/local/bin/pip3
RUN pip3 --no-cache-dir install pre-commit==1.10.4 ipython==5.3.0 && \
pip3 --no-cache-dir install ipykernel==4.6.0 wheel && \
pip3.6 --no-cache-dir install pre-commit==1.10.4 ipython==5.3.0 && \
pip3.6 --no-cache-dir install ipykernel==4.6.0 wheel && \
pip3.8 --no-cache-dir install pre-commit==1.10.4 ipython==5.3.0 && \
pip3.8 --no-cache-dir install ipykernel==4.6.0 wheel && \
pip --no-cache-dir install pre-commit==1.10.4 ipython==5.3.0 && \
pip --no-cache-dir install ipykernel==4.6.0 wheel
#For docstring checker
RUN pip3 --no-cache-dir install pylint pytest astroid isort && \
pip3.6 --no-cache-dir install pylint pytest astroid isort && \
pip3.8 --no-cache-dir install pylint pytest astroid isort && \
pip --no-cache-dir install pylint pytest astroid isort
COPY ./python/requirements.txt /root/
RUN pip3 --no-cache-dir install -r /root/requirements.txt && \
pip3.6 --no-cache-dir install -r /root/requirements.txt && \
pip3.8 --no-cache-dir install -r /root/requirements.txt && \
pip --no-cache-dir install -r /root/requirements.txt
RUN apt-get install libprotobuf-dev -y
# Configure OpenSSH server. c.f. https://docs.docker.com/engine/examples/running_ssh_service
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd && echo 'root:root' | chpasswd && \
sed -ri 's/^#?PermitRootLogin\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config && \
sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
CMD source ~/.bashrc
# ccache 3.7.9
RUN wget https://paddle-ci.gz.bcebos.com/ccache-3.7.9.tar.gz && \
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 && \
ln -s /usr/local/ccache-3.7.9/bin/ccache /usr/local/bin/ccache
# Install ROCM Package
RUN wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add -
RUN echo 'deb [arch=amd64] https://repo.radeon.com/rocm/apt/<rocm_repo_version>/ xenial main' | tee /etc/apt/sources.list.d/rocm.list
RUN apt-get update && apt install rocm-dkms -y
# Install ROCM Libs
RUN apt-get update && apt-get install rocblas miopen-hip rocrand rccl -y
# rocPRIM
RUN wget https://github.com/ROCmSoftwarePlatform/rocPRIM/archive/rocm-<rocprim_version>.tar.gz && tar zxf rocm-<rocprim_version>.tar.gz && rm -rf rocm-<rocprim_version>.tar.gz && \
cd rocPRIM-rocm-<rocprim_version> && mkdir build && cd build && \
CXX=/opt/rocm/hip/bin/hipcc cmake .. && \
make -j8 && make install && \
cd .. && rm -rf rocPRIM-rocm-<rocprim_version>/
# rocThrust
RUN wget https://github.com/ROCmSoftwarePlatform/rocThrust/archive/rocm-<rocthrust_version>.tar.gz && tar zxf rocm-<rocthrust_version>.tar.gz && rm -rf rocm-<rocthrust_version>.tar.gz && \
cd rocThrust-rocm-<rocthrust_version> && mkdir build && cd build && \
CXX=/opt/rocm/hip/bin/hipcc cmake .. && \
make -j8 && make install && \
cd .. && rm -rf rocThrust-rocm-<rocthrust_version>/
# hipCUB
RUN wget https://github.com/ROCmSoftwarePlatform/hipCUB/archive/rocm-<hipcub_version>.tar.gz && tar zxf rocm-<hipcub_version>.tar.gz && rm -rf rocm-<hipcub_version>.tar.gz && \
cd hipCUB-rocm-<hipcub_version> && mkdir build && cd build && \
CXX=/opt/rocm/hip/bin/hipcc cmake .. && \
make -j8 && make install && \
cd .. && rm -rf hipCUB-rocm-<hipcub_version>/
ENV PATH=/opt/rocm/bin:$PATH
RUN echo "export PATH=/opt/rocm/bin:\${PATH}" >> ~/.bashrc
EXPOSE 22
\ No newline at end of file
#!/bin/bash
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
function rocm() {
# ROCM 3.3 - not work as rocthrust build fail without AMD GPU
# sed 's#<rocm_repo_version>#3.3#g' Dockerfile.rocm >test/rocm33.dockerfile
# sed -ri 's#<rocprim_version>#3.3.0#g' test/rocm33.dockerfile
# sed -ri 's#<rocthrust_version>#3.3.0#g' test/rocm33.dockerfile
# sed -ri 's#<hipcub_version>#3.3.0#g' test/rocm33.dockerfile
# ROCM 3.5
sed 's#<rocm_repo_version>#3.5.1#g' Dockerfile.rocm >test/rocm35.dockerfile
sed -ri 's#<rocprim_version>#3.5.1#g' test/rocm35.dockerfile
sed -ri 's#<rocthrust_version>#3.5.0#g' test/rocm35.dockerfile
sed -ri 's#<hipcub_version>#3.5.0#g' test/rocm35.dockerfile
# ROCM 3.9
sed 's#<rocm_repo_version>#3.9.1#g' Dockerfile.rocm >test/rocm39.dockerfile
sed -ri 's#<rocprim_version>#3.9.0#g' test/rocm39.dockerfile
sed -ri 's#<rocthrust_version>#3.9.0#g' test/rocm39.dockerfile
sed -ri 's#<hipcub_version>#3.9.0#g' test/rocm39.dockerfile
}
function main() {
if [ ! -d "test" ];then
mkdir test
fi
rocm
}
main
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册