Skip to content

Cannot import torch_tensorrt Python package declared as dependency #2780

Closed as not planned
@gfringeli

Description

@gfringeli

🐞 bug report

Affected Rule

py_binary in our case, but potentially others.

Is this a regression?

Unknown. We did not use torch_tensorrt before.

Description

We are unable to use torch_tensorrt as a Python dependency in our Bazel (version 8.0.1) project. Our py_binary is being built without any issue but on execution of import torch_tensorrt leads to a ModuleNotFoundError.
Importing other packages, like torch works.

🔬 Minimal Reproduction

I created a minimal setup here: https://github.com/scanvio/bazel-torch-tensorrt

🔥 Exception or Error


Traceback (most recent call last):
  File "***redacted***/execroot/_main/bazel-out/k8-fastbuild/bin/dummy_torch_tensorrt.runfiles/_main/dummy_torch_tensorrt.py", line 1, in 
    import torch_tensorrt
ModuleNotFoundError: No module named 'torch_tensorrt'

🌍 Your Environment

Operating System:

  
Ubuntu 24.04
  

Output of bazel version:

  
Bazelisk version: v1.20.0
Build label: 8.0.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Fri Jan 17 19:16:16 2025 (1737141376)
Build timestamp: 1737141376
Build timestamp as int: 1737141376
  

Rules_python version:

  
1.3.0
  

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions