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/isaaclab_physx/app/kit_launcher.py b/source/isaaclab_physx/isaaclab_physx/app/kit_launcher.py index 2431b9d85d6f..4f452ab29637 100644 --- a/source/isaaclab_physx/isaaclab_physx/app/kit_launcher.py +++ b/source/isaaclab_physx/isaaclab_physx/app/kit_launcher.py @@ -82,8 +82,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): @@ -358,8 +358,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",