(cmd, cwd=".")
| 606 | |
| 607 | |
| 608 | def execute_cmd(cmd, cwd="."): |
| 609 | env = environ.copy() # Copy the current environment |
| 610 | env["LD_LIBRARY_PATH"] = str(NSYS_PATH.parent) |
| 611 | logger.debug(f"Running command: {cmd}") |
| 612 | |
| 613 | with subprocess.Popen( |
| 614 | cmd, |
| 615 | cwd=cwd, |
| 616 | shell=True, |
| 617 | stdout=subprocess.PIPE, |
| 618 | stderr=subprocess.PIPE, |
| 619 | env=env, |
| 620 | ) as process: |
| 621 | cmd_out, cmd_err = process.communicate() |
| 622 | cmd_out_decoded = cmd_out.strip().decode("utf-8", errors="replace") |
| 623 | cmd_error_decoded = cmd_err.strip().decode("utf-8", errors="replace") |
| 624 | |
| 625 | for line in cmd_out_decoded.split("\n"): |
| 626 | logger.info(line) |
| 627 | |
| 628 | for line in cmd_error_decoded.split("\n"): |
| 629 | if line: |
| 630 | logger.warning(line) |
| 631 | |
| 632 | return_code = process.returncode |
| 633 | if return_code != 0: |
| 634 | logger.fatal(cmd_error_decoded) |
| 635 | raise Exception('Error running command: "%s", rc: %d' % (cmd, return_code)) |
| 636 | |
| 637 | return cmd_out_decoded, cmd_error_decoded, return_code |
| 638 | |
| 639 | |
| 640 | def _get_program_output_spec(exported_program) -> list[torch.Tensor]: |
no test coverage detected