Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rocm_ep and migraphx_ep to rocm4.5.2 and fix dockerfiles to build docker images correctly #10445

Merged
merged 6 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions dockerfiles/Dockerfile.migraphx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ENV LANG C.UTF-8
# Install rocm
RUN apt-get update && apt-get install -y gnupg2 --no-install-recommends curl && \
curl -sL http://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - && \
sh -c 'echo deb [arch=amd64] http://repo.radeon.com/rocm/apt/4.5/ ubuntu main > /etc/apt/sources.list.d/rocm.list'
sh -c 'echo deb [arch=amd64] http://repo.radeon.com/rocm/apt/4.5.2/ ubuntu main > /etc/apt/sources.list.d/rocm.list'

RUN apt-get update &&\
apt-get install -y sudo git bash build-essential rocm-dev libpython3.6-dev python3-pip miopen-hip \
Expand All @@ -32,24 +32,28 @@ https://github.com/Kitware/CMake/releases/download/v3.21.0/cmake-3.21.0-linux-x8
tar -zxf /tmp/cmake-3.21.0-linux-x86_64.tar.gz --strip=1 -C /usr

# Install rbuild
RUN pip3 install https://github.com/RadeonOpenCompute/rbuild/archive/master.tar.gz
RUN pip3 install https://github.com/RadeonOpenCompute/rbuild/archive/master.tar.gz numpy yapf==0.28.0

ENV PATH /opt/miniconda/bin:/code/cmake-3.21.0-linux-x86_64/bin:${PATH}

# Install MIGraphX from source
RUN mkdir -p /migraphx
RUN cd /migraphx && git clone --depth=1 --branch migraphx_for_ort https://github.com/ROCmSoftwarePlatform/AMDMIGraphX src
RUN cd /migraphx && rbuild package --cxx /opt/rocm-4.5.0/llvm/bin/clang++ -d /migraphx/deps -B /migraphx/build -S /migraphx/src/ -DPYTHON_EXECUTABLE=/usr/bin/python3
RUN cd /migraphx && rbuild package --cxx /opt/rocm-4.5.2/llvm/bin/clang++ -d /migraphx/deps -B /migraphx/build -S /migraphx/src/ -DPYTHON_EXECUTABLE=/usr/bin/python3
RUN dpkg -i /migraphx/build/*.deb
RUN rm -rf /migraphx

# Install rocm ep dependencies
RUN apt-get update &&\
apt-get install -y rocrand rccl hipsparse hipfft hipcub hipblas rocthrust

WORKDIR /code

# Prepare onnxruntime repository & build onnxruntime
RUN git clone --single-branch --branch ${ONNXRUNTIME_BRANCH} --recursive ${ONNXRUNTIME_REPO} onnxruntime &&\
/bin/sh onnxruntime/dockerfiles/scripts/install_common_deps.sh &&\
cd onnxruntime &&\
/bin/sh ./build.sh --config Release --build_wheel --update --build --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) --use_migraphx &&\
pip install /code/onnxruntime/build/Linux/Release/dist/*.whl &&\
cd .. &&\
rm -rf onnxruntime cmake-3.21.0-linux-x86_64
cd onnxruntime &&\
/bin/sh ./build.sh --cmake_extra_defines ONNXRUNTIME_VERSION=`cat ./VERSION_NUMBER` --config Release --parallel \
--skip_tests --build_wheel --use_rocm --rocm_version=4.5.2 --rocm_home /opt/rocm --use_migraphx &&\
pip install /code/onnxruntime/build/Linux/Release/dist/*.whl

22 changes: 12 additions & 10 deletions dockerfiles/Dockerfile.rocm
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ ENV LANG C.UTF-8
# Install rocm
RUN apt-get update && apt-get install -y gnupg2 --no-install-recommends curl && \
curl -sL http://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - && \
sh -c 'echo deb [arch=amd64] http://repo.radeon.com/rocm/apt/4.0/ xenial main > /etc/apt/sources.list.d/rocm.list'
sh -c 'echo deb [arch=amd64] http://repo.radeon.com/rocm/apt/4.5.2/ ubuntu main > /etc/apt/sources.list.d/rocm.list'

RUN apt-get update &&\
apt-get install -y --no-install-recommends sudo git bash build-essential cmake libelf1 rocm-dkms libpython3.6-dev python3-pip miopen-hip rocblas\
libnuma-dev kmod half hipsparse rocfft hipblas
apt-get install -y sudo git bash build-essential rocm-dev libpython3.6-dev python3-pip miopen-hip rocblas half aria2 libnuma-dev

RUN aria2c -q -d /tmp -o cmake-3.20.0-linux-x86_64.tar.gz \
https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-linux-x86_64.tar.gz &&\
tar -zxf /tmp/cmake-3.20.0-linux-x86_64.tar.gz --strip=1 -C /usr

# Install yapf
RUN pip3 install yapf==0.28.0
RUN pip3 install yapf==0.28.0 numpy

ENV PATH /opt/miniconda/bin:/code/cmake-3.21.0-linux-x86_64/bin:${PATH}
ENV PATH /opt/miniconda/bin:/code/cmake-3.20.0-linux-x86_64/bin:${PATH}

# Install dependencies
COPY ./scripts/install_rocm_deps.sh /
RUN chmod +x /install_rocm_deps.sh && /install_rocm_deps.sh && rm /install_rocm_deps.sh
RUN apt-get update &&\
apt-get install -y rocrand rccl hipsparse hipfft hipcub hipblas rocthrust

WORKDIR /code

Expand All @@ -42,8 +45,7 @@ RUN git clone --single-branch --branch ${ONNXRUNTIME_BRANCH} --recursive ${ONNXR
/bin/sh onnxruntime/dockerfiles/scripts/install_common_deps.sh &&\
cd onnxruntime &&\
/bin/sh ./build.sh --config Release --build_wheel --update --build --parallel --cmake_extra_defines\
ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) --use_rocm --rocm_home=/opt/rocm &&\
ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) --use_rocm --rocm_home=/opt/rocm &&\
pip install /code/onnxruntime/build/Linux/Release/dist/*.whl &&\
cd .. &&\
rm -rf onnxruntime cmake-3.21.0-linux-x86_64
cd ..

55 changes: 30 additions & 25 deletions dockerfiles/scripts/install_rocm_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,73 @@ apt-get update && apt-get install -y --no-install-recommends \
python3-dev

# rocm-cmake
wget --quiet https://github.com/RadeonOpenCompute/rocm-cmake/archive/rocm-3.8.0.tar.gz
tar -xzvf rocm-3.8.0.tar.gz
rm rocm-3.8.0.tar.gz
cd rocm-cmake-rocm-3.8.0
rocm_cmake_version=4.5.2
wget --quiet https://github.com/RadeonOpenCompute/rocm-cmake/archive/refs/tags/rocm-${rocm_cmake_version}.tar.gz
tar -xzvf rocm-${rocm_cmake_version}.tar.gz
rm rocm-${rocm_cmake_version}.tar.gz
cd rocm-cmake-rocm-${rocm_cmake_version}
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=$prefix ..
make -j8
make install
cd ../..
rm -rf rocm-cmake-rocm-3.8.0
rm -rf rocm-cmake-rocm-${rocm_cmake_version}

# rccl
wget --quiet https://github.com/ROCmSoftwarePlatform/rccl/archive/rocm-4.0.0.tar.gz
tar -xzvf rocm-4.0.0.tar.gz
rm rocm-4.0.0.tar.gz
cd rccl-rocm-4.0.0
rccl_version=4.5.2
wget --quiet https://github.com/ROCmSoftwarePlatform/rccl/archive/refs/tags/rocm-${rccl_version}.tar.gz
tar -xzvf rocm-${rccl_version}.tar.gz
rm rocm-${rccl_version}.tar.gz
cd rccl-rocm-${rccl_version}
mkdir build
cd build
CXX=/opt/rocm/bin/hipcc cmake -DCMAKE_INSTALL_PREFIX=$prefix ..
make -j8
make install
cd ../..
rm -rf rccl-rocm-4.0.0
rm -rf rccl-rocm-${rccl_version}

#rocrand
wget --quiet https://github.com/ROCmSoftwarePlatform/rocRAND/archive/rocm-4.0.0.tar.gz
tar -xzvf rocm-4.0.0.tar.gz
rm rocm-4.0.0.tar.gz
cd rocRAND-rocm-4.0.0
rocrand_version=4.5.2
wget --quiet https://github.com/ROCmSoftwarePlatform/rocRAND/archive/refs/tags/rocm-${rocrand_version}.tar.gz
tar -xzvf rocm-${rocrand_version}.tar.gz
rm rocm-${rocrand_version}.tar.gz
cd rocRAND-rocm-${rocrand_version}
mkdir build
cd build
CXX=/opt/rocm/bin/hipcc cmake -DCMAKE_INSTALL_PREFIX=$prefix ..
make -j8
make install
cd ../..
rm -rf rocRAND-rocm-4.0.0
rm -rf rocRAND-rocm-${rocrand_version}

#hipcub
wget --quiet https://github.com/ROCmSoftwarePlatform/hipCUB/archive/rocm-4.0.0.tar.gz
tar -xzvf rocm-4.0.0.tar.gz
rm rocm-4.0.0.tar.gz
cd hipCUB-rocm-4.0.0
hipcub_version=4.5.2
wget --quiet https://github.com/ROCmSoftwarePlatform/hipCUB/archive/refs/tags/rocm-${hipcub_version}.tar.gz
tar -xzvf rocm-${hipcub_version}.tar.gz
rm rocm-${hipcub_version}.tar.gz
cd hipCUB-rocm-${hipcub_version}
mkdir build
cd build
CXX=/opt/rocm/bin/hipcc cmake -DCMAKE_INSTALL_PREFIX=$prefix ..
make -j8
make package
make install
cd ../..
rm -rf hipCUB-rocm-4.0.0
rm -rf hipCUB-rocm-${hipcub_version}

#rocprim
wget --quiet https://github.com/ROCmSoftwarePlatform/rocPRIM/archive/rocm-4.0.0.tar.gz
tar -xzvf rocm-4.0.0.tar.gz
rm rocm-4.0.0.tar.gz
cd rocPRIM-rocm-4.0.0
rocprim_version=4.5.2
wget --quiet https://github.com/ROCmSoftwarePlatform/rocPRIM/archive/refs/tags/rocm-${rocprim_version}.tar.gz
tar -xzvf rocm-${rocprim_version}.tar.gz
rm rocm-${rocprim_version}.tar.gz
cd rocPRIM-rocm-${rocprim_version}
mkdir build
cd build
CXX=/opt/rocm/bin/hipcc cmake -DCMAKE_INSTALL_PREFIX=$prefix ..
make -j8
make install
cd ../..
rm -rf rocPRIM-rocm-4.0.0
rm -rf rocPRIM-rocm-${rocprim_version}