Skip to content

Commit

Permalink
Add gpus-per-node to job scripts and resources
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Jul 25, 2024
1 parent 1ba1091 commit 560b620
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion compass/job/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ def write_job_script(config, machine, target_cores, min_cores, work_dir,
job_name = 'compass'
else:
job_name = f'compass_{suite}'

if config.has_option('parallel', 'gpus_per_node'):
gpus_per_node = config.get('parallel', 'gpus_per_node')
else:
gpus_per_node = ''

wall_time = config.get('job', 'wall_time')

template = Template(resources.read_text(
Expand All @@ -96,7 +102,8 @@ def write_job_script(config, machine, target_cores, min_cores, work_dir,
text = template.render(job_name=job_name, account=account,
nodes=f'{nodes}', wall_time=wall_time, qos=qos,
partition=partition, constraint=constraint,
suite=suite, pre_run_commands=pre_run_commands,
gpus_per_node=gpus_per_node, suite=suite,
pre_run_commands=pre_run_commands,
post_run_commands=post_run_commands)
text = _clean_up_whitespace(text)
if suite == '':
Expand Down
3 changes: 3 additions & 0 deletions compass/job/job_script.template
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
{% if constraint != '' -%}
#SBATCH --constraint={{ constraint }}
{%- endif %}
{% if gpus_per_node != '' -%}
#SBATCH --gpus-per-node={{ gpus_per_node }}
{%- endif %}

source load_compass_env.sh
{{ pre_run_commands }}
Expand Down
5 changes: 5 additions & 0 deletions compass/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def get_available_parallel_resources(config):
cores_per_node=cores_per_node,
mpi_allowed=mpi_allowed
)

if config.has_option('parallel', 'gpus_per_node'):
available_resources['gpus_per_node'] = \
config.getint('parallel', 'gpus_per_node')

return available_resources


Expand Down

0 comments on commit 560b620

Please sign in to comment.