Build torch-tensorrt locally — install/pin the matching PyTorch nightly, drive Bazel through setup.py, do a clean rebuild after libtorch ABI changes, and recover from common build failures (undefined symbol, stale _C.so, libtorchtrt.so missing). Invoke whenever the user asks to build, rebuild, install editable, or upgrade the torch nightly; or when an import fails with an undefined-symbol error tying torch_tensorrt to libtorch.
npx skills add https://github.com/pytorch/TensorRT --skill build
undefined symbol: _ZN3c10...c10::ValueError...) → torch and the compiled _C.so / libtorchtrt.so are mismatched. Do a clean rebuild (delete artifacts + uv pip install -e .).uv pip install against https://download.pytorch.org/whl/nightly/cu<MAJOR><MINOR>, then clean rebuild..cpp/.h/.cc touched, no torch upgrade) → no rebuild needed. Just re-run.uv pip install -e . --no-deps --no-build-isolation (incremental Bazel build) usually suffices. If linkage looks off, escalate to clean rebuild..venv/. Tooling: uv, bazelisk (or bazel), a matching CUDA toolchain.pyproject.toml (the torch>=…,<… line in [project].dependencies). Bumps occasionally on main — check that line if a build fails right after a rebase or branch switch.dev_dep_versions.yml (__cuda_version__). Use the matching nightly index, e.g. https://download.pytorch.org/whl/nightly/cu<MAJOR><MINOR>.third_party/dist_dir/x86_64-linux-gnu (no system install required).setup.py:resolve_torch_path() (see setup.py:287) and MODULE.bazel/WORKSPACE. Detection order:
TORCH_PATH env var (absolute path to torch package dir)VIRTUAL_ENV — used when a venv / uv venv is activeCONDA_PREFIX — when a conda env is active.venv/bin/python3 relative to repo rootpython3 / python on PATHIf you ever see headers/runtime mismatch, set TORCH_PATH explicitly:
TORCH_PATH=$(uv run python -c "import torch, os; print(os.path.dirname(torch.__file__))") \
uv pip install -e . --no-deps --no-build-isolation
uv pip install -e . --no-deps --no-build-isolation
setup.py:DevelopCommand.run() → build_libtorchtrt_cxx11_abi(develop=True) → bazelisk build //:libtorchtrt --compilation_mode=dbg --config=python --config=linuxcopy_libtorchtrt() (untars bazel-bin/libtorchtrt.tar.gz into py/torch_tensorrt/)--no-deps avoids re-resolving torch / overwriting a manually-pinned nightly--no-build-isolation makes Bazel use the active venv's torch (skipping isolation prevents the build from picking up a different torch)rm -rf build py/torch_tensorrt/_C*.so py/torch_tensorrt/lib/*.so
uv pip install -e . --no-deps --no-build-isolation
Required when:
import torch_tensorrt raises undefined symbol: _ZN3c10... (libtorch ABI changed)core/runtime/*The 4 artifacts to remove:
py/torch_tensorrt/_C.cpython-313-x86_64-linux-gnu.so (Python extension)py/torch_tensorrt/lib/libtorchtrt.so (main C++ runtime)py/torch_tensorrt/lib/libtorchtrt_runtime.so (slim C++ runtime)py/torch_tensorrt/lib/libtorchtrt_plugins.so (TRT plugin shim)build/ (Bazel symlink + scratch)The whl index is https://download.pytorch.org/whl/nightly/cu<MAJOR><MINOR> — derive <MAJOR><MINOR> from dev_dep_versions.yml (e.g. CUDA 13.0 → cu130). Filename convention: torch==<X.Y>.<Z>.dev<YYYYMMDD>+cu<MAJOR><MINOR>, with <X.Y> matching the torch constraint in pyproject.toml.
# Substitute the right CUDA tag and date; check pyproject.toml for the torch version
uv pip install \
--index-url https://download.pytorch.org/whl/nightly/cu<MAJOR><MINOR> \
"torch==<X.Y>.<Z>.dev<YYYYMMDD>+cu<MAJOR><MINOR>"
Then always clean rebuild afterward — _C.so was linked against the previous torch.
PYTHON_ONLY=1 uv pip install -e . --no-deps --no-build-isolation — skips Bazel entirely. Use when iterating on pure-Python and you don't need engine execution via C++.NO_TORCHSCRIPT=1 uv pip install -e . --no-deps --no-build-isolationUSE_TRT_RTX=1 ... — rebuilds against the RTX TRT distribution; package name becomes torch-tensorrt-rtx.uv pip wheel --no-deps --no-build-isolation -w dist .
These builds take 2–5 min. Always launch in the background and poll for terminal markers; do not sleep-loop on a fixed schedule:
Bash(
command="rm -rf build py/torch_tensorrt/_C*.so py/torch_tensorrt/lib/*.so && uv pip install -e . --no-deps --no-build-isolation 2>&1 | tail -5",
description="Clean rebuild",
run_in_background=True,
)
# then wait for one of the terminal markers in the background output file:
Bash(
command="until grep -qE 'Installed|error\\b|ERROR|failed|exit code' \"$OUTPUT_FILE\" 2>/dev/null; do sleep 30; done; tail -10 \"$OUTPUT_FILE\"",
timeout=600000,
)
Or use the Monitor tool if available — it notifies on each stdout line and avoids the polling loop entirely.
uv run python -c "
import torch, torch_tensorrt
print('torch:', torch.__version__)
print('torch-tensorrt:', torch_tensorrt.__version__)
print('C++ runtime:', torch_tensorrt.ENABLED_FEATURES.torch_tensorrt_runtime)
try:
print('ABI:', torch.ops.tensorrt.ABI_VERSION())
except Exception:
pass # ABI op only registered when the C++ runtime is built
"
If this prints clean (no OSError: Could not load this library: ...libtorchtrt.so), the build is good.
undefined symbol: _ZN3c10* from libtorchtrt.so or _C.sotorch's libtorch was upgraded but our .so files were linked against the old one. Solution: clean rebuild.
libtorchtrt.so timestamp from Jan 1 2000That's the wheel-build's reproducible-build epoch. Normal — not stale.
TORCH_PATH resolution failed. Verify the venv is active (echo $VIRTUAL_ENV should print .venv), or set TORCH_PATH explicitly (see "How Bazel finds libtorch" above).
bazelisk: command not foundInstall bazelisk: curl -fSsL https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 -o ~/.local/bin/bazelisk && chmod +x ~/.local/bin/bazelisk. Or install bazel matching .bazelversion.
import torch_tensorrt still failsOld .so files may persist if Python cached them. find py/torch_tensorrt -name __pycache__ -exec rm -rf {} + then re-import.
Permission denied: '/tmp/torch_tensorrt_engine_cache/timing_cache.bin'Torch-TensorRT writes its timing cache under tempfile.gettempdir() (defaulting to /tmp). On shared hosts the cache directory may already exist with another user's ownership, blocking writes. Set TMPDIR to a user-private path before running tests/builds:
export TMPDIR=/tmp/$(whoami)-trt
mkdir -p "$TMPDIR"
This makes the engine-cache directory user-scoped and avoids cross-user collisions.
setup.py — drives Bazel; respects env vars PYTHON_ONLY, NO_TORCHSCRIPT, USE_TRT_RTX, RELEASE, CI_BUILD, TORCH_PATH, CU_VERSION, JETPACK_BUILDpyproject.toml — declares torch version range, build-system setuptools, project metadataMODULE.bazel / WORKSPACE — Bazel deps, libtorch detection, TensorRT archive URL.bazelversion — pinned bazel version (bazelisk reads this)dev_dep_versions.yml — CUDA / TensorRT version pins surfaced into __cuda_version__ / __tensorrt_version__docsrc/getting_started/installation.rst — official build docs (Linux, Windows, Jetpack)tests/ edits — just re-run pytest.docsrc/ edits — cd docsrc && make html (separate flow)..claude/, MEMORY.md, slash-commands — never need a build.Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
Access NCBI GEO for gene expression/genomics data. Search/download microarray and RNA-seq datasets (GSE, GSM, GPL), retrieve SOFT/Matrix files, for transcriptomics and expression analysis.
Bayesian modeling with PyMC. Build hierarchical models, MCMC (NUTS), variational inference, LOO/WAIC comparison, posterior checks, for probabilistic programming and inference.
Multi-objective optimization framework. NSGA-II, NSGA-III, MOEA/D, Pareto fronts, constraint handling, benchmarks (ZDT, DTLZ), for engineering design and optimization problems.
Statistical modeling toolkit. OLS, GLM, logistic, ARIMA, time series, hypothesis tests, diagnostics, AIC/BIC, for rigorous statistical inference and econometric analysis.
Fine-tune models on Azure AI Foundry using SFT (supervised), DPO (preference), or RFT (reinforcement with graders). Covers dataset preparation, training job submission, deployment, and evaluation. USE FOR: fine-tune, SFT, DPO, RFT, training data, grader, distillation, fine-tuned model, training job, large file upload, calibrate grader, deploy fine-tuned model, evaluate fine-tuned model. DO NOT USE FOR: general model deployment without fine-tuning (use deploy-model), agent creation (use agents), prompt optimization without training (use prompt-optimizer).
Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.
Work with Data Commons, a platform providing programmatic access to public statistical data from global sources. Use this skill when working with demographic data, economic indicators, health statistics, environmental data, or any public datasets available through Data Commons. Applicable for querying population statistics, GDP figures, unemployment rates, disease prevalence, geographic entity resolution, and exploring relationships between statistical entities.
Take pytorch/build from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference pip, uv.
Without those the skill loads but fails at the first command.