Skip to content

Commit

Permalink
Fix num_processes is not defined (#746)
Browse files Browse the repository at this point in the history
* Fix num_processes is not defined

* Also reorganize questions

Co-authored-by: Sylvain Gugger <[email protected]>
  • Loading branch information
muellerzr and sgugger committed Oct 7, 2022
1 parent a54cd0a commit 2ef7973
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/accelerate/commands/config/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def get_cluster_input():

machine_rank = 0
num_machines = 1
num_processes = 1
gpu_ids = None
main_process_ip = None
main_process_port = None
Expand Down Expand Up @@ -294,12 +295,6 @@ def get_cluster_input():
default=1,
error_message="Please enter an integer.",
)

if distributed_type in [DistributedType.MULTI_GPU, DistributedType.NO] and not use_cpu:
gpu_ids = _ask_field(
"What GPU(s) (by id) should be used for training on this machine as a comma-seperated list? [all]:",
default="all",
)
elif distributed_type in [DistributedType.FSDP, DistributedType.DEEPSPEED]:
num_processes = _ask_field(
"How many GPU(s) should be used for distributed training? [1]:",
Expand All @@ -310,6 +305,12 @@ def get_cluster_input():
else:
num_processes = 1

if distributed_type in [DistributedType.MULTI_GPU, DistributedType.NO] and not use_cpu:
gpu_ids = _ask_field(
"What GPU(s) (by id) should be used for training on this machine as a comma-seperated list? [all]:",
default="all",
)

if distributed_type != DistributedType.TPU:
if distributed_type == DistributedType.DEEPSPEED and use_deepspeed_config:
mixed_precision = "no"
Expand Down

0 comments on commit 2ef7973

Please sign in to comment.