diff --git a/build.py b/build.py index 2a9b2469fc..eb390b0319 100755 --- a/build.py +++ b/build.py @@ -116,7 +116,8 @@ def fail_if(p, msg): def target_platform(): - if FLAGS.target_platform is not None: + # When called by compose.py, FLAGS will be None + if FLAGS and FLAGS.target_platform is not None: return FLAGS.target_platform platform_string = platform.system().lower() if platform_string == "linux": @@ -132,7 +133,8 @@ def target_platform(): def target_machine(): - if FLAGS.target_machine is not None: + # When called by compose.py, FLAGS will be None + if FLAGS and FLAGS.target_machine is not None: return FLAGS.target_machine return platform.machine().lower() @@ -639,13 +641,16 @@ def pytorch_cmake_args(images): cmake_backend_arg("pytorch", "TRITON_PYTORCH_DOCKER_IMAGE", None, image), ] - if FLAGS.enable_gpu: + # TODO: TPRD-372 TorchTRT extension is not currently supported by our manylinux build + # TODO: TPRD-373 NVTX extension is not currently supported by our manylinux build + if target_platform() != "rhel": + if FLAGS.enable_gpu: + cargs.append( + cmake_backend_enable("pytorch", "TRITON_PYTORCH_ENABLE_TORCHTRT", True) + ) cargs.append( - cmake_backend_enable("pytorch", "TRITON_PYTORCH_ENABLE_TORCHTRT", True) + cmake_backend_enable("pytorch", "TRITON_ENABLE_NVTX", FLAGS.enable_nvtx) ) - cargs.append( - cmake_backend_enable("pytorch", "TRITON_ENABLE_NVTX", FLAGS.enable_nvtx) - ) return cargs @@ -899,6 +904,203 @@ def install_dcgm_libraries(dcgm_version, target_machine): ) +def create_dockerfile_buildbase_rhel(ddir, dockerfile_name, argmap): + df = """ +ARG TRITON_VERSION={} +ARG TRITON_CONTAINER_VERSION={} +ARG BASE_IMAGE={} +""".format( + argmap["TRITON_VERSION"], + argmap["TRITON_CONTAINER_VERSION"], + argmap["BASE_IMAGE"], + ) + + df += """ +FROM ${BASE_IMAGE} + +ARG TRITON_VERSION +ARG TRITON_CONTAINER_VERSION +""" + + df += """ +# Install docker docker buildx +RUN yum install -y ca-certificates curl gnupg yum-utils \\ + && yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo \\ + && yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin +# && yum install -y docker.io docker-buildx-plugin + +# libcurl4-openSSL-dev is needed for GCS +# python3-dev is needed by Torchvision +# python3-pip and libarchive-dev is needed by python backend +# libxml2-dev is needed for Azure Storage +# scons is needed for armnn_tflite backend build dep +RUN yum install -y \\ + ca-certificates \\ + autoconf \\ + automake \\ + git \\ + gperf \\ + re2-devel \\ + openssl-devel \\ + libtool \\ + libcurl-devel \\ + libb64-devel \\ + gperftools-devel \\ + patchelf \\ + python3.11-devel \\ + python3-pip \\ + python3-setuptools \\ + rapidjson-devel \\ + python3-scons \\ + pkg-config \\ + unzip \\ + wget \\ + zlib-devel \\ + libarchive-devel \\ + libxml2-devel \\ + numactl-devel \\ + wget + +RUN pip3 install --upgrade pip \\ + && pip3 install --upgrade \\ + wheel \\ + setuptools \\ + docker \\ + virtualenv + +# Install boost version >= 1.78 for boost::span +# Current libboost-dev apt packages are < 1.78, so install from tar.gz +RUN wget -O /tmp/boost.tar.gz \\ + https://archives.boost.io/release/1.80.0/source/boost_1_80_0.tar.gz \\ + && (cd /tmp && tar xzf boost.tar.gz) \\ + && mv /tmp/boost_1_80_0/boost /usr/include/boost + +# Server build requires recent version of CMake (FetchContent required) +# Might not need this if the installed version of cmake is high enough for our build. +# RUN apt update -q=2 \\ +# && apt install -y gpg wget \\ +# && wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null \\ +# && . /etc/os-release \\ +# && echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $UBUNTU_CODENAME main" | tee /etc/apt/sources.list.d/kitware.list >/dev/null \\ +# && apt-get update -q=2 \\ +# && apt-get install -y --no-install-recommends cmake=3.27.7* cmake-data=3.27.7* +""" + if FLAGS.enable_gpu: + df += install_dcgm_libraries(argmap["DCGM_VERSION"], target_machine()) + df += """ +ENV TRITON_SERVER_VERSION ${TRITON_VERSION} +ENV NVIDIA_TRITON_SERVER_VERSION ${TRITON_CONTAINER_VERSION} +""" + + df += """ +WORKDIR /workspace +RUN rm -fr * +COPY . . +ENTRYPOINT [] +""" + + with open(os.path.join(ddir, dockerfile_name), "w") as dfile: + dfile.write(df) + + +def create_dockerfile_buildbase_rhel(ddir, dockerfile_name, argmap): + df = """ +ARG TRITON_VERSION={} +ARG TRITON_CONTAINER_VERSION={} +ARG BASE_IMAGE={} +""".format( + argmap["TRITON_VERSION"], + argmap["TRITON_CONTAINER_VERSION"], + argmap["BASE_IMAGE"], + ) + + df += """ +FROM ${BASE_IMAGE} + +ARG TRITON_VERSION +ARG TRITON_CONTAINER_VERSION +""" + df += """ +# Install docker docker buildx +RUN yum install -y ca-certificates curl gnupg yum-utils \\ + && yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo \\ + && yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin +# && yum install -y docker.io docker-buildx-plugin + +# libcurl4-openSSL-dev is needed for GCS +# python3-dev is needed by Torchvision +# python3-pip and libarchive-dev is needed by python backend +# libxml2-dev is needed for Azure Storage +# scons is needed for armnn_tflite backend build dep +RUN yum install -y \\ + ca-certificates \\ + autoconf \\ + automake \\ + git \\ + gperf \\ + re2-devel \\ + openssl-devel \\ + libtool \\ + libcurl-devel \\ + libb64-devel \\ + gperftools-devel \\ + patchelf \\ + python3.11-devel \\ + python3-pip \\ + python3-setuptools \\ + rapidjson-devel \\ + python3-scons \\ + pkg-config \\ + unzip \\ + wget \\ + zlib-devel \\ + libarchive-devel \\ + libxml2-devel \\ + numactl-devel \\ + wget + +RUN pip3 install --upgrade pip \\ + && pip3 install --upgrade \\ + wheel \\ + setuptools \\ + docker \\ + virtualenv + +# Install boost version >= 1.78 for boost::span +# Current libboost-dev apt packages are < 1.78, so install from tar.gz +RUN wget -O /tmp/boost.tar.gz \\ + https://archives.boost.io/release/1.80.0/source/boost_1_80_0.tar.gz \\ + && (cd /tmp && tar xzf boost.tar.gz) \\ + && mv /tmp/boost_1_80_0/boost /usr/include/boost + +# Server build requires recent version of CMake (FetchContent required) +# Might not need this if the installed version of cmake is high enough for our build. +# RUN apt update -q=2 \\ +# && apt install -y gpg wget \\ +# && wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null \\ +# && . /etc/os-release \\ +# && echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $UBUNTU_CODENAME main" | tee /etc/apt/sources.list.d/kitware.list >/dev/null \\ +# && apt-get update -q=2 \\ +# && apt-get install -y --no-install-recommends cmake=3.27.7* cmake-data=3.27.7* +""" + if FLAGS.enable_gpu: + df += install_dcgm_libraries(argmap["DCGM_VERSION"], target_machine()) + df += """ +ENV TRITON_SERVER_VERSION ${TRITON_VERSION} +ENV NVIDIA_TRITON_SERVER_VERSION ${TRITON_CONTAINER_VERSION} +""" + + df += """ +WORKDIR /workspace +RUN rm -fr * +COPY . . +ENTRYPOINT [] +""" + + with open(os.path.join(ddir, dockerfile_name), "w") as dfile: + dfile.write(df) + + def create_dockerfile_buildbase_rhel(ddir, dockerfile_name, argmap): df = """ ARG TRITON_VERSION={} @@ -1301,7 +1503,6 @@ def dockerfile_prepare_container_linux(argmap, backends, enable_gpu, target_mach gpu_enabled=gpu_enabled ) - # This if target_platform() == "rhel": df += """ # Common dpeendencies. @@ -1816,6 +2017,12 @@ def core_build( os.path.join(repo_install_dir, "lib", "tritonserver.lib"), os.path.join(install_dir, "bin"), ) + elif target_platform() == "rhel": + cmake_script.mkdir(os.path.join(install_dir, "bin")) + cmake_script.cp( + os.path.join(repo_install_dir, "bin", "tritonserver"), + os.path.join(install_dir, "bin"), + ) elif target_platform() == "rhel": cmake_script.mkdir(os.path.join(install_dir, "bin")) cmake_script.cp(