trt-samples-for-hackathon-cn
CLAUDE.md1.7k starsChanged 5 months agoApache-2.0View on GitHub
Recommended before running examples (optional in most Python cases due to auto-discovery): The tensorrt_cookbook package first tries to auto-discover this path and sets the environment variable automatically when found. Recommended environment: NVIDIA Docker image nvcr.io/nvidia/pytorch:26.07-py3 (Python 3.12, CUDA 13.3, TensorRT 11.0). Install dependencies: Run a single example: Run examples via the unified runner: Run the full test suite (unified runner): Run pytest tests (NetworkSerialization): Linting / formatting: Regenerate README.md: Add SPDX license headers to new files: All examples import from…
- Installs packages
Trending
Quiet this year.thin dataabout the whole repository
Who's talking about NVIDIA/trt-samples-for-hackathon-cn
- Tlntin/Qwen-TensorRT-LLM“长序列(>2048)出现output为空”GitHub · Nov 29, 2023
- NVIDIA/TensorRT“override getBatch() in IInt8EntropyCalibrator failure”GitHub · Sep 20, 2023
The biggest 2 of 2 mentions linking to the repository that our crawl found. Each line is their own headline.
In this repository5 other files it gives its agents.
The file
We split this CLAUDE.md into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 78
All examples import from this package.
- Very specific: line 95
When adding a helper, place it by dependency direction, not by topic name: utils_function may not import from the package, utils_onnx may …
- Very specific: line 120
If a directory contains unit_test.yaml, its run: commands are used.
- Very specific: line 121
If a directory has main.py but no unit_test.yaml, the runner defaults to python3 main.py > log-main.py.log.
- Very specific: line 132
All source files require an SPDX Apache-2.0 header.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Environment Setup
Recommended before running examples (optional in most Python cases due to auto-discovery):
cd cookbook/
export TRT_COOKBOOK_PATH=$(pwd) # Point to the cookbook/ root
pip install -e .The tensorrt_cookbook package first tries to auto-discover this path and sets the environment variable automatically when found.
Recommended environment: NVIDIA Docker image nvcr.io/nvidia/pytorch:26.07-py3 (Python 3.12, CUDA 13.3, TensorRT 11.0).
Install dependencies:
pip install -r requirements.txt
# Developer (editable) install:
pip install -e .
# Release build:
python -m pip install -U build && python -m build && pip install dist/*.whlCommon Commands
Run a single example:
cd 02-API/Layer/Cast
python3 main.pyRun examples via the unified runner:
python3 tests/run_tests.py # run all discoverable examples
python3 tests/run_tests.py --case 02-API/Layer/Cast # run one specific example
python3 tests/run_tests.py --include "02-API/**" # glob filter
python3 tests/run_tests.py --list # list without running
python3 tests/run_tests.py --dry-run # print commands only
python3 tests/run_tests.py --tags plugin # filter by tagRun the full test suite (unified runner):
python3 tests/run_tests.pyRun pytest tests (NetworkSerialization):
pytest tests/NetworkSerialization/
pytest tests/NetworkSerialization/test_convolution.py # single test fileLinting / formatting:
pre-commit run --all-files # run all hooks (yapf, clang-format, autoflake, codespell…)
pre-commit install # install hooks into .git/hooksRegenerate README.md:
python3 build-README.pyAdd SPDX license headers to new files:
python3 build-Copyright.pyCode Architecture
tensorrt_cookbook/ — shared utility package
All examples import from this package. Key modules:
utils_class.py— TensorRT wrapper classes that are the primary abstraction used across examples:TRTWrapperV1/TRTWrapperV2— high-level build + inference workflowsTRTWrapperDDS,TRTWrapperShapeInput,TRTWrapperV2Torch— specialised variantsCookbookLogger,CookbookProfiler,CookbookErrorRecorder— diagnostic helpersCookbookGpuAllocator,CookbookOutputAllocator— custom memory management
utils_cookbook.py— cookbook infrastructure: path resolution (cookbook_path), thecase_markdecorator used by everymain.py, logging, API-coverage inspection, README/copyright generationutils_function.py— framework-agnostic data helpers only: maths, array printing/comparison, dtype casting. Depends on nothing heavier than numpy/torch/tensorrtutils_network.py— building and inspectingINetworkDefinition: layer-type helpers (layer_dynamic_cast, …),parse_onnx,print_network,export_network_as_onnxutils_engine.py— inspecting a built engine: plan-file header (print_engine_information), engine/context I/O tables, engine-information JSON → ONNXutils_workflow.py—check_torch_operator: run one Torch model through Torch → ONNX → ONNX-Runtime → Polygraphy → TensorRT and report which stage breaksutils_network_serialization.py— network serialization/deserialization (also tested bytests/NetworkSerialization/)utils_onnx.py— ONNX / onnx-graphsurgeon utilities. Deliberately does not importtensorrtutils_plugin.py— plugin development helpersutils_engine_explorer.py— TREx-derived engine profiling/visualisation
When adding a helper, place it by dependency direction, not by topic name: utils_function may not
import from the package, utils_onnx may not import tensorrt, and anything that touches a built
engine belongs in utils_engine.py. Because __init__.py re-exports every module with import *,
moving a function between these modules does not affect examples.
Numbered example sections
| Directory | Content |
00-Data/ | Dataset and model preparation |
01-SimpleDemo/ | Minimal end-to-end TensorRT examples |
02-API/ | TensorRT API coverage (Builder, Network, Layers, etc.) |
03-Workflow/ | Framework-to-TRT pipelines (PyTorch/TF/Paddle → ONNX → TRT) |
04-Feature/ | Advanced features: quantization, profiling, caching, safety |
05-Plugin/ | Custom plugin development and ONNX parser integration |
06-DLFrameworkTRT/ | Torch-TensorRT |
07-Tool/ | External tools: trtexec, Polygraphy, Netron, ONNX utilities |
08-Advance/ | Advanced patterns: CUDA graphs, multi-device, multi-stream |
90-Misc/ | General utilities not specific to TensorRT |
Each leaf directory is independently runnable. The standard entry point is main.py.
Test orchestration
Examples are discovered and run by tests/run_tests.py. Discovery rules:
- If a directory contains
unit_test.yaml, itsrun:commands are used. - If a directory has
main.pybut nounit_test.yaml, the runner defaults topython3 main.py > log-main.py.log. - Paths matched by
tests/skip_tests.yamlare globally excluded from discovery. - Presence of a
.skip_unit_testfile disables that directory entirely.
unit_test.yaml fields: enabled, tags, timeout, env, pre, run, post, clean. See tests/run_tests.py for the full spec.
Code Style
- Python: formatted by YAPF (config in
.style.yapf); isort is intentionally disabled to avoid conflicts. - C++/CUDA: formatted by clang-format v16 (LLVM style, config in
.clang-format). - CMake: formatted by cmake-format.
- All source files require an SPDX Apache-2.0 header. Run
python3 copyright.pyto add/update headers. - Pre-commit hooks enforce all of the above automatically on commit.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

