Skip to content

v7: ground-up rewrite — no-throw C++ TensorRT inference library (+ optional Python bindings) #1

v7: ground-up rewrite — no-throw C++ TensorRT inference library (+ optional Python bindings)

v7: ground-up rewrite — no-throw C++ TensorRT inference library (+ optional Python bindings) #1

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
# CPU-only build + the non-GPU test suite. GitHub-hosted runners have no NVIDIA GPU, so we
# compile against the CUDA/TensorRT headers + stubs and run only `ctest -LE gpu`. TensorRT and
# CUDA come from NVIDIA's apt repos (the layout FindTensorRT.cmake searches).
build-cpu:
name: build + cpu tests (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install CUDA toolkit + TensorRT (apt)
run: |
set -eux
distro=$(. /etc/os-release; echo "ubuntu${VERSION_ID/./}")
wget -qO cuda-keyring.deb \
"https://developer.download.nvidia.com/compute/cuda/repos/${distro}/x86_64/cuda-keyring_1.1-1_all.deb"
sudo dpkg -i cuda-keyring.deb
sudo apt-get update
# Toolkit (headers + cudart) and the TensorRT dev packages. No GPU is needed to compile.
sudo apt-get install -y --no-install-recommends \
cuda-cudart-dev-12-6 cuda-nvcc-12-6 \
libnvinfer-dev libnvonnxparsers-dev || \
sudo apt-get install -y --no-install-recommends \
cuda-cudart-dev-12-6 cuda-nvcc-12-6 \
libnvinfer10 libnvinfer-dev libnvonnxparsers10 libnvonnxparsers-dev
echo "/usr/local/cuda-12.6/bin" >> "$GITHUB_PATH"
- name: Configure
run: |
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DTRT_CPP_API_BUILD_TESTS=ON \
-DTRT_CPP_API_BUILD_PREPROC=ON \
-DCMAKE_CUDA_COMPILER=/usr/local/cuda-12.6/bin/nvcc
- name: Build
run: cmake --build build -j2
- name: CPU tests (exclude gpu-labeled)
run: ctest --test-dir build -LE gpu --output-on-failure
- name: Install smoke (find_package consumer)
run: |
cmake --install build --prefix "$PWD/_install"
cmake -S .github/consumer -B build/consumer -DCMAKE_PREFIX_PATH="$PWD/_install"
cmake --build build/consumer
./build/consumer/consumer
# AddressSanitizer + UBSan on the CPU test suite.
sanitizers:
name: asan + ubsan (cpu tests)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install CUDA toolkit + TensorRT (apt)
run: |
set -eux
wget -qO cuda-keyring.deb \
"https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb"
sudo dpkg -i cuda-keyring.deb
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
cuda-cudart-dev-12-6 cuda-nvcc-12-6 libnvinfer-dev libnvonnxparsers-dev
- name: Configure (sanitized)
run: |
cmake -S . -B build-san \
-DCMAKE_BUILD_TYPE=Debug \
-DTRT_CPP_API_BUILD_TESTS=ON \
-DTRT_CPP_API_BUILD_PREPROC=OFF \
-DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-sanitize-recover=all -fno-omit-frame-pointer"
- name: Build
run: cmake --build build-san -j2
- name: Run CPU tests under sanitizers
run: ctest --test-dir build-san -LE gpu --output-on-failure
# Python wheel build + import sanity (no GPU needed to import).
python-wheel:
name: python wheel + import
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install CUDA toolkit + TensorRT (apt)
run: |
set -eux
wget -qO cuda-keyring.deb \
"https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-keyring_1.1-1_all.deb"
sudo dpkg -i cuda-keyring.deb
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
cuda-cudart-dev-12-6 cuda-nvcc-12-6 libnvinfer-dev libnvonnxparsers-dev
- name: Build + install the wheel
run: |
python -m pip install --upgrade pip
pip install . -v --config-settings=cmake.define.CMAKE_CUDA_COMPILER=/usr/local/cuda-12.6/bin/nvcc
- name: Import sanity
run: python -c "import trtcpp; print(trtcpp.version_string()); assert trtcpp.library_version()[0] == 7"
# Full GPU suite. GitHub-hosted runners have no GPU, so this is manual-dispatch only and
# expects a self-hosted runner labeled [self-hosted, gpu]. Left here as a documented stub.
gpu-tests:
name: gpu tests (self-hosted)
if: ${{ github.event_name == 'workflow_dispatch' }}
runs-on: [self-hosted, gpu]
steps:
- uses: actions/checkout@v4
- name: Configure + build
run: |
cmake -S . -B build -DTRT_CPP_API_BUILD_TESTS=ON
cmake --build build -j4
- name: Full test suite
run: ctest --test-dir build --output-on-failure