From 031bde6cd025344197c3902459949c90a897d3a0 Mon Sep 17 00:00:00 2001 From: Ivan-267 <61947090+Ivan-267@users.noreply.github.com> Date: Fri, 22 Sep 2023 20:23:04 +0200 Subject: [PATCH 1/9] Require sb3 version 2 or newer Our environment will not work with older sb3 versions, due to using gymnasium (where older sb3 versions used gym). --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index a6dc219f..b967bddd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,7 +16,7 @@ install_requires = wget huggingface_hub>=0.10 gymnasium - stable-baselines3 + stable-baselines3>=2.0.0 huggingface_sb3 onnx onnxruntime From f59fc2cb48c2c3da4b92f035e33902f86dd3718a Mon Sep 17 00:00:00 2001 From: Ivan-267 <61947090+Ivan-267@users.noreply.github.com> Date: Fri, 22 Sep 2023 20:55:49 +0200 Subject: [PATCH 2/9] Install rllib without reinstalling older sb3 This may fix the related error in tests. However, it will now install rllib separately from what is set in .[rllib]. --- .github/workflows/test-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-ci.yml b/.github/workflows/test-ci.yml index a3cb6c0b..1faa87ac 100644 --- a/.github/workflows/test-ci.yml +++ b/.github/workflows/test-ci.yml @@ -77,7 +77,7 @@ jobs: - name: Clean up dependencies run: | pip uninstall -y stable-baselines3 gymnasium - pip install .[rllib] + pip install ray[rllib] - name: Download examples run: | make download_examples @@ -105,7 +105,7 @@ jobs: - name: Clean up dependencies run: | pip uninstall -y stable-baselines3 gymnasium - pip install .[rllib] + pip install ray[rllib] - name: Download examples run: | make download_examples From 29c78e7ac19bcd7f3168ed216a68cb60d10ed337 Mon Sep 17 00:00:00 2001 From: Ivan-267 <61947090+Ivan-267@users.noreply.github.com> Date: Fri, 22 Sep 2023 21:20:44 +0200 Subject: [PATCH 3/9] Attempt to fix the execution provider error --- godot_rl/wrappers/onnx/stable_baselines_export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/godot_rl/wrappers/onnx/stable_baselines_export.py b/godot_rl/wrappers/onnx/stable_baselines_export.py index 015a06fa..f39d0b32 100644 --- a/godot_rl/wrappers/onnx/stable_baselines_export.py +++ b/godot_rl/wrappers/onnx/stable_baselines_export.py @@ -59,7 +59,7 @@ def verify_onnx_export(ppo: PPO, onnx_model_path: str, num_tests=10): onnx.checker.check_model(onnx_model) sb3_model = ppo.policy.to("cpu") - ort_sess = ort.InferenceSession(onnx_model_path) + ort_sess = ort.InferenceSession(onnx_model_path, providers=['CPUExecutionProvider']) for i in range(num_tests): obs = dict(ppo.observation_space.sample()) From 776f2c9c8e63f9bbf5ba99f4ba42f19e2993c1ac Mon Sep 17 00:00:00 2001 From: Ivan-267 <61947090+Ivan-267@users.noreply.github.com> Date: Sat, 23 Sep 2023 12:20:43 +0200 Subject: [PATCH 4/9] Specify gymnasium 0.26.3 for Rllib --- .github/workflows/test-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-ci.yml b/.github/workflows/test-ci.yml index 1faa87ac..f365c82b 100644 --- a/.github/workflows/test-ci.yml +++ b/.github/workflows/test-ci.yml @@ -77,6 +77,7 @@ jobs: - name: Clean up dependencies run: | pip uninstall -y stable-baselines3 gymnasium + pip install gymnasium==0.26.3 pip install ray[rllib] - name: Download examples run: | @@ -105,6 +106,7 @@ jobs: - name: Clean up dependencies run: | pip uninstall -y stable-baselines3 gymnasium + pip install gymnasium==0.26.3 pip install ray[rllib] - name: Download examples run: | From ddf7c94011e1c4d7295650fabb6937a7e2ae30fe Mon Sep 17 00:00:00 2001 From: Ivan-267 <61947090+Ivan-267@users.noreply.github.com> Date: Sat, 23 Sep 2023 14:02:07 +0200 Subject: [PATCH 5/9] Convert paths to absolute for rllib --- godot_rl/main.py | 1 + godot_rl/wrappers/ray_wrapper.py | 3 ++- setup.cfg | 1 - tests/test_rllib.py | 4 +++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/godot_rl/main.py b/godot_rl/main.py index f856e673..d87c2952 100644 --- a/godot_rl/main.py +++ b/godot_rl/main.py @@ -21,6 +21,7 @@ """ import argparse +import os try: from godot_rl.wrappers.ray_wrapper import rllib_training diff --git a/godot_rl/wrappers/ray_wrapper.py b/godot_rl/wrappers/ray_wrapper.py index 01a6c195..e163fdd4 100644 --- a/godot_rl/wrappers/ray_wrapper.py +++ b/godot_rl/wrappers/ray_wrapper.py @@ -1,3 +1,4 @@ +import os import pathlib from typing import Callable, List, Optional, Tuple @@ -174,7 +175,7 @@ def rllib_training(args, extras): checkpoint_freq=checkpoint_freq, checkpoint_at_end=not args.eval, restore=args.restore, - local_dir=args.experiment_dir or "logs/rllib", + local_dir=os.path.abspath(args.experiment_dir) or os.path.abspath("logs/rllib"), trial_name_creator=lambda trial: f"{args.experiment_name}" if args.experiment_name else f"{trial.trainable_name}_{trial.trial_id}" ) if args.export: diff --git a/setup.cfg b/setup.cfg index b967bddd..c0329fec 100644 --- a/setup.cfg +++ b/setup.cfg @@ -48,7 +48,6 @@ sf = sample-factory rllib = - gymnasium==0.26.3 ray[rllib] cleanrl = diff --git a/tests/test_rllib.py b/tests/test_rllib.py index d6eb62f5..7ec608b7 100644 --- a/tests/test_rllib.py +++ b/tests/test_rllib.py @@ -1,3 +1,5 @@ +import os.path + import pytest from godot_rl.core.utils import cant_import @@ -7,7 +9,7 @@ def test_rllib_training(): from godot_rl.wrappers.ray_wrapper import rllib_training from godot_rl.main import get_args args, extras = get_args() - args.config_file = "tests/fixtures/test_rllib.yaml" + args.config_file = "fixtures/test_rllib.yaml" args.env_path = "examples/godot_rl_JumperHard/bin/JumperHard.x86_64" From 55f86f4076ca5469372d09c9f46131fd6ec7198f Mon Sep 17 00:00:00 2001 From: Ivan-267 <61947090+Ivan-267@users.noreply.github.com> Date: Sat, 23 Sep 2023 14:03:41 +0200 Subject: [PATCH 6/9] Remove left-over import from testing --- godot_rl/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/godot_rl/main.py b/godot_rl/main.py index d87c2952..f856e673 100644 --- a/godot_rl/main.py +++ b/godot_rl/main.py @@ -21,7 +21,6 @@ """ import argparse -import os try: from godot_rl.wrappers.ray_wrapper import rllib_training From 497abd3078cf72ace75b1deacd86a9fe5e5ac73c Mon Sep 17 00:00:00 2001 From: Ivan-267 <61947090+Ivan-267@users.noreply.github.com> Date: Sat, 23 Sep 2023 14:09:44 +0200 Subject: [PATCH 7/9] Restore the test config path changed for testing --- tests/test_rllib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_rllib.py b/tests/test_rllib.py index 7ec608b7..4012ab37 100644 --- a/tests/test_rllib.py +++ b/tests/test_rllib.py @@ -9,8 +9,8 @@ def test_rllib_training(): from godot_rl.wrappers.ray_wrapper import rllib_training from godot_rl.main import get_args args, extras = get_args() - args.config_file = "fixtures/test_rllib.yaml" + args.config_file = "tests/fixtures/test_rllib.yaml" args.env_path = "examples/godot_rl_JumperHard/bin/JumperHard.x86_64" - rllib_training(args, extras) \ No newline at end of file + rllib_training(args, extras) From b8ee52120ce7830407e3ade7a2267c4ec8bd3dfe Mon Sep 17 00:00:00 2001 From: Ivan-267 <61947090+Ivan-267@users.noreply.github.com> Date: Sat, 23 Sep 2023 14:27:52 +0200 Subject: [PATCH 8/9] Remove gymnasium version --- .github/workflows/test-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test-ci.yml b/.github/workflows/test-ci.yml index f365c82b..1faa87ac 100644 --- a/.github/workflows/test-ci.yml +++ b/.github/workflows/test-ci.yml @@ -77,7 +77,6 @@ jobs: - name: Clean up dependencies run: | pip uninstall -y stable-baselines3 gymnasium - pip install gymnasium==0.26.3 pip install ray[rllib] - name: Download examples run: | @@ -106,7 +105,6 @@ jobs: - name: Clean up dependencies run: | pip uninstall -y stable-baselines3 gymnasium - pip install gymnasium==0.26.3 pip install ray[rllib] - name: Download examples run: | From b175d4182ee036e9bc742f68dc9a011a5f1967b7 Mon Sep 17 00:00:00 2001 From: Ivan-267 <61947090+Ivan-267@users.noreply.github.com> Date: Sat, 23 Sep 2023 14:45:43 +0200 Subject: [PATCH 9/9] Remove os.path import left over from testing --- tests/test_rllib.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_rllib.py b/tests/test_rllib.py index 4012ab37..574d2b82 100644 --- a/tests/test_rllib.py +++ b/tests/test_rllib.py @@ -1,5 +1,3 @@ -import os.path - import pytest from godot_rl.core.utils import cant_import