Skip to content

Commit

Permalink
Add GPU support for shell script based executables
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Jun 8, 2023
1 parent 4e11642 commit 932ee35
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 9 additions & 12 deletions pyiron_base/jobs/job/extension/executable.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,32 +217,29 @@ def executable_path(self, new_path):
else:
self.storage.mpi = False

def get_input_for_subprocess_call(self, cores, threads):
def get_input_for_subprocess_call(self, cores, threads, gpus=None):
"""
Get the input parameters for the subprocess call to execute the job
Args:
cores (int): number of cores
threads (int): number of threads
gpus (int/None): number of gpus
Returns:
str/ list, boolean: executable and shell variables
"""
if cores == 1 or not self.mpi:
executable = self.__str__()
shell = True
elif isinstance(self.executable_path, list):
executable = self.executable_path[:] + [
str(cores),
str(threads),
]
shell = False
else:
executable = [
self.executable_path,
str(cores),
str(threads),
]
if isinstance(self.executable_path, list):
executable = self.executable_path[:]
else:
executable = [self.executable_path]
executable += [str(cores), str(threads)]
if gpus is not None:
executable += [str(gpus)]
shell = False
return executable, shell

Expand Down
2 changes: 1 addition & 1 deletion pyiron_base/jobs/job/runfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def execute_job_with_external_executable(job):
raise ValueError("No executable set!")
job.status.running = True
executable, shell = job.executable.get_input_for_subprocess_call(
cores=job.server.cores, threads=job.server.threads
cores=job.server.cores, threads=job.server.threads, gpus=job.server.gpus
)
job_crashed, out = False, None
try:
Expand Down

0 comments on commit 932ee35

Please sign in to comment.