Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup multiprocessing environment variables #122

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions quadra/configs/hydra/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ hydra:
exclude_keys:
- trainer.devices
chdir: true
env_set:
OMP_NUM_THREADS: 8
OPENBLAS_NUM_THREADS: 8
MKL_NUM_THREADS: 8
VECLIB_MAXIMUM_THREADS: 8
NUMEXPR_NUM_THREADS: 8
23 changes: 14 additions & 9 deletions quadra/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,35 @@

import hydra
from omegaconf import DictConfig
from pytorch_lightning import seed_everything

from quadra.tasks.base import Task
from quadra.utils.resolver import register_resolvers
from quadra.utils.utils import get_logger, load_envs, setup_opencv
from quadra.utils.validator import validate_config

load_envs()
register_resolvers()

log = get_logger(__name__)


# pylint: disable=import-outside-toplevel
@hydra.main(config_path="configs/", config_name="config.yaml", version_base="1.3.0")
def main(config: DictConfig):
"""Main entry function for any of the tasks."""
# Import everything here to allow setting environment variables before importing torch
import torch
from pytorch_lightning import seed_everything

from quadra.tasks import Task
from quadra.utils import utils
from quadra.utils.utils import get_logger, load_envs, setup_opencv
from quadra.utils.validator import validate_config

log = get_logger(__name__)
log.debug("Running with %d torch threads: ", torch.get_num_threads())

load_envs()
if config.validate:
start = time.time()
validate_config(config)
stop = time.time()
log.info("Config validation took %f seconds", stop - start)

from quadra.utils import utils # pylint: disable=import-outside-toplevel

utils.extras(config)

# Prints the resolved configuration to the console
Expand Down
Loading