I’ve used setup.py to create a package of my code. The training script is a module that I invoke with “python -m”. Incidentally, it also uses hydra and so it’s command line args are a diff format:
python -m train.py arg1=foo arg1.bar=foo

How do I use torch.utils.bottleneck to profile my code?
$ python -m torch.utils.bottleneck train.py
Running environment analysis...
Running your script with cProfile
Traceback (most recent call last):
  File "/home/shrek/anaconda3/envs/cloud/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/shrek/anaconda3/envs/cloud/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/shrek/anaconda3/envs/cloud/lib/python3.8/site-packages/torch/utils/bottleneck/__main__.py", line 231, in <module>
    main()
  File "/home/shrek/anaconda3/envs/cloud/lib/python3.8/site-packages/torch/utils/bottleneck/__main__.py", line 209, in main
    cprofile_prof = run_cprofile(code, globs)
  File "/home/shrek/anaconda3/envs/cloud/lib/python3.8/site-packages/torch/utils/bottleneck/__main__.py", line 74, in run_cprofile
    exec(code, globs, None)
  File "train.py", line 17, in <module>
    from .config_parse.train import TrainScriptConfig
ImportError: attempted relative import with no known parent package