diff --git a/Dockerfile b/Dockerfile index fea1cd97..37cf6b01 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,33 +27,7 @@ ARG TRITONSDK_BASE_IMAGE # Ensure apt-get won't prompt for selecting options ENV DEBIAN_FRONTEND=noninteractive - -RUN apt-get update && \ - apt-get install -y python3-dev - -RUN mkdir -p /opt/triton-model-analyzer - -# Install architecture-specific components - -# Install DCGM version 4.x. Steps from https://developer.nvidia.com/dcgm#Downloads -# Remove any old DCGM installations -RUN dpkg --list datacenter-gpu-manager &> /dev/null && \ - apt purge --yes datacenter-gpu-manager || true && \ - dpkg --list datacenter-gpu-manager-config &> /dev/null && \ - apt purge --yes datacenter-gpu-manager-config || true - -RUN apt-get update && \ - apt-get install --yes \ - --install-recommends \ - datacenter-gpu-manager-4-cuda13 - -# Install Docker -RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && \ - echo \ - "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ - $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ - tee /etc/apt/sources.list.d/docker.list > /dev/null && \ - apt-get update && apt-get install -y docker-ce-cli +RUN apt update -qq && apt install -y docker.io # Install tritonclient COPY --from=sdk /workspace/install/python /tmp/tritonclient @@ -62,30 +36,29 @@ RUN find /tmp/tritonclient -maxdepth 1 -type f -name \ xargs pip3 install --upgrade && rm -rf /tmp/tritonclient/ WORKDIR /opt/triton-model-analyzer -RUN rm -fr * -COPY --from=sdk /usr/local/bin/perf_analyzer . -RUN chmod +x ./perf_analyzer + +RUN python3 -m pip install \ + build \ + coverage \ + mkdocs \ + mkdocs-htmlproofer-plugin==0.10.3 \ + mypy \ + nvidia-pyindex \ + types-protobuf \ + types-PyYAML \ + types-requests \ + yapf==0.32.0 COPY . . -RUN chmod +x /opt/triton-model-analyzer/nvidia_entrypoint.sh -RUN chmod +x build_wheel.sh && \ - ./build_wheel.sh perf_analyzer true && \ - rm -f perf_analyzer -RUN python3 -m pip install nvidia-pyindex && \ - python3 -m pip install wheels/triton_model_analyzer-*-manylinux*.whl -# Install other pip packages -RUN python3 -m pip install coverage -RUN python3 -m pip install mypy -RUN python3 -m pip install types-PyYAML -RUN python3 -m pip install types-requests -RUN python3 -m pip install types-protobuf -RUN python3 -m pip install mkdocs -RUN python3 -m pip install mkdocs-htmlproofer-plugin==0.10.3 -RUN python3 -m pip install yapf==0.32.0 -RUN apt-get install -y wkhtmltopdf +RUN python3 -m build --wheel \ + && cd dist \ + && python3 -m pip install triton*model*analyzer*.whl + +RUN chmod +x /opt/triton-model-analyzer/nvidia_entrypoint.sh ENTRYPOINT ["/opt/triton-model-analyzer/nvidia_entrypoint.sh"] + ENV MODEL_ANALYZER_VERSION=${MODEL_ANALYZER_VERSION} ENV MODEL_ANALYZER_CONTAINER_VERSION=${MODEL_ANALYZER_CONTAINER_VERSION} ENV TRITON_SERVER_SDK_CONTAINER_IMAGE_NAME=${TRITONSDK_BASE_IMAGE} diff --git a/build_wheel.sh b/build_wheel.sh deleted file mode 100755 index 29f35127..00000000 --- a/build_wheel.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# Copyright (c) 2020, NVIDIA CORPORATION. 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. - -PYTHON=${PYTHON:=`which python3`} - -if [[ "$1" == "-h" || "$1" == "--help" ]] ; then - echo "usage: $0 " - exit 1 -fi - -if [[ ! -f "VERSION" ]]; then - echo "Could not find VERSION" - exit 1 -fi - -if [[ ! -f "LICENSE" ]]; then - echo "Could not find LICENSE" - exit 1 -fi - -if [[ -z "$1" ]]; then - echo "Path to perf_analyzer binary not provided. Checking PATH..." - if [[ -z "$(which perf_analyzer)" ]]; then - echo "Could not find perf_analyzer binary" - exit 1 - else - PERF_ANALYZER_PATH="$(which perf_analyzer)" - fi -elif [[ ! -f "$1" ]]; then - echo "Could not find perf_analyzer binary" - exit 1 -else - PERF_ANALYZER_PATH="${1}" -fi - -WHLDIR="`pwd`/wheels" -mkdir -p ${WHLDIR} - -# Copy required files into WHEELDIR temporarily -cp $PERF_ANALYZER_PATH "${WHLDIR}" -cp VERSION "${WHLDIR}" -cp LICENSE "${WHLDIR}" -cp requirements.txt "${WHLDIR}" - -# Set platform and build wheel -echo $(date) : "=== Building wheel" -if [[ -z "$2" || "$2" = true ]]; then - PLATFORM=`uname -m` - if [ "$PLATFORM" = "aarch64" ] ; then - PLATFORM_NAME="manylinux2014_aarch64" - else - PLATFORM_NAME="manylinux1_x86_64" - fi - ${PYTHON} setup.py bdist_wheel --plat-name $PLATFORM_NAME --dependency-dir $WHLDIR -else - ${PYTHON} setup.py bdist_wheel --dependency-dir $WHLDIR -fi -rm -f $WHLDIR/* && cp dist/* $WHLDIR -rm -rf build dist triton_model_analyzer.egg-info -touch ${WHLDIR}/stamp.whl -echo $(date) : "=== Output wheel file is in: ${WHLDIR}" diff --git a/pyproject.toml b/pyproject.toml index d7131f32..7a63072b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ -# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# Copyright 2023-2025, NVIDIA CORPORATION & AFFILIATES. 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. @@ -12,6 +12,80 @@ # See the License for the specific language governing permissions and # limitations under the License. +[build-system] +requires = ["setuptools >= 61.0","wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "triton-model-analyzer" +dynamic = ["version"] +license = "BSD-3-Clause" +description = "Triton Model Analyzer is a tool to profile and analyze the runtime performance of one or more models on the Triton Inference Server" +readme = {content-type = "text/markdown", text = """See the Model Analyzer's [installation documentation](https://github.com/triton-inference-server/model_analyzer/blob/main/docs/install.md#using-pip3) for package details. The [quick start](https://github.com/triton-inference-server/model_analyzer/blob/main/docs/quick_start.md) documentation describes how to get started with profiling and analysis using Triton Model Analyzer."""} +authors = [ + {name = "NVIDIA Inc.", email = "sw-dl-triton@nvidia.com"} +] +keywords = ["triton", "tensorrt", "inference", "server", "service", "analyzer", "nvidia"] +classifiers = [ + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Intended Audience :: Information Technology", + "Topic :: Scientific/Engineering", + "Topic :: Scientific/Engineering :: Image Recognition", + "Topic :: Scientific/Engineering :: Artificial Intelligence", + "Topic :: Software Development :: Libraries", + "Topic :: Utilities", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Environment :: Console", + "Natural Language :: English", + "Operating System :: POSIX :: Linux", +] +requires-python = ">=3.8" +dependencies = [ + "cryptography>=3.3.2", + "distro>=1.5.0", + "docker>=4.3.1", + "gevent>=22.08.0", + "grpcio>=1.63.0,<1.68", + "httplib2>=0.19.0", + "importlib_metadata>=7.1.0", + "matplotlib>=3.3.4", + "numba>=0.51.2", + "optuna==3.6.1", + "pdfkit>=0.6.1", + "prometheus_client>=0.9.0", + "protobuf", + "psutil>=5.8.0", + "pyyaml>=5.3.1", + "requests>=2.24.0", + "tritonclient[all]>=2.4.0", + "urllib3>=2.0.7", +] + +[project.urls] +Homepage = "https://developer.nvidia.com/nvidia-triton-inference-server" +Repository = "https://github.com/triton-inference-server/model_analyzer" + +[project.scripts] +model-analyzer = "model_analyzer.entrypoint:main" + + +[project.optional-dependencies] +perf-analyzer = ["perf-analyzer"] + +[tool.setuptools.dynamic] +version = {file = "VERSION"} + +[tool.setuptools.packages.find] +where = ["."] +include = ["model_analyzer*"] +exclude = ["tests*", "examples*", "qa*"] + [tool.codespell] # note: pre-commit passes explicit lists of files here, which this skip file list doesn't override - # this is only to allow you to run codespell interactively diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 0e6e70f4..00000000 --- a/requirements.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2020-2022, NVIDIA CORPORATION & AFFILIATES. 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. - -cryptography>=3.3.2 -distro>=1.5.0 -docker>=4.3.1 -gevent>=22.08.0 -grpcio>=1.63.0,<1.68 -httplib2>=0.19.0 -importlib_metadata>=7.1.0 -matplotlib>=3.3.4 -numba>=0.51.2 -optuna==3.6.1 -pdfkit>=0.6.1 -prometheus_client>=0.9.0 -protobuf -psutil>=5.8.0 -pyyaml>=5.3.1 -requests>=2.24.0 -tritonclient[all]>=2.4.0 -urllib3>=2.0.7 diff --git a/setup.py b/setup.py deleted file mode 100755 index 0fd1e06c..00000000 --- a/setup.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright 2020-2023, NVIDIA CORPORATION & AFFILIATES. 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. - -import os -import sys - -from setuptools import find_packages, setup - -if "--dependency-dir" in sys.argv: - idx = sys.argv.index("--dependency-dir") - DEPENDENCY_DIR = sys.argv[idx + 1] - sys.argv.pop(idx + 1) - sys.argv.pop(idx) -else: - DEPENDENCY_DIR = "." - -if "--plat-name" in sys.argv: - PLATFORM_FLAG = sys.argv[sys.argv.index("--plat-name") + 1] -else: - PLATFORM_FLAG = "any" - - -def version(filename="VERSION"): - with open(os.path.join(filename)) as f: - project_version = f.read() - return project_version - - -def req_file(filename): - with open(os.path.join(filename)) as f: - content = f.readlines() - return [x.strip() for x in content if not x.startswith("#")] - - -project_version = version() -install_requires = req_file("requirements.txt") - -try: - from wheel.bdist_wheel import bdist_wheel as _bdist_wheel - - class bdist_wheel(_bdist_wheel): - def finalize_options(self): - _bdist_wheel.finalize_options(self) - self.root_is_pure = False - - def get_tag(self): - pyver, abi, plat = "py3", "none", PLATFORM_FLAG - return pyver, abi, plat - -except ImportError: - bdist_wheel = None - -data_files = [ - ("", [os.path.join(DEPENDENCY_DIR, "LICENSE")]), -] - -if PLATFORM_FLAG != "any": - data_files += [("bin", [os.path.join(DEPENDENCY_DIR, "perf_analyzer")])] - -setup( - name="triton-model-analyzer", - version=project_version, - author="NVIDIA Inc.", - author_email="sw-dl-triton@nvidia.com", - description="Triton Model Analyzer is a tool to profile and analyze the runtime performance of one or more models on the Triton Inference Server", - long_description="""See the Model Analyzer's [installation documentation](https://github.com/triton-inference-server/model_analyzer/blob/main/docs/install.md#using-pip3) """ - """for package details. The [quick start](https://github.com/triton-inference-server/model_analyzer/blob/main/docs/quick_start.md) documentation """ - """describes how to get started with profiling and analysis using Triton Model Analyzer.""", - long_description_content_type="text/markdown", - license="BSD", - url="https://developer.nvidia.com/nvidia-triton-inference-server", - keywords=[ - "triton", - "tensorrt", - "inference", - "server", - "service", - "analyzer", - "nvidia", - ], - classifiers=[ - "Intended Audience :: Developers", - "Intended Audience :: Science/Research", - "Intended Audience :: Information Technology", - "Topic :: Scientific/Engineering", - "Topic :: Scientific/Engineering :: Image Recognition", - "Topic :: Scientific/Engineering :: Artificial Intelligence", - "Topic :: Software Development :: Libraries", - "Topic :: Utilities", - "License :: OSI Approved :: BSD License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Environment :: Console", - "Natural Language :: English", - "Operating System :: POSIX :: Linux", - ], - entry_points={ - "console_scripts": ["model-analyzer = model_analyzer.entrypoint:main"] - }, - install_requires=install_requires, - dependency_links=["https://pypi.ngc.nvidia.com/tritonclient"], - packages=find_packages(exclude=("tests",)), - zip_safe=False, - data_files=data_files, -)