Skip to content

Commit

Permalink
Fixes the checkpoint loading error in RSL-RL training script (isaac-s…
Browse files Browse the repository at this point in the history
…im#1210)

# Description

An error of `No checkpoints in the directory` will throw when resume
from a previous training with `--video` set. This is because a new log
folder will be created before the check.

This MR fixes this issue by loading the checkpoint before.

Fixes isaac-sim#1209 

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] 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
  • Loading branch information
bearpaw authored Oct 13, 2024
1 parent 1b8943c commit f879aa6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Guidelines for modifications:
* Rosario Scalise
* Shafeef Omar
* Vladimir Fokow
* Wei Yang
* Xavier Nal
* Yang Jin
* Zhengyu Zhang
Expand Down
9 changes: 6 additions & 3 deletions source/standalone/workflows/rsl_rl/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen

# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg, render_mode="rgb_array" if args_cli.video else None)

# save resume path before creating a new log_dir
if agent_cfg.resume:
resume_path = get_checkpoint_path(log_root_path, agent_cfg.load_run, agent_cfg.load_checkpoint)

# wrap for video recording
if args_cli.video:
video_kwargs = {
Expand All @@ -122,10 +127,8 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
runner = OnPolicyRunner(env, agent_cfg.to_dict(), log_dir=log_dir, device=agent_cfg.device)
# write git state to logs
runner.add_git_repo_to_log(__file__)
# save resume path before creating a new log_dir
# load the checkpoint
if agent_cfg.resume:
# get path to previous checkpoint
resume_path = get_checkpoint_path(log_root_path, agent_cfg.load_run, agent_cfg.load_checkpoint)
print(f"[INFO]: Loading model checkpoint from: {resume_path}")
# load previously trained model
runner.load(resume_path)
Expand Down

0 comments on commit f879aa6

Please sign in to comment.