plasma-umass / scalene

Scalene: a high-performance, high-precision CPU, GPU, and memory profiler for Python with AI-powered optimization proposals
Apache License 2.0
12.19k stars 399 forks source link

Running hydra configured scripts #412

Open SolomidHero opened 2 years ago

SolomidHero commented 2 years ago

Is your feature request related to a problem? Please describe. It is impossible to run profiling on hydra (https://github.com/facebookresearch/hydra) configured python scripts. Hydra scripts often runs in such manner:

python script.py param1=1 param2='a'

Describe the solution you'd like Great solution proposed in readme:

scalene (...) --- script.py param1=1 param2='a'

But next error:

    main()
  File "/usr/local/lib/python3.9/site-packages/hydra/main.py", line 90, in decorated_main
    _run_hydra(
  File "/usr/local/lib/python3.9/site-packages/hydra/_internal/utils.py", line 389, in _run_hydra
    _run_app(
  File "/usr/local/lib/python3.9/site-packages/hydra/_internal/utils.py", line 452, in _run_app
    run_and_report(
  File "/usr/local/lib/python3.9/site-packages/hydra/_internal/utils.py", line 216, in run_and_report
    raise ex
  File "/usr/local/lib/python3.9/site-packages/hydra/_internal/utils.py", line 213, in run_and_report
    return func()
  File "/usr/local/lib/python3.9/site-packages/hydra/_internal/utils.py", line 453, in <lambda>
    lambda: hydra.run(
  File "/usr/local/lib/python3.9/site-packages/hydra/_internal/hydra.py", line 105, in run
    cfg = self.compose_config(
  File "/usr/local/lib/python3.9/site-packages/hydra/_internal/hydra.py", line 594, in compose_config
    cfg = self.config_loader.load_configuration(
  File "/usr/local/lib/python3.9/site-packages/hydra/_internal/config_loader_impl.py", line 141, in load_configuration
    return self._load_configuration_impl(
  File "/usr/local/lib/python3.9/site-packages/hydra/_internal/config_loader_impl.py", line 233, in _load_configuration_impl
    parsed_overrides = parser.parse_overrides(overrides=overrides)
  File "/usr/local/lib/python3.9/site-packages/hydra/core/override_parser/overrides_parser.py", line 96, in parse_overrides
    raise OverrideParseException(
hydra.errors.OverrideParseException: Error parsing override 'script.py'
missing EQUAL at '<EOF>'
See https://hydra.cc/docs/next/advanced/override_grammar/basic for details

It seems that filename used as first argument in spawning process, which hydra parses as key parameter

Describe alternatives you've considered Maybe additional argument to not use program name as argument

Additional context python 3.9.13 hydra-core==1.2.0 scalene==1.5.8

LennardBo commented 2 years ago

I have a related problem with scalene + hydra, only that in my case hydra is unable to find even the (in CLI) given config file:

hydra.errors.MissingConfigException: Cannot find primary config '....'. Check that it's in your config search path.

I'm just wondering, has anyone successfully used scalene with hydra? If it doesn't work, that makes scalene for my team rather useless and would be a major downside, considering hydra's popularity.

Exctues commented 1 year ago

+1 Could someone help to run scalene with hydra? I experience Error executing job with overrides

jiaxuan0313 commented 1 year ago

I also made a similar mistake:

Error parsing override 'python' missing EQUAL at '' See https://hydra.cc/docs/1.2/advanced/override_grammar/basic for details

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.

Does anyone know how to solve it?

selflein commented 3 weeks ago

This seems to work for me

scalene --html --outfile /tmp/out.html  scripts/train.py --- dataset=imagenet ...