Skip to content
Merged
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
10 changes: 0 additions & 10 deletions src/ansys/fluent/core/launcher/fluent_launcher_options.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@
},
"fluent_format": "{}"
},
"gpu": {
"type": "bool",
"default": "null",
"fluent_required": false,
"fluent_map": {
"true": " -gpu",
"false": ""
},
"fluent_format": "{}"
},
"scheduler": {
"type": "str",
"fluent_format": " -scheduler={}"
Expand Down
11 changes: 8 additions & 3 deletions src/ansys/fluent/core/launcher/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def launch_fluent(
lightweight_mode: Optional[bool] = None,
mode: Optional[Union[FluentMode, str, None]] = None,
py: Optional[bool] = None,
gpu: Optional[bool] = None,
gpu: Union[bool, list[int], None] = None,
cwd: Optional[str] = None,
topy: Optional[Union[str, list]] = None,
start_watchdog: Optional[bool] = None,
Expand Down Expand Up @@ -178,8 +178,13 @@ def launch_fluent(
``"pure-meshing"`` and ``"solver"``.
py : bool, optional
If True, Fluent will run in Python mode. Default is None.
gpu : bool, optional
If True, Fluent will start with GPU Solver.
gpu : bool or list, optional
This option will start Fluent with the GPU Solver. A list of GPU IDs can be
passed to use specific GPUs. If True is passed, the number of GPUs used will be
clamped to the value of ``processor_count``. Please refer to
*Starting the Fluent GPU Solver* section in *Fluent's User Guide* for more
information like how to determine the GPU IDs.

cwd : str, Optional
Working directory for the Fluent client.
topy : bool or str, optional
Expand Down
5 changes: 5 additions & 0 deletions src/ansys/fluent/core/launcher/launcher_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ def _build_fluent_launch_args_string(**kwargs) -> str:
)
if parallel_options:
launch_args_string += " " + parallel_options
gpu = kwargs.get("gpu")
if gpu is True:
launch_args_string += " -gpu"
elif isinstance(gpu, list):
launch_args_string += f" -gpu={','.join(map(str, gpu))}"
return launch_args_string


Expand Down
14 changes: 12 additions & 2 deletions tests/test_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ def test_gpu_launch_arg(helpers, monkeypatch):
with pytest.raises(LaunchFluentError) as error:
pyfluent.launch_fluent(gpu=True, start_timeout=0)

assert "-gpu" in str(error.value).split()
assert " -gpu" in str(error.value)

with pytest.raises(LaunchFluentError) as error:
pyfluent.launch_fluent(gpu=[1, 2, 4], start_timeout=0)

assert " -gpu=1,2,4" in str(error.value)


def test_gpu_launch_arg_additional_arg(helpers, monkeypatch):
Expand All @@ -158,7 +163,12 @@ def test_gpu_launch_arg_additional_arg(helpers, monkeypatch):
with pytest.raises(LaunchFluentError) as error:
pyfluent.launch_fluent(additional_arguments="-gpu", start_timeout=0)

assert "-gpu" in str(error.value).split()
assert " -gpu" in str(error.value)

with pytest.raises(LaunchFluentError) as error:
pyfluent.launch_fluent(additional_arguments="-gpu=1,2,4", start_timeout=0)

assert " -gpu=1,2,4" in str(error.value)


def test_kwargs():
Expand Down