Jovan Andonov
Jovan Andonov

Reputation: 446

Turn off console logging for Hydra when using Pytorch Lightning

Is there a way to turn off console logging for Hydra, but keep file logging? I am encountering a problem where Hydra is duplicating all my console prints. These prints are handled by Pytorch Lightning and I want them to stay like that. However, I am fine with hydra logging them to a file (once per print), but I do not want to see my prints twice in the console.

Upvotes: 1

Views: 2080

Answers (2)

Jieru Hu
Jieru Hu

Reputation: 184

I think we have a similar issue here https://github.com/facebookresearch/hydra/issues/1012

Have you tried setting

hydra/job_logging=none
hydra/hydra_logging=none

as suggested in the issue and see if works better for you?

Upvotes: 1

Jovan Andonov
Jovan Andonov

Reputation: 446

I struggled a bit with the hydra documentation which is why I wanted to write a detailed explanation here so that other people can have it easy. In order to be able to use the answer proposed by @j_hu, i.e.:

hydra/job_logging=none
hydra/hydra_logging=none

with hydra 1.0 (which is the stable version at the time I am writing this answer) you need to first:

  1. Create a directory called hydra within your config directory.
  2. Create two subdirectories: job_logging and hydra_logging.
  3. Create two none.yaml files in both of those directories as described below.
# @package _group_
version: 1
root: null
disable_existing_loggers: false

After this is done, you can use the none.yaml configuration to either override the logging via the command line:

python main.py hydra/job_logging=none hydra/hydra_logging=none

or via the config.yaml file:

defaults:
  - hydra/hydra_logging: none
  - hydra/job_logging: none

Upvotes: 0

Related Questions