Skip to content

Commit

Permalink
Memory-efficient stats gathering (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmoens authored Jun 26, 2022
1 parent f7177cc commit aad5d04
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion torchrl/trainers/helpers/envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ def get_stats_random_rollout(
while n < cfg.init_env_steps:
_td_stats = proof_environment.rollout(max_steps=cfg.init_env_steps)
n += _td_stats.numel()
td_stats.append(_td_stats)
td_stats.append(_td_stats.to_tensordict().select(key).cpu())
del _td_stats
td_stats = torch.cat(td_stats, 0)

if key is None:
Expand Down

0 comments on commit aad5d04

Please sign in to comment.