Skip to content

feat: limit RAM usage in bazel build#4418

Merged
zewenli98 merged 2 commits into
mainfrom
evanli/limit_ram_usage_while_building
Jul 21, 2026
Merged

feat: limit RAM usage in bazel build#4418
zewenli98 merged 2 commits into
mainfrom
evanli/limit_ram_usage_while_building

Conversation

@zewenli98

Copy link
Copy Markdown
Collaborator

Description

When building torch-trt from source, the bazel often gets stuck and gets OOM if memory is limited, as it runs 32 actions in parallel. This PR defaults to:

build --jobs=6
build --local_resources=memory=HOST_RAM*.7

It caps concurrent actions and let bazel schedule against a RAM budget. Feel free to tune --jobs up/down based on how much headroom free -g shows during a build.

Fixes # (issue)

Type of change

  • New feature (non-breaking change which adds functionality)

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

@zewenli98
zewenli98 requested a review from narendasan July 17, 2026 23:15
@zewenli98 zewenli98 self-assigned this Jul 17, 2026
@meta-cla meta-cla Bot added the cla signed label Jul 17, 2026
@zewenli98 zewenli98 changed the title feat: limit ram usage while building the proj feat: limit RAM usage in bazel build Jul 17, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to Python style guidelines:

--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/lowering/passes/eliminate_sym_min_int64_max.py	2026-07-17 23:16:00.055965+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/lowering/passes/eliminate_sym_min_int64_max.py	2026-07-17 23:16:20.971622+00:00
@@ -2,11 +2,10 @@

import torch
from torch.fx import GraphModule, Node

from .pass_utils import clean_up_graph_after_modifications
-

_INT64_MAX = 2**63 - 1
_SYM_MIN = getattr(torch, "sym_min", None)

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to Python style guidelines:

--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/lowering/passes/eliminate_sym_min_int64_max.py	2026-07-17 23:15:58.273713+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/lowering/passes/eliminate_sym_min_int64_max.py	2026-07-17 23:16:23.806062+00:00
@@ -2,11 +2,10 @@

import torch
from torch.fx import GraphModule, Node

from .pass_utils import clean_up_graph_after_modifications
-

_INT64_MAX = 2**63 - 1
_SYM_MIN = getattr(torch, "sym_min", None)

Comment thread .bazelrc.user Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are user specific I think we shouldnt check them in. Can be in gitignore We can just use the try-import to pull them in optionally

@narendasan

Copy link
Copy Markdown
Collaborator

Also we should note this in the contributors.md

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to Python style guidelines:

--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/lowering/passes/eliminate_sym_min_int64_max.py	2026-07-20 22:00:23.549974+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/lowering/passes/eliminate_sym_min_int64_max.py	2026-07-20 22:00:49.322440+00:00
@@ -2,11 +2,10 @@

import torch
from torch.fx import GraphModule, Node

from .pass_utils import clean_up_graph_after_modifications
-

_INT64_MAX = 2**63 - 1
_SYM_MIN = getattr(torch, "sym_min", None)

@zewenli98
zewenli98 requested a review from narendasan July 21, 2026 17:36

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some changes that do not conform to Python style guidelines:

--- /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/lowering/passes/eliminate_sym_min_int64_max.py	2026-07-21 17:36:54.940975+00:00
+++ /home/runner/work/TensorRT/TensorRT/py/torch_tensorrt/dynamo/lowering/passes/eliminate_sym_min_int64_max.py	2026-07-21 17:37:23.111643+00:00
@@ -2,11 +2,10 @@

import torch
from torch.fx import GraphModule, Node

from .pass_utils import clean_up_graph_after_modifications
-

_INT64_MAX = 2**63 - 1
_SYM_MIN = getattr(torch, "sym_min", None)

@narendasan narendasan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zewenli98
zewenli98 merged commit af7d134 into main Jul 21, 2026
134 of 150 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants