Skip to content

Commit

Permalink
Adding gres handling for teach
Browse files Browse the repository at this point in the history
Adding srun's gres parameter handling logic for teach in order to pass the requested gres and set the default num_gpus if not requested when c=teach and p=gpu
  • Loading branch information
yassinkhalifa committed Aug 23, 2024
1 parent a760fb3 commit 77c7d37
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions apps/crc_interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def __init__(self) -> None:
cluster_args = self.add_argument_group('Cluster Arguments')
cluster_args.add_argument('-p', '--partition', help='run the session on a specific partition')
for cluster, abbrev in self.clusters.items():
cluster_args.add_argument(f'-{abbrev}', f'--{cluster}', action='store_true', help=f'launch a session on the {cluster} cluster')
cluster_args.add_argument(f'-{abbrev}', f'--{cluster}', action='store_true',
help=f'launch a session on the {cluster} cluster')

# Arguments for requesting additional hardware resources
resource_args = self.add_argument_group('Arguments for Increased Resources')
Expand Down Expand Up @@ -116,7 +117,7 @@ def parse_args(self, args=None, namespace=None) -> Namespace:

# Set defaults that need to be determined dynamically
if not args.num_gpus:
args.num_gpus = 1 if args.gpu else 0
args.num_gpus = 1 if (args.gpu or (args.teach and (args.partition == 'gpu'))) else 0

# Check wall time is between limits, enable both %H:%M format and integer hours
check_time = args.time.hour + args.time.minute / 60 + args.time.second / 3600
Expand Down Expand Up @@ -171,7 +172,7 @@ def create_srun_command(self, args: Namespace) -> str:
srun_args += ' ' + srun_arg_name.format(arg_value)

# The --gres argument in srun needs some special handling so is missing from the above dict
if (args.gpu or args.invest) and args.num_gpus:
if (args.gpu or args.invest or (args.teach and (args.partition == 'gpu'))) and args.num_gpus:
srun_args += ' ' + f'--gres=gpu:{args.num_gpus}'

try:
Expand Down

0 comments on commit 77c7d37

Please sign in to comment.