Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion scripts/benchmarks/benchmark_non_rl.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,18 @@
import os
import torch
from datetime import datetime
from gymnasium.wrappers import RecordVideo

from isaaclab.envs import DirectMARLEnvCfg, DirectRLEnvCfg, ManagerBasedRLEnvCfg
from isaaclab.utils.dict import print_dict
from isaaclab.utils.recorder import stop_recording

import isaaclab_tasks # noqa: F401
from isaaclab_tasks.utils.hydra import hydra_task_config

# monkey-patch the stop_recording function to fix memory leak error (see https://github.com/Farama-Foundation/Gymnasium/pull/1444)
RecordVideo.stop_recording = stop_recording

imports_time_end = time.perf_counter_ns()


Expand Down Expand Up @@ -138,7 +143,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
}
print("[INFO] Recording videos during training.")
print_dict(video_kwargs, nesting=4)
env = gym.wrappers.RecordVideo(env, **video_kwargs)
env = RecordVideo(env, **video_kwargs)

task_startup_time_end = time.perf_counter_ns()

Expand Down
8 changes: 7 additions & 1 deletion scripts/benchmarks/benchmark_rlgames.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import random
import torch
from datetime import datetime
from gymnasium.wrappers import RecordVideo

from rl_games.common import env_configurations, vecenv
from rl_games.common.algo_observer import IsaacAlgoObserver
Expand All @@ -76,6 +77,7 @@
from isaaclab.envs import DirectMARLEnvCfg, DirectRLEnvCfg, ManagerBasedRLEnvCfg
from isaaclab.utils.dict import print_dict
from isaaclab.utils.io import dump_pickle, dump_yaml
from isaaclab.utils.recorder import stop_recording

from isaaclab_rl.rl_games import RlGamesGpuEnv, RlGamesVecEnvWrapper

Expand All @@ -86,6 +88,7 @@

sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../.."))


from isaaclab.utils.timer import Timer
from scripts.benchmarks.utils import (
log_app_start_time,
Expand All @@ -100,6 +103,9 @@
parse_tf_logs,
)

# monkey-patch the stop_recording function to fix memory leak error (see https://github.com/Farama-Foundation/Gymnasium/pull/1444)
RecordVideo.stop_recording = stop_recording

torch.backends.cuda.matmul.allow_tf32 = True
torch.backends.cudnn.allow_tf32 = True
torch.backends.cudnn.deterministic = False
Expand Down Expand Up @@ -190,7 +196,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
}
print("[INFO] Recording videos during training.")
print_dict(video_kwargs, nesting=4)
env = gym.wrappers.RecordVideo(env, **video_kwargs)
env = RecordVideo(env, **video_kwargs)

# wrap around environment for rl-games
env = RlGamesVecEnvWrapper(env, rl_device, clip_obs, clip_actions)
Expand Down
8 changes: 7 additions & 1 deletion scripts/benchmarks/benchmark_rsl_rl.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@
import numpy as np
import torch
from datetime import datetime
from gymnasium.wrappers import RecordVideo

from rsl_rl.runners import OnPolicyRunner

from isaaclab.envs import DirectMARLEnvCfg, DirectRLEnvCfg, ManagerBasedRLEnvCfg
from isaaclab.utils.dict import print_dict
from isaaclab.utils.io import dump_pickle, dump_yaml
from isaaclab.utils.recorder import stop_recording

from isaaclab_rl.rsl_rl import RslRlOnPolicyRunnerCfg, RslRlVecEnvWrapper

Expand All @@ -88,6 +90,7 @@
from isaacsim.core.utils.extensions import enable_extension

enable_extension("isaacsim.benchmark.services")

from isaacsim.benchmark.services import BaseIsaacBenchmark

from isaaclab.utils.timer import Timer
Expand All @@ -104,6 +107,9 @@
parse_tf_logs,
)

# monkey-patch the stop_recording function to fix memory leak error (see https://github.com/Farama-Foundation/Gymnasium/pull/1444)
RecordVideo.stop_recording = stop_recording

torch.backends.cuda.matmul.allow_tf32 = True
torch.backends.cudnn.allow_tf32 = True
torch.backends.cudnn.deterministic = False
Expand Down Expand Up @@ -183,7 +189,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
}
print("[INFO] Recording videos during training.")
print_dict(video_kwargs, nesting=4)
env = gym.wrappers.RecordVideo(env, **video_kwargs)
env = RecordVideo(env, **video_kwargs)
# wrap around environment for rsl-rl
env = RslRlVecEnvWrapper(env)

Expand Down
7 changes: 6 additions & 1 deletion scripts/reinforcement_learning/rl_games/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import random
import time
import torch
from gymnasium.wrappers import RecordVideo

from rl_games.common import env_configurations, vecenv
from rl_games.common.player import BasePlayer
Expand All @@ -75,13 +76,17 @@
from isaaclab.utils.assets import retrieve_file_path
from isaaclab.utils.dict import print_dict
from isaaclab.utils.pretrained_checkpoint import get_published_pretrained_checkpoint
from isaaclab.utils.recorder import stop_recording

from isaaclab_rl.rl_games import RlGamesGpuEnv, RlGamesVecEnvWrapper

import isaaclab_tasks # noqa: F401
from isaaclab_tasks.utils import get_checkpoint_path
from isaaclab_tasks.utils.hydra import hydra_task_config

# monkey-patch the stop_recording function to fix memory leak error (see https://github.com/Farama-Foundation/Gymnasium/pull/1444)
RecordVideo.stop_recording = stop_recording

# PLACEHOLDER: Extension template (do not remove this comment)


Expand Down Expand Up @@ -154,7 +159,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
}
print("[INFO] Recording videos during training.")
print_dict(video_kwargs, nesting=4)
env = gym.wrappers.RecordVideo(env, **video_kwargs)
env = RecordVideo(env, **video_kwargs)

# wrap around environment for rl-games
env = RlGamesVecEnvWrapper(env, rl_device, clip_obs, clip_actions, obs_groups, concate_obs_groups)
Expand Down
7 changes: 6 additions & 1 deletion scripts/reinforcement_learning/rl_games/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import os
import random
from datetime import datetime
from gymnasium.wrappers import RecordVideo

import omni
from rl_games.common import env_configurations, vecenv
Expand All @@ -80,12 +81,16 @@
from isaaclab.utils.assets import retrieve_file_path
from isaaclab.utils.dict import print_dict
from isaaclab.utils.io import dump_pickle, dump_yaml
from isaaclab.utils.recorder import stop_recording

from isaaclab_rl.rl_games import RlGamesGpuEnv, RlGamesVecEnvWrapper

import isaaclab_tasks # noqa: F401
from isaaclab_tasks.utils.hydra import hydra_task_config

# monkey-patch the stop_recording function to fix memory leak error (see https://github.com/Farama-Foundation/Gymnasium/pull/1444)
RecordVideo.stop_recording = stop_recording

# PLACEHOLDER: Extension template (do not remove this comment)


Expand Down Expand Up @@ -177,7 +182,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
}
print("[INFO] Recording videos during training.")
print_dict(video_kwargs, nesting=4)
env = gym.wrappers.RecordVideo(env, **video_kwargs)
env = RecordVideo(env, **video_kwargs)

# wrap around environment for rl-games
env = RlGamesVecEnvWrapper(env, rl_device, clip_obs, clip_actions, obs_groups, concate_obs_groups)
Expand Down
7 changes: 6 additions & 1 deletion scripts/reinforcement_learning/rsl_rl/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import os
import time
import torch
from gymnasium.wrappers import RecordVideo

from rsl_rl.runners import DistillationRunner, OnPolicyRunner

Expand All @@ -70,13 +71,17 @@
from isaaclab.utils.assets import retrieve_file_path
from isaaclab.utils.dict import print_dict
from isaaclab.utils.pretrained_checkpoint import get_published_pretrained_checkpoint
from isaaclab.utils.recorder import stop_recording

from isaaclab_rl.rsl_rl import RslRlBaseRunnerCfg, RslRlVecEnvWrapper, export_policy_as_jit, export_policy_as_onnx

import isaaclab_tasks # noqa: F401
from isaaclab_tasks.utils import get_checkpoint_path
from isaaclab_tasks.utils.hydra import hydra_task_config

# monkey-patch the stop_recording function to fix memory leak error (see https://github.com/Farama-Foundation/Gymnasium/pull/1444)
RecordVideo.stop_recording = stop_recording

# PLACEHOLDER: Extension template (do not remove this comment)


Expand Down Expand Up @@ -129,7 +134,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
}
print("[INFO] Recording videos during training.")
print_dict(video_kwargs, nesting=4)
env = gym.wrappers.RecordVideo(env, **video_kwargs)
env = RecordVideo(env, **video_kwargs)

# wrap around environment for rsl-rl
env = RslRlVecEnvWrapper(env, clip_actions=agent_cfg.clip_actions)
Expand Down
7 changes: 6 additions & 1 deletion scripts/reinforcement_learning/rsl_rl/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import os
import torch
from datetime import datetime
from gymnasium.wrappers import RecordVideo

import omni
from rsl_rl.runners import DistillationRunner, OnPolicyRunner
Expand All @@ -89,13 +90,17 @@
)
from isaaclab.utils.dict import print_dict
from isaaclab.utils.io import dump_pickle, dump_yaml
from isaaclab.utils.recorder import stop_recording

from isaaclab_rl.rsl_rl import RslRlBaseRunnerCfg, RslRlVecEnvWrapper

import isaaclab_tasks # noqa: F401
from isaaclab_tasks.utils import get_checkpoint_path
from isaaclab_tasks.utils.hydra import hydra_task_config

# monkey-patch the stop_recording function to fix memory leak error (see https://github.com/Farama-Foundation/Gymnasium/pull/1444)
RecordVideo.stop_recording = stop_recording

# PLACEHOLDER: Extension template (do not remove this comment)

torch.backends.cuda.matmul.allow_tf32 = True
Expand Down Expand Up @@ -171,7 +176,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
}
print("[INFO] Recording videos during training.")
print_dict(video_kwargs, nesting=4)
env = gym.wrappers.RecordVideo(env, **video_kwargs)
env = RecordVideo(env, **video_kwargs)

# wrap around environment for rsl-rl
env = RslRlVecEnvWrapper(env, clip_actions=agent_cfg.clip_actions)
Expand Down
7 changes: 6 additions & 1 deletion scripts/reinforcement_learning/sb3/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import random
import time
import torch
from gymnasium.wrappers import RecordVideo

from stable_baselines3 import PPO
from stable_baselines3.common.vec_env import VecNormalize
Expand All @@ -79,13 +80,17 @@
)
from isaaclab.utils.dict import print_dict
from isaaclab.utils.pretrained_checkpoint import get_published_pretrained_checkpoint
from isaaclab.utils.recorder import stop_recording

from isaaclab_rl.sb3 import Sb3VecEnvWrapper, process_sb3_cfg

import isaaclab_tasks # noqa: F401
from isaaclab_tasks.utils.hydra import hydra_task_config
from isaaclab_tasks.utils.parse_cfg import get_checkpoint_path

# monkey-patch the stop_recording function to fix memory leak error (see https://github.com/Farama-Foundation/Gymnasium/pull/1444)
RecordVideo.stop_recording = stop_recording

# PLACEHOLDER: Extension template (do not remove this comment)


Expand Down Expand Up @@ -147,7 +152,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
}
print("[INFO] Recording videos during training.")
print_dict(video_kwargs, nesting=4)
env = gym.wrappers.RecordVideo(env, **video_kwargs)
env = RecordVideo(env, **video_kwargs)
# wrap around environment for stable baselines
env = Sb3VecEnvWrapper(env, fast_variant=not args_cli.keep_all_info)

Expand Down
7 changes: 6 additions & 1 deletion scripts/reinforcement_learning/sb3/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def cleanup_pbar(*args):
import os
import random
from datetime import datetime
from gymnasium.wrappers import RecordVideo

import omni
from stable_baselines3 import PPO
Expand All @@ -92,12 +93,16 @@ def cleanup_pbar(*args):
)
from isaaclab.utils.dict import print_dict
from isaaclab.utils.io import dump_pickle, dump_yaml
from isaaclab.utils.recorder import stop_recording

from isaaclab_rl.sb3 import Sb3VecEnvWrapper, process_sb3_cfg

import isaaclab_tasks # noqa: F401
from isaaclab_tasks.utils.hydra import hydra_task_config

# monkey-patch the stop_recording function to fix memory leak error (see https://github.com/Farama-Foundation/Gymnasium/pull/1444)
RecordVideo.stop_recording = stop_recording

# PLACEHOLDER: Extension template (do not remove this comment)


Expand Down Expand Up @@ -169,7 +174,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
}
print("[INFO] Recording videos during training.")
print_dict(video_kwargs, nesting=4)
env = gym.wrappers.RecordVideo(env, **video_kwargs)
env = RecordVideo(env, **video_kwargs)

# wrap around environment for stable baselines
env = Sb3VecEnvWrapper(env, fast_variant=not args_cli.keep_all_info)
Expand Down
8 changes: 7 additions & 1 deletion scripts/reinforcement_learning/skrl/play.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import random
import time
import torch
from gymnasium.wrappers import RecordVideo

import skrl
from packaging import version
Expand All @@ -97,6 +98,7 @@
elif args_cli.ml_framework.startswith("jax"):
from skrl.utils.runner.jax import Runner


from isaaclab.envs import (
DirectMARLEnv,
DirectMARLEnvCfg,
Expand All @@ -106,13 +108,17 @@
)
from isaaclab.utils.dict import print_dict
from isaaclab.utils.pretrained_checkpoint import get_published_pretrained_checkpoint
from isaaclab.utils.recorder import stop_recording

from isaaclab_rl.skrl import SkrlVecEnvWrapper

import isaaclab_tasks # noqa: F401
from isaaclab_tasks.utils import get_checkpoint_path
from isaaclab_tasks.utils.hydra import hydra_task_config

# monkey-patch the stop_recording function to fix memory leak error (see https://github.com/Farama-Foundation/Gymnasium/pull/1444)
RecordVideo.stop_recording = stop_recording

# PLACEHOLDER: Extension template (do not remove this comment)

# config shortcuts
Expand Down Expand Up @@ -188,7 +194,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, expe
}
print("[INFO] Recording videos during training.")
print_dict(video_kwargs, nesting=4)
env = gym.wrappers.RecordVideo(env, **video_kwargs)
env = RecordVideo(env, **video_kwargs)

# wrap around environment for skrl
env = SkrlVecEnvWrapper(env, ml_framework=args_cli.ml_framework) # same as: `wrap_env(env, wrapper="auto")`
Expand Down
Loading