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

set "use_cpu" to true in cpu pytorch training benchmark tests (#159) #160

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 optimum_benchmark/backends/pytorch/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,12 @@ def train(
) -> TrainerState:
LOGGER.info(f"\t+ Wrapping training arguments with {TrainingArguments.__name__}")
training_arguments = TrainingArguments(**training_arguments)

if self.config.device == "cpu":
assert training_arguments.use_cpu, f"""backend.device is set to {self.config.device} while use_cpu in training_arguments is set to false (default)
which will make the training run on gpu. Please set benchmark.training.training_arguments.use_cpu to true if the benchmark is intended to run on cpu
"""

LOGGER.info(f"\t+ Wrapping model with {Trainer.__name__}")
trainer = Trainer(
args=training_arguments,
Expand Down
4 changes: 4 additions & 0 deletions tests/configs/cpu_training_pytorch_bert_sweep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ defaults:
- _self_ # hydra 1.1 compatibility

experiment_name: cpu_training_pytorch_bert_sweep

benchmark:
training_arguments:
use_cpu: true
4 changes: 4 additions & 0 deletions tests/configs/cpu_training_pytorch_gpt_sweep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ defaults:
- _self_ # hydra 1.1 compatibility

experiment_name: cpu_training_pytorch_gpt_sweep

benchmark:
training_arguments:
use_cpu: true
Loading