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

Limit the number of pytorch threads #5

Merged
merged 1 commit into from
Nov 18, 2019
Merged
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
4 changes: 4 additions & 0 deletions allentune/modules/allennlp_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import Optional

import pandas as pd
import torch
from allennlp.commands.train import train_model
from allennlp.common.params import Params, parse_overrides, with_fallback
from allennlp.common.util import import_submodules
Expand Down Expand Up @@ -50,6 +51,9 @@ def train_func(config, reporter):
logger.warning(f"No GPU specified, using CPU.")
params_dict["trainer"]["cuda_device"] = -1

if args.cpus_per_trial > 0:
torch.set_num_threads(args.cpus_per_trial)

params = Params(params_dict)

logger.debug(f"AllenNLP Configuration: {params.as_dict()}")
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ray==0.6.2
git+git://github.com/allenai/allennlp@27ebcf6ba3e02afe341a5e62cb1a7d5c6906c0c9
seaborn
pandas
torch

# Testing
pytest
Expand Down