Skip to main content

SKY-GPU003 · Deployment and infrastructure

TensorRT engine shipped to GPUs it was not built for

High

A serialized TensorRT engine is a model compiled for one GPU model; by default it only runs on GPUs with the same compute capability. SKY-GPU003 reports an engine that is built, written to a file and copied into the release image when the contract lists GPUs with different compute capabilities.

Languages
Python, C++, Dockerfile, GPU target contract (YAML)
Quality gate
counted toward the gate limits (full and diff scans). Reported under reliability. It counts toward max_reliability, which is 0 by default, so one finding fails --gate.
Needs
A .skylos/gpu-targets.yml contract in the repository.
Finding type
review
Catalog name
TensorRT engine is not portable across target GPUs
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

On the other GPUs TensorRT refuses to load the engine, so the service starts but every inference fails. The mismatch is only visible on the hardware itself.

What Skylos flags

build_engine.py · PythonReported on line 10
import tensorrt as trt logger = trt.Logger(trt.Logger.WARNING)builder = trt.Builder(logger)network = builder.create_network(0)parser = trt.OnnxParser(network, logger)with open("model.onnx", "rb") as model:    parser.parse(model.read())config = builder.create_builder_config()serialized = builder.build_serialized_network(network, config)with open("model.engine", "wb") as output:    output.write(serialized)
Dockerfile · Dockerfile
FROM nvcr.io/nvidia/tensorrt:24.05-py3COPY model.engine /models/model.engineCOPY serve.py /app/serve.pyCMD ["python3", "/app/serve.py"]
CMakeLists.txt · CMake
cmake_minimum_required(VERSION 3.24)project(trt_plugins LANGUAGES CXX CUDA)set(CMAKE_CUDA_ARCHITECTURES 80 86)add_library(trt_plugins SHARED plugins/nms.cu)
.skylos/gpu-targets.yml · YAML
version: 1targets:  - name: a100    vendor: nvidia    compute_capability: "8.0"  - name: rtx-a6000    vendor: nvidia    compute_capability: "8.6"

What Skylos leaves alone

build_engine.py · Python
import tensorrt as trt logger = trt.Logger(trt.Logger.WARNING)builder = trt.Builder(logger)network = builder.create_network(0)parser = trt.OnnxParser(network, logger)with open("model.onnx", "rb") as model:    parser.parse(model.read())config = builder.create_builder_config()config.hardware_compatibility_level = trt.HardwareCompatibilityLevel.AMPERE_PLUSserialized = builder.build_serialized_network(network, config)with open("model.engine", "wb") as output:    output.write(serialized)

Dockerfile: same as in the flagged example.

CMakeLists.txt: same as in the flagged example.

.skylos/gpu-targets.yml: same as in the flagged example.

Why Skylos leaves it alone

The builder sets the AMPERE_PLUS hardware compatibility level on this config before building, so the engine runs on every Ampere or newer GPU, including both targets.

How Skylos decides

  1. Runs with --danger (or -a), and only when the repository has a GPU target contract: .skylos/gpu-targets.yml (or .yaml), version 1, listing each target's name, vendor: nvidia, and its driver, compute_capability and platform (linux or windows, optionally /amd64 or /arm64). Without the file nothing is checked, unless an SKY-GPU rule is selected explicitly with --select.
  2. Reads Dockerfiles, CMake files, Makefiles, Bazel files, shell scripts, Python, C/C++/CUDA sources and YAML as text, skipping build, dist, node_modules, caches and virtual environments. It never runs a build or probes a GPU.
  3. Needs a contract with targets of different compute capabilities.
  4. In Python, finds a build_serialized_network(network, config) call, a later binary write of its result to a literal file path, and a COPY or ADD of that exact file in the final Docker stage. C++ builders using NvInfer.h are matched the same way.
  5. Does not report when that same config object gets hardware_compatibility_level = AMPERE_PLUS before the build and every target is Ampere (8.0) or newer.
  6. Reports HIGH on the build call.

How to fix it

Build the engine on the target GPU at deploy time, ship one engine per compute capability, or build with the AMPERE_PLUS hardware compatibility level when every target is Ampere or newer.

build_engine.py · Python · the fix, against the flagged file
import tensorrt as trt logger = trt.Logger(trt.Logger.WARNING)builder = trt.Builder(logger)network = builder.create_network(0)parser = trt.OnnxParser(network, logger)with open("model.onnx", "rb") as model:    parser.parse(model.read())config = builder.create_builder_config()Added: config.hardware_compatibility_level = trt.HardwareCompatibilityLevel.AMPERE_PLUSserialized = builder.build_serialized_network(network, config)with open("model.engine", "wb") as output:    output.write(serialized)

When it can be wrong

  • AMPERE_PLUS does not make an engine portable across operating systems or CPU architectures, and is not counted as covering pre-Ampere GPUs such as a T4.
  • An engine that is built but not copied into the final Docker stage is not reported.
  • The compatibility level must be assigned as written in the example. Setting it through a variable (level = trt.HardwareCompatibilityLevel.AMPERE_PLUS, then config.hardware_compatibility_level = level) is not recognised, so a portable engine is still reported.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • Put the marker on the build call line, or in a comment on the line above it.

    Python
    # skylos: ignore[SKY-GPU003] fleet is being moved to A100 onlyserialized = builder.build_serialized_network(network, config)
  • [tool.skylos] ignore = ["SKY-GPU003"] turns the rule off for the project.

  • A baseline (skylos baseline ., then --baseline) accepts the findings that exist today and reports new ones.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.