Skip to content

Commit

Permalink
Update cmake to 3.27 and upgrade Linux CUDA docker files from CentOS7…
Browse files Browse the repository at this point in the history
… to UBI8 (microsoft#16856)

### Description
1. Update docker files and their build instructions.
ARM64 and x86_64 can use the same docker file.

2. Upgrade Linux CUDA pipeline's base docker image from CentOS7 to UBI8
AB#18990
  • Loading branch information
snnn authored and kleiti committed Mar 22, 2024
1 parent 5f4d330 commit 3b76993
Show file tree
Hide file tree
Showing 62 changed files with 381 additions and 244 deletions.
4 changes: 2 additions & 2 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()

if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9)
message(FATAL_ERROR "GCC version must be greater than or equal to 9")
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 8)
message(FATAL_ERROR "GCC version must be greater than or equal to 8")
endif()

# Options
Expand Down
5 changes: 5 additions & 0 deletions cmake/adjust_global_compile_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ else()
string(APPEND CMAKE_CXX_FLAGS " -g -O0 --coverage ")
string(APPEND CMAKE_C_FLAGS " -g -O0 --coverage ")
endif()
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
# suppress warnings from flatbuffers
string(APPEND CMAKE_CXX_FLAGS " -Wno-restrict ")
string(APPEND CMAKE_C_FLAGS " -Wno-restrict ")
endif()
# Check support for AVX and f16c.
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-mf16c" COMPILER_SUPPORT_MF16C)
Expand Down
5 changes: 4 additions & 1 deletion cmake/onnxruntime_unittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function(AddTest)
else()
onnxruntime_add_executable(${_UT_TARGET} ${_UT_SOURCES})
endif()

if (_UT_DEPENDS)
list(REMOVE_DUPLICATES _UT_DEPENDS)
endif(_UT_DEPENDS)
Expand Down Expand Up @@ -202,11 +201,15 @@ function(AddTest)
WORKING_DIRECTORY $<TARGET_FILE_DIR:${_UT_TARGET}>
)
endif()
# Set test timeout to 3 hours.
set_tests_properties(${_UT_TARGET} PROPERTIES TIMEOUT 7200)
else()
add_test(NAME ${_UT_TARGET}
COMMAND ${_UT_TARGET} ${TEST_ARGS}
WORKING_DIRECTORY $<TARGET_FILE_DIR:${_UT_TARGET}>
)
# Set test timeout to 3 hours.
set_tests_properties(${_UT_TARGET} PROPERTIES TIMEOUT 7200)
endif()
endif()
endfunction(AddTest)
Expand Down
17 changes: 0 additions & 17 deletions dockerfiles/Dockerfile.arm32v7

This file was deleted.

17 changes: 0 additions & 17 deletions dockerfiles/Dockerfile.arm64

This file was deleted.

2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.cuda
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ MAINTAINER Changming Sun "chasun@microsoft.com"
ADD . /code

ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
RUN apt-get update && apt-get install -y --no-install-recommends python3-dev ca-certificates g++ python3-numpy gcc make git python3-setuptools python3-wheel python3-packaging python3-pip aria2 && aria2c -q -d /tmp -o cmake-3.26.3-linux-x86_64.tar.gz https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3-linux-x86_64.tar.gz && tar -zxf /tmp/cmake-3.26.3-linux-x86_64.tar.gz --strip=1 -C /usr
RUN apt-get update && apt-get install -y --no-install-recommends python3-dev ca-certificates g++ python3-numpy gcc make git python3-setuptools python3-wheel python3-packaging python3-pip aria2 && aria2c -q -d /tmp -o cmake-3.27.3-linux-x86_64.tar.gz https://github.com/Kitware/CMake/releases/download/v3.27.3/cmake-3.27.3-linux-x86_64.tar.gz && tar -zxf /tmp/cmake-3.27.3-linux-x86_64.tar.gz --strip=1 -C /usr

RUN cd /code && python3 -m pip install -r tools/ci_build/github/linux/docker/inference/x64/python/cpu/scripts/requireme\
nts.txt && /bin/bash ./build.sh --allow_running_as_root --skip_submodule_sync --cuda_home /usr/local/cuda --cudnn_home /usr/lib/x86_64-linux-gnu/ --use_cuda --config Release --build_wheel --update --build --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER) 'CMAKE_CUDA_ARCHITECTURES=52;60;61;70;75;86'
Expand Down
8 changes: 4 additions & 4 deletions dockerfiles/Dockerfile.migraphx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ RUN apt-get update &&\
apt-get install -y sudo git bash build-essential rocm-dev python3-dev python3-pip miopen-hip \
rocblas half aria2 libnuma-dev pkg-config

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

# Install rbuild
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.26.3-linux-x86_64/bin:${PATH}
ENV PATH /opt/miniconda/bin:/code/cmake-3.27.3-linux-x86_64/bin:${PATH}

# Install MIGraphX from source
RUN mkdir -p /migraphx
Expand Down
6 changes: 3 additions & 3 deletions dockerfiles/Dockerfile.openvino-centos7
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ RUN yum update -y && \
yum clean packages && yum clean all && rm -rf /var/cache/yum && \
# Install cmake
cd $MY_ROOT && \
wget https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3.tar.gz && \
tar -zxvf cmake-3.26.3.tar.gz && rm -rf cmake-3.26.3.tar.gz && \
cd cmake-3.26.3 && \
wget https://github.com/Kitware/CMake/releases/download/v3.27.3/cmake-3.27.3.tar.gz && \
tar -zxvf cmake-3.27.3.tar.gz && rm -rf cmake-3.27.3.tar.gz && \
cd cmake-3.27.3 && \
./bootstrap && \
make && \
make install && \
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.rocm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ARG ONNXRUNTIME_BRANCH=main

WORKDIR /code

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

# Prepare onnxruntime repository & build onnxruntime
RUN git clone --single-branch --branch ${ONNXRUNTIME_BRANCH} --recursive ${ONNXRUNTIME_REPO} onnxruntime &&\
Expand Down
10 changes: 5 additions & 5 deletions dockerfiles/Dockerfile.source
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
# --------------------------------------------------------------
# Dockerfile to run ONNXRuntime with source build for CPU

FROM ubuntu:22.04
FROM mcr.microsoft.com/cbl-mariner/base/python:3
MAINTAINER Changming Sun "chasun@microsoft.com"
ADD . /code

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends python3-dev ca-certificates g++ python3-numpy gcc make git python3-setuptools python3-wheel python3-pip aria2 && aria2c -q -d /tmp -o cmake-3.26.3-linux-x86_64.tar.gz https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3-linux-x86_64.tar.gz && tar -zxf /tmp/cmake-3.26.3-linux-x86_64.tar.gz --strip=1 -C /usr
RUN tdnf install -y tar ca-certificates build-essential python3-numpy cmake python3-setuptools python3-wheel python3-pip curl python3-devel
RUN /code/dockerfiles/scripts/install_cmake.sh

# Prepare onnxruntime repository & build onnxruntime
RUN cd /code && python3 -m pip install -r tools/ci_build/github/linux/docker/inference/x64/python/cpu/scripts/requirements.txt && /bin/bash ./build.sh --allow_running_as_root --skip_submodule_sync --config Release --build_wheel --update --build --parallel --cmake_extra_defines ONNXRUNTIME_VERSION=$(cat ./VERSION_NUMBER)

FROM ubuntu:22.04
FROM mcr.microsoft.com/cbl-mariner/base/python:3
COPY --from=0 /code/build/Linux/Release/dist /root
COPY --from=0 /code/dockerfiles/LICENSE-IMAGE.txt /code/LICENSE-IMAGE.txt
RUN apt-get update && apt-get install -y --no-install-recommends libstdc++6 ca-certificates python3-setuptools python3-wheel python3-pip unattended-upgrades && unattended-upgrade && python3 -m pip install /root/*.whl && rm -rf /root/*.whl
RUN tdnf install -y ca-certificates python3-setuptools python3-wheel python3-pip && python3 -m pip install /root/*.whl && rm -rf /root/*.whl
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.tensorrt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN apt-get update &&\
RUN unattended-upgrade

WORKDIR /code
ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:/code/cmake-3.26.3-linux-x86_64/bin:/opt/miniconda/bin:${PATH}
ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:/code/cmake-3.27.3-linux-x86_64/bin:/opt/miniconda/bin:${PATH}

# Prepare onnxruntime repository & build onnxruntime with TensorRT
RUN git clone --single-branch --branch ${ONNXRUNTIME_BRANCH} --recursive ${ONNXRUNTIME_REPO} onnxruntime &&\
Expand Down
4 changes: 2 additions & 2 deletions dockerfiles/Dockerfile.vitisai
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

ENV PATH /code/cmake-3.26.3-linux-x86_64/bin:$PATH
ENV PATH /code/cmake-3.27.3-linux-x86_64/bin:$PATH
ENV LD_LIBRARY_PATH /opt/xilinx/xrt/lib:$LD_LIBRARY_PATH

WORKDIR /code
Expand All @@ -41,4 +41,4 @@ RUN . $VAI_ROOT/conda/etc/profile.d/conda.sh &&\
/bin/sh ./build.sh --allow_running_as_root --config RelWithDebInfo --enable_pybind --build_wheel --use_vitisai --parallel --update --build --build_shared_lib &&\
pip install /code/onnxruntime/build/Linux/RelWithDebInfo/dist/*-linux_x86_64.whl &&\
cd .. &&\
rm -rf onnxruntime cmake-3.26.3-linux-x86_64
rm -rf onnxruntime cmake-3.27.3-linux-x86_64
34 changes: 14 additions & 20 deletions dockerfiles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
- OpenVINO: [Dockerfile](Dockerfile.openvino), [Instructions](#openvino)
- TensorRT: [Dockerfile](Dockerfile.tensorrt), [Instructions](#tensorrt)
- VitisAI: [Dockerfile](Dockerfile.vitisai)

**Platforms**
- ARM 32v7: [Dockerfile](Dockerfile.arm32v7), [Instructions](#arm-3264)
- ARM 64: [Dockerfile](Dockerfile.arm64), [Instructions](#arm-3264)
- NVIDIA Jetson TX1/TX2/Nano/Xavier: [Dockerfile](Dockerfile.jetson), [Instructions](#nvidia-jetson-tx1tx2nanoxavier)

**Other**
Expand All @@ -22,38 +18,36 @@
# Instructions

## CPU
**Ubuntu 22.04, CPU, Python Bindings**
**Mariner 2.0, CPU, Python Bindings**

1. Update submodules
```
git submodule update --init
```

2. Build the docker image from the Dockerfile in this repository.
```
1. Build the docker image from the Dockerfile in this repository.
```bash
docker build -t onnxruntime-source -f Dockerfile.source ..
```

3. Run the Docker image
2. Run the Docker image

```
```bash
docker run -it onnxruntime-source
```

## CUDA
**Ubuntu 20.04, CUDA 11.4, CuDNN 8**
The docker file supports both x86_64 and ARM64(aarch64). You may use docker's "--platform" parameter to explictly specify which CPU architecture you want to build. For example:
1. Update submodules
```
git submodule update --init
```bash
docker build --platform linux/arm64/v8 -f Dockerfile.source
```
However, we cannot build the code for 32-bit ARM in such a way since a 32-bit compiler/linker might not have enough memory to generate the binaries.
2. Build the docker image from the Dockerfile in this repository.
## CUDA
**Ubuntu 22.04, CUDA 12.1, CuDNN 8**
1. Build the docker image from the Dockerfile in this repository.
```
docker build -t onnxruntime-cuda -f Dockerfile.cuda ..
```
3. Run the Docker image
2. Run the Docker image
```
docker run --gpus all -it onnxruntime-cuda
Expand Down
23 changes: 0 additions & 23 deletions dockerfiles/scripts/install_centos_arm64.sh

This file was deleted.

11 changes: 11 additions & 0 deletions dockerfiles/scripts/install_cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e -x
mkdir -p /tmp/src
cd /tmp/src

echo "Installing cmake"
CPU_ARCH=`uname -m`
CMAKE_VERSION='3.27.3'
curl https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-$CPU_ARCH.tar.gz -sSL --retry 5 -o /tmp/src/cmake.tar.gz
tar -zxf /tmp/src/cmake.tar.gz --strip=1 -C /usr
rm -f /tmp/src/cmake.tar.gz
6 changes: 3 additions & 3 deletions dockerfiles/scripts/install_common_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ pip install "wheel>=0.35.1"
rm -rf /opt/miniconda/pkgs

# Dependencies: cmake
wget --quiet https://github.com/Kitware/CMake/releases/download/v3.26.3/cmake-3.26.3-linux-x86_64.tar.gz
tar zxf cmake-3.26.3-linux-x86_64.tar.gz
rm -rf cmake-3.26.3-linux-x86_64.tar.gz
wget --quiet https://github.com/Kitware/CMake/releases/download/v3.27.3/cmake-3.27.3-linux-x86_64.tar.gz
tar zxf cmake-3.27.3-linux-x86_64.tar.gz
rm -rf cmake-3.27.3-linux-x86_64.tar.gz
5 changes: 0 additions & 5 deletions dockerfiles/scripts/install_fedora_arm32.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tools/android_custom_build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN apt-get update && apt-get install --yes --no-install-recommends \
unzip lsb-release

# cmake
RUN CMAKE_VERSION=3.26.3 && \
RUN CMAKE_VERSION=3.27.3 && \
aria2c -q -d /tmp -o cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz \
--checksum=sha-256=28d4d1d0db94b47d8dfd4f7dec969a3c747304f4a28ddd6fd340f553f2384dc2 \
https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz && \
Expand Down
Loading

0 comments on commit 3b76993

Please sign in to comment.