Skip to content

Fix Torch-TensorRT Bazel build on JetPack#4307

Open
Mike-Sagiri wants to merge 1 commit into
pytorch:mainfrom
Mike-Sagiri:fix/jetpack-tensorrt-bazel
Open

Fix Torch-TensorRT Bazel build on JetPack#4307
Mike-Sagiri wants to merge 1 commit into
pytorch:mainfrom
Mike-Sagiri:fix/jetpack-tensorrt-bazel

Conversation

@Mike-Sagiri
Copy link
Copy Markdown

@Mike-Sagiri Mike-Sagiri commented May 29, 2026

Description

Update and fix TensorRT Bazel build support on NVIDIA JetPack platforms.
JetPack packages TensorRT headers and libraries differently from standard Linux TensorRT distributions.

This change:

  • adds JetPack-specific include path support for third_party/tensorrt/local/BUILD
  • adds JetPack-specific library path support for third_party/tensorrt/local/BUILD
  • updates Bazel select() rules for JetPack environments for third_party/tensorrt/local/BUILD
  • fixes incorrect TensorRT library resolution on JetPack systems for of third_party/tensorrt/local/BUILD
  • updates dependencies for JetPack in setup.py and MODULE.bazel
  • now the users can use --jetpack to build Torch-TensorRT from source successfully

Known issue:

  • Since TensorRT 10.13+ not support cuda 12.x anymore, building Torch-TensorRT with TensorRT 10.13+ needs cuda 13 on JetPack. However, JetPack 6.2 and lower doesn't support cuda 13. When building Torch-TensorRT with TensorRT 10.7-, add_attention is not supported by TensorRT 10.14-. So the users may need to add torch.backends.cuda.enable_flash_sdp(False), torch.backends.cuda.enable_mem_efficient_sdp(False), torch.backends.cuda.enable_math_sdp(True) to solve the problem.
  • A stable version for JetPack 6.x is Torch 2.10, Torch-TensorRT 2.10 and TensorRT 10.7.

Fixes # (issue)

Type of change

Please delete options that are not relevant and/or add your own.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project (You can use the linters)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas and hacks
  • I have made corresponding changes to the documentation
  • I have added tests to verify my fix or my feature
  • New and existing unit tests pass locally with my changes
  • I have added the relevant labels to my PR in so that relevant reviewers are notified

@meta-cla meta-cla Bot added the cla signed label May 29, 2026
@github-actions github-actions Bot added the component: build system Issues re: Build system label May 29, 2026
@github-actions github-actions Bot requested a review from lanluo-nvidia May 29, 2026 03:38
@narendasan
Copy link
Copy Markdown
Collaborator

@Mike-Sagiri can you explain more about the system configuration you are targeting? If it is Jetson Thor / JP 7.0+, you should be able to use SBSA style distributions (aarch64_linux configuration). Or are you targeting Orin JP 6.2?

The PR seems to hint at JP7.0+

@Mike-Sagiri
Copy link
Copy Markdown
Author

@narendasan Thanks for raising this point. Actually, the goal of this PR is not to target a specific JetPack release. The main issue I am addressing is the build configuration under the --jetpack flag itself.

In principle, both JetPack 6 and JetPack 7 can be supported through --jetpack as long as the dependencies in MODULE.bazel are configured appropriately. The PR does not introduce any JP7-specific build logic.

That said, for the dependency versions currently used by Torch-TensorRT 2.12, I aligned the JetPack configuration with the versions already used on other architectures (CUDA, PyTorch, and TensorRT). As a result, the default configuration in this PR effectively matches the dependency stack available on JetPack 7.

One important consideration is that TensorRT versions available on JetPack 6 do not provide the add_attention API/operator that Torch-TensorRT 2.12 depends on. Because of this, Torch-TensorRT 2.12 is not actually in a stable or fully functional state on JetPack 6, regardless of the build configuration. In practice, Torch-TensorRT 2.10 is the most stable version for JetPack 6 systems, mentioned in "known issue".

Therefore, my rationale was to make the default JetPack configuration consistent with the dependency versions already used by other architectures, rather than maintaining a separate JetPack-specific dependency matrix that would still not provide full Torch-TensorRT 2.12 functionality on JetPack 6.

@narendasan
Copy link
Copy Markdown
Collaborator

narendasan commented Jun 2, 2026

I see. Generally the direction of Jetpack as a whole is to align on SBSA (the aarch64_linux target for Torch-TensorRT): https://developer.nvidia.com/embedded/jetpack/downloads. Jetson Thor was first with Jetpack 7.0, but JP7.0 did not support Jetson Orin which is why we left the jetpack target in the code base to support JP6.2 / Orin as long as there were PyTorch builds available. With JP 7.2, Orin should be also aligned on SBSA and likely we will remove the jetpack target in the future and support SBSA, Thor and Orin via the aarch64_linux target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants