Skip to content

Commit 79fc49d

Browse files
authored
Fixes TiledCamera data types and rlgames training on CPU (#3808)
# Description We were incorrectly converting all numpy array data in the TiledCamera class into uint8 type warp arrays when simulation device is set to CPU. Some annotations like depth are float32 while segmentation data is uint32. The correct behavior should convert to warp arrays depending on the input data type of the numpy array. Additionally, rlgames configs were set to cuda device by default but were not being overridden when users specify the simulation device to CPU through cmdline. We should propagate the device setting to the rlgames configs so that we can run training on the same device, similar to how RSL RL is set up. Fixes #3526 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there <!-- As you go through the checklist above, you can mark something as done by putting an x character in it For example, - [x] I have done this task - [ ] I have not done this task -->
1 parent c0eb55c commit 79fc49d

File tree

11 files changed

+124
-32
lines changed

11 files changed

+124
-32
lines changed

scripts/benchmarks/benchmark_non_rl.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
115115
env_cfg.sim.device = args_cli.device if args_cli.device is not None else env_cfg.sim.device
116116
env_cfg.seed = args_cli.seed
117117

118+
# check for invalid combination of CPU device with distributed training
119+
if args_cli.distributed and args_cli.device is not None and "cpu" in args_cli.device:
120+
raise ValueError(
121+
"Distributed training is not supported when using CPU device. "
122+
"Please use GPU device (e.g., --device cuda) for distributed training."
123+
)
124+
118125
# process distributed
119126
world_size = 1
120127
world_rank = 0

scripts/benchmarks/benchmark_rlgames.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
128128
# override configurations with non-hydra CLI arguments
129129
env_cfg.scene.num_envs = args_cli.num_envs if args_cli.num_envs is not None else env_cfg.scene.num_envs
130130
env_cfg.sim.device = args_cli.device if args_cli.device is not None else env_cfg.sim.device
131+
# check for invalid combination of CPU device with distributed training
132+
if args_cli.distributed and args_cli.device is not None and "cpu" in args_cli.device:
133+
raise ValueError(
134+
"Distributed training is not supported when using CPU device. "
135+
"Please use GPU device (e.g., --device cuda) for distributed training."
136+
)
137+
138+
# update agent device to match simulation device
139+
if args_cli.device is not None:
140+
agent_cfg["params"]["config"]["device"] = args_cli.device
141+
agent_cfg["params"]["config"]["device_name"] = args_cli.device
131142

132143
# randomly sample a seed if seed = -1
133144
if args_cli.seed == -1:

scripts/benchmarks/benchmark_rsl_rl.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
140140
# note: certain randomizations occur in the environment initialization so we set the seed here
141141
env_cfg.seed = agent_cfg.seed
142142
env_cfg.sim.device = args_cli.device if args_cli.device is not None else env_cfg.sim.device
143+
# check for invalid combination of CPU device with distributed training
144+
if args_cli.distributed and args_cli.device is not None and "cpu" in args_cli.device:
145+
raise ValueError(
146+
"Distributed training is not supported when using CPU device. "
147+
"Please use GPU device (e.g., --device cuda) for distributed training."
148+
)
143149

144150
# multi-gpu training configuration
145151
world_rank = 0

scripts/reinforcement_learning/rl_games/play.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
9595
# override configurations with non-hydra CLI arguments
9696
env_cfg.scene.num_envs = args_cli.num_envs if args_cli.num_envs is not None else env_cfg.scene.num_envs
9797
env_cfg.sim.device = args_cli.device if args_cli.device is not None else env_cfg.sim.device
98+
# update agent device to match simulation device
99+
if args_cli.device is not None:
100+
agent_cfg["params"]["config"]["device"] = args_cli.device
101+
agent_cfg["params"]["config"]["device_name"] = args_cli.device
98102

99103
# randomly sample a seed if seed = -1
100104
if args_cli.seed == -1:

scripts/reinforcement_learning/rl_games/train.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
9595
# override configurations with non-hydra CLI arguments
9696
env_cfg.scene.num_envs = args_cli.num_envs if args_cli.num_envs is not None else env_cfg.scene.num_envs
9797
env_cfg.sim.device = args_cli.device if args_cli.device is not None else env_cfg.sim.device
98+
# check for invalid combination of CPU device with distributed training
99+
if args_cli.distributed and args_cli.device is not None and "cpu" in args_cli.device:
100+
raise ValueError(
101+
"Distributed training is not supported when using CPU device. "
102+
"Please use GPU device (e.g., --device cuda) for distributed training."
103+
)
104+
105+
# update agent device to match simulation device
106+
if args_cli.device is not None:
107+
agent_cfg["params"]["config"]["device"] = args_cli.device
108+
agent_cfg["params"]["config"]["device_name"] = args_cli.device
98109

99110
# randomly sample a seed if seed = -1
100111
if args_cli.seed == -1:

scripts/reinforcement_learning/rsl_rl/train.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
118118
# note: certain randomizations occur in the environment initialization so we set the seed here
119119
env_cfg.seed = agent_cfg.seed
120120
env_cfg.sim.device = args_cli.device if args_cli.device is not None else env_cfg.sim.device
121+
# check for invalid combination of CPU device with distributed training
122+
if args_cli.distributed and args_cli.device is not None and "cpu" in args_cli.device:
123+
raise ValueError(
124+
"Distributed training is not supported when using CPU device. "
125+
"Please use GPU device (e.g., --device cuda) for distributed training."
126+
)
121127

122128
# multi-gpu training configuration
123129
if args_cli.distributed:

scripts/reinforcement_learning/skrl/train.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
129129
env_cfg.scene.num_envs = args_cli.num_envs if args_cli.num_envs is not None else env_cfg.scene.num_envs
130130
env_cfg.sim.device = args_cli.device if args_cli.device is not None else env_cfg.sim.device
131131

132+
# check for invalid combination of CPU device with distributed training
133+
if args_cli.distributed and args_cli.device is not None and "cpu" in args_cli.device:
134+
raise ValueError(
135+
"Distributed training is not supported when using CPU device. "
136+
"Please use GPU device (e.g., --device cuda) for distributed training."
137+
)
138+
132139
# multi-gpu training config
133140
if args_cli.distributed:
134141
env_cfg.sim.device = f"cuda:{app_launcher.local_rank}"

source/isaaclab/config/extension.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
# Note: Semantic Versioning is used: https://semver.org/
4-
version = "0.47.1"
4+
version = "0.47.2"
55

66
# Description
77
title = "Isaac Lab framework for Robot Learning"

source/isaaclab/docs/CHANGELOG.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changelog
22
---------
33

4+
0.47.2 (2025-10-22)
5+
~~~~~~~~~~~~~~~~~~~
6+
7+
Changed
8+
^^^^^^^
9+
10+
* Fixed the data type conversion in :class:`~isaaclab.sensors.tiled_camera.TiledCamera` to
11+
support the correct data type when converting from numpy arrays to warp arrays on the CPU.
12+
13+
414
0.47.1 (2025-10-17)
515
~~~~~~~~~~~~~~~~~~~
616

source/isaaclab/isaaclab/sensors/camera/tiled_camera.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ def _update_buffers_impl(self, env_ids: Sequence[int]):
248248

249249
# convert data buffer to warp array
250250
if isinstance(tiled_data_buffer, np.ndarray):
251-
tiled_data_buffer = wp.array(tiled_data_buffer, device=self.device, dtype=wp.uint8)
251+
# Let warp infer the dtype from numpy array instead of hardcoding uint8
252+
# Different annotators return different dtypes: RGB(uint8), depth(float32), segmentation(uint32)
253+
tiled_data_buffer = wp.array(tiled_data_buffer, device=self.device)
252254
else:
253255
tiled_data_buffer = tiled_data_buffer.to(device=self.device)
254256

0 commit comments

Comments
 (0)