From 450c2be611629b761231ef66ba4f9eac511cbe94 Mon Sep 17 00:00:00 2001 From: Antoine RICHARD Date: Wed, 30 Sep 2026 15:54:17 +0200 Subject: [PATCH 1/3] Default --device to cpu on macOS --- .../antoiner-feat-macos-cpu-device-default.rst | 5 +++++ .../isaaclab_physx/app/kit_launcher.py | 12 ++++++++---- source/isaaclab_physx/test/app/test_kit_launcher.py | 13 +++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 source/isaaclab_physx/changelog.d/antoiner-feat-macos-cpu-device-default.rst diff --git a/source/isaaclab_physx/changelog.d/antoiner-feat-macos-cpu-device-default.rst b/source/isaaclab_physx/changelog.d/antoiner-feat-macos-cpu-device-default.rst new file mode 100644 index 000000000000..169f3d93e50f --- /dev/null +++ b/source/isaaclab_physx/changelog.d/antoiner-feat-macos-cpu-device-default.rst @@ -0,0 +1,5 @@ +Changed +^^^^^^^ + +* Changed the ``--device`` default to ``cpu`` on macOS, which has no CUDA, so commands run without + passing ``--device cpu``. Other platforms still default to ``cuda:0``. diff --git a/source/isaaclab_physx/isaaclab_physx/app/kit_launcher.py b/source/isaaclab_physx/isaaclab_physx/app/kit_launcher.py index 8c85b422b2e6..f53757a0d945 100644 --- a/source/isaaclab_physx/isaaclab_physx/app/kit_launcher.py +++ b/source/isaaclab_physx/isaaclab_physx/app/kit_launcher.py @@ -79,8 +79,8 @@ def _sanitize_sys_argv_for_kit(argv: list[str]) -> list[str]: class _StoreAndMarkExplicit(argparse.Action): """Store the value and set ``_explicit``, for options whose default must stay a real value. - ``--device`` defaults to ``"cuda:0"`` because scripts read ``args_cli.device`` before launch, yet XR - needs to know whether it was passed (see :meth:`KitLauncher._resolve_device_settings`). + ``--device`` defaults to ``"cuda:0"`` (``"cpu"`` on macOS) because scripts read ``args_cli.device`` before + launch, yet XR needs to know whether it was passed (see :meth:`KitLauncher._resolve_device_settings`). """ def __call__(self, parser, namespace, values, option_string=None): @@ -359,8 +359,12 @@ def add_launcher_args(parser: argparse.ArgumentParser) -> None: "--device", type=str, action=_StoreAndMarkExplicit, - default="cuda:0", - help='The device to run the simulation on. Can be "cpu", "cuda", "cuda:N", where N is the device ID', + # macOS has no CUDA; checked without importing torch, which must load after Kit + default="cpu" if sys.platform == "darwin" else "cuda:0", + help=( + 'The device to run the simulation on. Can be "cpu", "cuda", "cuda:N", where N is the device ID.' + ' Defaults to "cuda:0", or "cpu" on macOS.' + ), ) arg_group.add_argument( "--visualizer", diff --git a/source/isaaclab_physx/test/app/test_kit_launcher.py b/source/isaaclab_physx/test/app/test_kit_launcher.py index ecdae2ef34f6..09c57a1cbd44 100644 --- a/source/isaaclab_physx/test/app/test_kit_launcher.py +++ b/source/isaaclab_physx/test/app/test_kit_launcher.py @@ -37,6 +37,19 @@ def _launcher_after_output_resolution(**state) -> KitLauncher: return launcher +@pytest.mark.parametrize(("platform", "expected"), [("linux", "cuda:0"), ("win32", "cuda:0"), ("darwin", "cpu")]) +def test_device_defaults_to_cpu_on_macos(platform, expected, monkeypatch): + """Default ``--device`` to the CPU on macOS, which has no CUDA, and to the first GPU elsewhere.""" + monkeypatch.setattr(sys, "platform", platform) + parser = argparse.ArgumentParser() + KitLauncher.add_launcher_args(parser) + + args = parser.parse_args([]) + + assert args.device == expected + assert not getattr(args, "device_explicit", False) + + def test_sanitize_sys_argv_removes_trailing_pytest_verbosity(monkeypatch): """Remove a pytest verbosity flag even when it is the final argument.""" monkeypatch.setitem(sys.modules, "pytest", object()) From e6e562c004db21b585271c5ba30d5a5af0603371 Mon Sep 17 00:00:00 2001 From: Antoine RICHARD Date: Wed, 30 Sep 2026 18:53:45 +0200 Subject: [PATCH 2/3] Drop the macOS device default test --- source/isaaclab_physx/test/app/test_kit_launcher.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/source/isaaclab_physx/test/app/test_kit_launcher.py b/source/isaaclab_physx/test/app/test_kit_launcher.py index 09c57a1cbd44..ecdae2ef34f6 100644 --- a/source/isaaclab_physx/test/app/test_kit_launcher.py +++ b/source/isaaclab_physx/test/app/test_kit_launcher.py @@ -37,19 +37,6 @@ def _launcher_after_output_resolution(**state) -> KitLauncher: return launcher -@pytest.mark.parametrize(("platform", "expected"), [("linux", "cuda:0"), ("win32", "cuda:0"), ("darwin", "cpu")]) -def test_device_defaults_to_cpu_on_macos(platform, expected, monkeypatch): - """Default ``--device`` to the CPU on macOS, which has no CUDA, and to the first GPU elsewhere.""" - monkeypatch.setattr(sys, "platform", platform) - parser = argparse.ArgumentParser() - KitLauncher.add_launcher_args(parser) - - args = parser.parse_args([]) - - assert args.device == expected - assert not getattr(args, "device_explicit", False) - - def test_sanitize_sys_argv_removes_trailing_pytest_verbosity(monkeypatch): """Remove a pytest verbosity flag even when it is the final argument.""" monkeypatch.setitem(sys.modules, "pytest", object()) From 6ba0189e5fc1c0c2dc4a40fff748657e2874008e Mon Sep 17 00:00:00 2001 From: Antoine RICHARD Date: Thu, 1 Oct 2026 17:53:01 +0200 Subject: [PATCH 3/3] Warn when macOS defaults --device to cpu --- .../antoiner-feat-macos-cpu-device-default.changed.rst | 2 ++ source/isaaclab/isaaclab/app/sim_launcher.py | 3 +++ .../antoiner-feat-macos-cpu-device-default.changed.rst | 2 ++ .../changelog.d/antoiner-feat-macos-cpu-device-default.rst | 5 ----- 4 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 source/isaaclab/changelog.d/antoiner-feat-macos-cpu-device-default.changed.rst create mode 100644 source/isaaclab_physx/changelog.d/antoiner-feat-macos-cpu-device-default.changed.rst delete mode 100644 source/isaaclab_physx/changelog.d/antoiner-feat-macos-cpu-device-default.rst diff --git a/source/isaaclab/changelog.d/antoiner-feat-macos-cpu-device-default.changed.rst b/source/isaaclab/changelog.d/antoiner-feat-macos-cpu-device-default.changed.rst new file mode 100644 index 000000000000..c73ef16db05f --- /dev/null +++ b/source/isaaclab/changelog.d/antoiner-feat-macos-cpu-device-default.changed.rst @@ -0,0 +1,2 @@ +* Changed :func:`~isaaclab.app.launch_simulation` to warn when it runs on the CPU because ``--device`` was not + given on macOS. diff --git a/source/isaaclab/isaaclab/app/sim_launcher.py b/source/isaaclab/isaaclab/app/sim_launcher.py index e0d47fdd47ed..27d9f0265f0f 100644 --- a/source/isaaclab/isaaclab/app/sim_launcher.py +++ b/source/isaaclab/isaaclab/app/sim_launcher.py @@ -594,6 +594,9 @@ def launch_simulation( # Resolve the device before any launcher or physics init: --device, else this rank's GPU, else the config's. _resolve_distributed_device(args) + if sys.platform == "darwin" and args.get("device") == "cpu" and not args.get("device_explicit", False): + # the --device default on macOS, which has no CUDA + logger.warning("No --device given; using 'cpu' because macOS has no CUDA.") if sim_cfg is not None: args["device"] = args.get("device") or sim_cfg.device # Decide the visualizers once, into the SimulationCfg. diff --git a/source/isaaclab_physx/changelog.d/antoiner-feat-macos-cpu-device-default.changed.rst b/source/isaaclab_physx/changelog.d/antoiner-feat-macos-cpu-device-default.changed.rst new file mode 100644 index 000000000000..e26abbf71310 --- /dev/null +++ b/source/isaaclab_physx/changelog.d/antoiner-feat-macos-cpu-device-default.changed.rst @@ -0,0 +1,2 @@ +* Changed the ``--device`` default to ``cpu`` on macOS, which has no CUDA, so commands run without passing + ``--device cpu``. Other platforms still default to ``cuda:0``. diff --git a/source/isaaclab_physx/changelog.d/antoiner-feat-macos-cpu-device-default.rst b/source/isaaclab_physx/changelog.d/antoiner-feat-macos-cpu-device-default.rst deleted file mode 100644 index 169f3d93e50f..000000000000 --- a/source/isaaclab_physx/changelog.d/antoiner-feat-macos-cpu-device-default.rst +++ /dev/null @@ -1,5 +0,0 @@ -Changed -^^^^^^^ - -* Changed the ``--device`` default to ``cpu`` on macOS, which has no CUDA, so commands run without - passing ``--device cpu``. Other platforms still default to ``cuda:0``.