Skip to content

Commit

Permalink
PyTorch Python fork fix part 2 (ROCm#292)
Browse files Browse the repository at this point in the history
PyTorch Python fork fix part 2

- store script file in environment for robustness against restart after fork
  • Loading branch information
jrmadsen authored Jun 22, 2023
1 parent a85f141 commit 6c9b66d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/python/omnitrace/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ def main(main_args=sys.argv):
sys.path.insert(0, os.path.dirname(script_file))

_OMNITRACE_PYTHON_SCRIPT_FILE = script_file
os.environ["OMNITRACE_PYTHON_SCRIPT_FILE"] = script_file

prof = Profiler()
fake = FakeProfiler()
Expand Down Expand Up @@ -397,6 +398,11 @@ def main(main_args=sys.argv):

if __name__ == "__main__":
args = sys.argv
if _OMNITRACE_PYTHON_SCRIPT_FILE is None:
_OMNITRACE_PYTHON_SCRIPT_FILE = os.environ.get(
"OMNITRACE_PYTHON_SCRIPT_FILE", None
)

if "--" not in args and _OMNITRACE_PYTHON_SCRIPT_FILE is not None:
args = [args[0]] + ["--", _OMNITRACE_PYTHON_SCRIPT_FILE] + args[1:]
os.environ["OMNITRACE_USE_PID"] = "ON"
Expand Down

0 comments on commit 6c9b66d

Please sign in to comment.