diff --git a/src/ansys/fluent/core/launcher/fluent_launcher_options.json b/src/ansys/fluent/core/launcher/fluent_launcher_options.json index 2aa887af9a74..33dd36b15b86 100644 --- a/src/ansys/fluent/core/launcher/fluent_launcher_options.json +++ b/src/ansys/fluent/core/launcher/fluent_launcher_options.json @@ -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={}" diff --git a/src/ansys/fluent/core/launcher/launcher.py b/src/ansys/fluent/core/launcher/launcher.py index d21fd1b6fa64..9c52addfd572 100644 --- a/src/ansys/fluent/core/launcher/launcher.py +++ b/src/ansys/fluent/core/launcher/launcher.py @@ -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, @@ -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 diff --git a/src/ansys/fluent/core/launcher/launcher_utils.py b/src/ansys/fluent/core/launcher/launcher_utils.py index 1105970b7de0..317334452905 100644 --- a/src/ansys/fluent/core/launcher/launcher_utils.py +++ b/src/ansys/fluent/core/launcher/launcher_utils.py @@ -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 diff --git a/tests/test_launcher.py b/tests/test_launcher.py index 20762f5c4132..70361e391e9a 100644 --- a/tests/test_launcher.py +++ b/tests/test_launcher.py @@ -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): @@ -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():