Skip to content

Commit

Permalink
Fix broken torch._inductor.config import (#104477)
Browse files Browse the repository at this point in the history
This fixes the bug in profiler code exposed by  #104368 that introduced on the fact that `import torch._dynamo` also imports `torch._inductor.config`:
```
$ python -c "import torch._inductor;print(torch._inductor.config)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'torch._inductor' has no attribute 'config'
(base) $ python -c "import torch._dynamo;print(torch._inductor.config)"
<module 'torch._inductor.config' from '/home/nshulga/git/pytorch/pytorch/torch/_inductor/config.py'>
```

### Testing
D47159397

Pull Request resolved: #104477
Approved by: https://github.com/aaronenyeshi, https://github.com/malfet
  • Loading branch information
huydhn authored and pytorchmergebot committed Jul 1, 2023
1 parent d6f1827 commit b3e60ee
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions torch/profiler/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ def start_trace(self):
if (
is_cuda11_or_lower
and hasattr(torch, '_inductor')
and torch._inductor.config.triton.cudagraphs
):
os.environ["DISABLE_CUPTI_LAZY_REINIT"] = "1"
self.add_metadata_json("DISABLE_CUPTI_LAZY_REINIT", "1")
import torch._inductor.config as inductor_config
if inductor_config.triton.cudagraphs:
os.environ["DISABLE_CUPTI_LAZY_REINIT"] = "1"
self.add_metadata_json("DISABLE_CUPTI_LAZY_REINIT", "1")

def stop_trace(self):
assert self.profiler is not None
Expand Down

0 comments on commit b3e60ee

Please sign in to comment.