[Proposal] RL agents should default to the environment's device
Proposal
Make every RL framework's agent run on the environment's device unless the agent configuration sets a device explicitly.
For example, the agent device fields would default to None, meaning "use the env's device", in the same way for rsl_rl, rl_games, sb3, skrl and torchrl. An explicit value would keep today's ability to run the policy on a different device than the simulation, e.g. CPU physics with GPU training.
Motivation
The agent device is resolved differently per framework (develop @ 9c572e4):
| Framework | Agent device source | Follows the env? |
|---|---|---|
| rsl_rl | RslRlBaseRunnerCfg.device = "cuda:0" (isaaclab_rl/rsl_rl/rl_cfg.py:239) |
Only for --distributed (train_rsl_rl.py:132) |
| rl_games | Task YAML config.device: cuda:0 (all 34 rl_games agent configs) |
Only for --distributed (train_rl_games.py:124) |
| sb3 | Task YAML device: "cuda:0" (2 of 5 configs); SB3's "auto" otherwise |
No |
| torchrl | Config default "cuda:0", overwritten with the env device |
Yes, always (train_torchrl.py:83) |
| skrl | Its wrapper reads env.device |
Yes, always |
Running the agent and the env on different devices works: rsl_rl moves observations, rewards and dones to the agent device every step, and the sb3 wrapper moves actions back to the simulation device. So the split is a feature, but for rsl_rl, rl_games and sb3 it is the default, which is surprising:
--device cpuon a GPU machine simulates on the CPU but trains rsl_rl / rl_games / sb3 policies oncuda:0. Nothing reports it, and the same command trains on the CPU with skrl or torchrl.--device cuda:1without--distributedsimulates on GPU 1 but trains on GPU 0. Every step then copies data between the two GPUs. Users have hit this: isaac-sim/IsaacLab#2148 was closed with workarounds (set the agent device, orCUDA_VISIBLE_DEVICES), but the default still applies.- Hosts without CUDA (macOS) crash with
AssertionError: Torch not compiled with CUDA enabledwhen building the agent, even with--device cpu. isaac-sim/IsaacLab#8188 works around this for rsl_rl only: it falls back to the env device, with a warning, when CUDA is unavailable. rl_games and the sb3 configs that pincuda:0still fail.
Alternatives
- Keep the per-framework behavior, and patch missing CUDA per framework (as isaac-sim/IsaacLab#8188 does for rsl_rl). This is minimal, but it leaves the
--device cpu/--device cuda:1surprises and three different behaviors. - Always force the agent onto the env device, like torchrl. This is simple, but it removes the CPU-physics / GPU-training option.
- Make
--deviceset both, and add a separate--agent_deviceflag. This is more explicit but adds CLI surface.
Build Info
- Isaac Lab Version:
develop@9c572e4 - Isaac Sim Version: n/a
Additional context
Found while adding experimental macOS (CPU-only) support: isaac-sim/IsaacLab#8188, isaac-sim/IsaacLab#8191.
Changing the default is a behavior change for rsl_rl, rl_games and sb3 users who run --device cpu on a GPU machine. They would get CPU training unless they set the agent device explicitly, so it needs a changelog entry, and possibly a one-time notice.
Checklist
- I have checked that there is no similar issue in the repo (required)
Acceptance Criteria
- rsl_rl, rl_games, sb3, skrl and torchrl resolve the agent device the same way: the env device by default, or an explicit agent device when configured.
- Task agent configs no longer hardcode
cuda:0unless a task needs a specific device. - Train and play run on a host without CUDA for every framework, making the rsl_rl-only fallback in isaac-sim/IsaacLab#8188 unnecessary.
- The behavior change is documented in the changelog.
Source: isaac-sim/IsaacLab