Polygraphy is a toolkit designed to assist in running and debugging deep learning models
in various frameworks. It includes a Python API and
a command-line interface (CLI) built using this API.
Among other things, Polygraphy lets you:
Run inference among multiple backends, like TensorRT and ONNX-Runtime, and compare results
(example: API, CLI)
Convert models to various formats, e.g. TensorRT engines with post-training quantization
(example: API, CLI)
View information about various types of models
(example: CLI)
IMPORTANT: Polygraphy supports only Python 3.8 and later.Before following the instructions below, please ensure you are using a supported version of Python.
NOTE:On Linux, the command-line toolkit is usually installed to ${HOME}/.local/bin by default.Make sure to add this directory to your PATH environment variable.
Building From Source
Using Make Targets (Linux)
make install
Using Powershell Script (Windows)
Make sure you are allowed to execute scripts on your system then run:
.\install.ps1
Building Manually
Install prerequisites:
python -m pip install build
Build a wheel:
python -m build --wheel
Install the wheel manually from outside the repository:
NOTE:It is strongly recommended to install the colored module for colored outputfrom Polygraphy, as this can greatly improve readability:
python -m pip install colored
Installing Dependencies
Polygraphy has no hard-dependencies on other Python packages. However, much of the functionality included
does require other Python packages.
Automatically Installing Dependencies
It's non-trivial to determine all the packages that will be required ahead of time,
since it depends on exactly what functionality is being used.
To make this easier, Polygraphy can optionally automatically install or upgrade dependencies at runtime, as they are needed.
To enable this behavior, set the POLYGRAPHY_AUTOINSTALL_DEPS environment variable to 1 or
polygraphy.config.AUTOINSTALL_DEPS = True using the Python API.
NOTE: By default, dependencies will be installed using the current interpreter, and may overwrite existingpackages. The default installation command, which is python -m pip install, can be overriden by settingthe POLYGRAPHY_INSTALL_CMD environment variable, or setting polygraphy.config.INSTALL_CMD using the Python API.
If you'd like Polygraphy to prompt you before automatically installing or
upgrading pacakges, set the POLYGRAPHY_ASK_BEFORE_INSTALL environment variable to 1
or polygraphy.config.ASK_BEFORE_INSTALL = True using the Python API.
Installing Manually
Each backend directory includes a requirements.txt file that specifies the minimum set of packages
it depends on. This does not necessarily include all packages required for all the functionality provided
by the backend, but does serve as a good starting point.
You can install the requirements for whichever backends you're interested in with: