Skip to content

Commit 70a0df4

Browse files
author
Aishwarya Bhandare
committed
GPU metrics only on rank 0
1 parent 9512c3b commit 70a0df4

4 files changed

Lines changed: 18 additions & 3 deletions

File tree

nemo_run/core/execution/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ def get_launcher_prefix(self) -> Optional[list[str]]:
165165
os.makedirs(os.path.join(self.job_dir, launcher.nsys_folder), exist_ok=True)
166166
return launcher.get_nsys_prefix(profile_dir=self.job_dir)
167167

168+
def get_nsys_entrypoint(self) -> str:
169+
return ("nsys","")
170+
168171
def supports_launcher_transform(self) -> bool:
169172
return False
170173

nemo_run/core/execution/launcher.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Launcher(ConfigurableMixin):
2424
"--cuda-event-trace=false",
2525
]
2626
)
27+
nsys_gpu_metrics: bool = False
2728

2829
def get_nsys_prefix(self, profile_dir: str) -> Optional[list[str]]:
2930
"""Make a command prefix for nsys profiling"""

nemo_run/core/execution/slurm.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,18 @@ def assign(
547547
def get_launcher_prefix(self) -> Optional[list[str]]:
548548
launcher = self.get_launcher()
549549
if launcher.nsys_profile:
550-
return launcher.get_nsys_prefix(profile_dir=f"/{RUNDIR_NAME}")
550+
nsys_prefix = launcher.get_nsys_prefix(profile_dir=f"/{RUNDIR_NAME}")
551+
if launcher.nsys_gpu_metrics:
552+
nsys_prefix += ["$GPU_METRICS_FLAG"]
553+
return nsys_prefix
554+
555+
def get_nsys_entrypoint(self) -> str:
556+
launcher = self.get_launcher()
557+
entrypoint, postfix = "nsys", ""
558+
if launcher.nsys_gpu_metrics:
559+
entrypoint="bash -c 'GPU_METRICS_FLAG=\"\"; if [ \"$SLURM_PROCID\" -eq 0 ]; then GPU_METRICS_FLAG=\"--gpu-metrics-devices=all\"; fi; nsys"
560+
postfix="'"
561+
return (entrypoint, postfix)
551562

552563
def supports_launcher_transform(self) -> bool:
553564
return True if isinstance(self.get_launcher(), SlurmTemplate) else False

nemo_run/run/torchx_backend/packaging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ def _get_details_from_script(fn_or_script: Script, serialize_configs: bool):
225225
nsys_prefix = executor.get_launcher_prefix()
226226
if nsys_prefix:
227227
role.args = [role.entrypoint] + role.args
228-
role.entrypoint = "nsys"
229-
role.args = nsys_prefix + role.args
228+
role.entrypoint, nsys_postfix = executor.get_nsys_entrypoint()
229+
role.args = nsys_prefix + role.args + [nsys_postfix]
230230

231231
if metadata:
232232
if USE_WITH_RAY_CLUSTER_KEY in metadata:

0 commit comments

Comments
 (0)